2
0

MacTypes.pas 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029
  1. {
  2. File: CarbonCore/MacTypes.h
  3. Contains: Basic Macintosh data types.
  4. Version: CarbonCore-769~1
  5. Bugs?: For bug reports, consult the following page on
  6. the World Wide Web:
  7. http://bugs.freepascal.org
  8. }
  9. { Pascal Translation Updated: Peter N Lewis, <[email protected]>, August 2005 }
  10. { Pascal Translation Updated: Jonas Maebe, <[email protected]>, October 2009 }
  11. { Pascal Translation Updated: Gorazd Krosl <[email protected]>, October 2009 }
  12. { Pascal Translation Updated: Jonas Maebe, <[email protected]>, September 2012 }
  13. {
  14. Modified for use with Free Pascal
  15. Version 308
  16. Please report any bugs to <[email protected]>
  17. }
  18. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  19. {$mode macpas}
  20. {$modeswitch cblocks}
  21. {$packenum 1}
  22. {$macro on}
  23. {$inline on}
  24. {$calling mwpascal}
  25. {$IFNDEF FPC_DOTTEDUNITS}
  26. unit MacTypes;
  27. {$ENDIF FPC_DOTTEDUNITS}
  28. interface
  29. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  30. {$setc GAP_INTERFACES_VERSION := $0308}
  31. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  32. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  33. {$endc}
  34. {$ifc defined CPUPOWERPC and defined CPUI386}
  35. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  36. {$endc}
  37. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  38. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  39. {$endc}
  40. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  41. {$setc __ppc__ := 1}
  42. {$elsec}
  43. {$setc __ppc__ := 0}
  44. {$endc}
  45. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  46. {$setc __ppc64__ := 1}
  47. {$elsec}
  48. {$setc __ppc64__ := 0}
  49. {$endc}
  50. {$ifc not defined __i386__ and defined CPUI386}
  51. {$setc __i386__ := 1}
  52. {$elsec}
  53. {$setc __i386__ := 0}
  54. {$endc}
  55. {$ifc not defined __x86_64__ and defined CPUX86_64}
  56. {$setc __x86_64__ := 1}
  57. {$elsec}
  58. {$setc __x86_64__ := 0}
  59. {$endc}
  60. {$ifc not defined __arm__ and defined CPUARM}
  61. {$setc __arm__ := 1}
  62. {$elsec}
  63. {$setc __arm__ := 0}
  64. {$endc}
  65. {$ifc not defined __arm64__ and defined CPUAARCH64}
  66. {$setc __arm64__ := 1}
  67. {$elsec}
  68. {$setc __arm64__ := 0}
  69. {$endc}
  70. {$ifc defined cpu64}
  71. {$setc __LP64__ := 1}
  72. {$elsec}
  73. {$setc __LP64__ := 0}
  74. {$endc}
  75. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  76. {$error Conflicting definitions for __ppc__ and __i386__}
  77. {$endc}
  78. {$ifc defined __ppc__ and __ppc__}
  79. {$setc TARGET_CPU_PPC := TRUE}
  80. {$setc TARGET_CPU_PPC64 := FALSE}
  81. {$setc TARGET_CPU_X86 := FALSE}
  82. {$setc TARGET_CPU_X86_64 := FALSE}
  83. {$setc TARGET_CPU_ARM := FALSE}
  84. {$setc TARGET_CPU_ARM64 := FALSE}
  85. {$setc TARGET_OS_MAC := TRUE}
  86. {$setc TARGET_OS_IPHONE := FALSE}
  87. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  88. {$setc TARGET_OS_EMBEDDED := FALSE}
  89. {$elifc defined __ppc64__ and __ppc64__}
  90. {$setc TARGET_CPU_PPC := FALSE}
  91. {$setc TARGET_CPU_PPC64 := TRUE}
  92. {$setc TARGET_CPU_X86 := FALSE}
  93. {$setc TARGET_CPU_X86_64 := FALSE}
  94. {$setc TARGET_CPU_ARM := FALSE}
  95. {$setc TARGET_CPU_ARM64 := FALSE}
  96. {$setc TARGET_OS_MAC := TRUE}
  97. {$setc TARGET_OS_IPHONE := FALSE}
  98. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  99. {$setc TARGET_OS_EMBEDDED := FALSE}
  100. {$elifc defined __i386__ and __i386__}
  101. {$setc TARGET_CPU_PPC := FALSE}
  102. {$setc TARGET_CPU_PPC64 := FALSE}
  103. {$setc TARGET_CPU_X86 := TRUE}
  104. {$setc TARGET_CPU_X86_64 := FALSE}
  105. {$setc TARGET_CPU_ARM := FALSE}
  106. {$setc TARGET_CPU_ARM64 := FALSE}
  107. {$ifc defined iphonesim}
  108. {$setc TARGET_OS_MAC := FALSE}
  109. {$setc TARGET_OS_IPHONE := TRUE}
  110. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  111. {$elsec}
  112. {$setc TARGET_OS_MAC := TRUE}
  113. {$setc TARGET_OS_IPHONE := FALSE}
  114. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  115. {$endc}
  116. {$setc TARGET_OS_EMBEDDED := FALSE}
  117. {$elifc defined __x86_64__ and __x86_64__}
  118. {$setc TARGET_CPU_PPC := FALSE}
  119. {$setc TARGET_CPU_PPC64 := FALSE}
  120. {$setc TARGET_CPU_X86 := FALSE}
  121. {$setc TARGET_CPU_X86_64 := TRUE}
  122. {$setc TARGET_CPU_ARM := FALSE}
  123. {$setc TARGET_CPU_ARM64 := FALSE}
  124. {$ifc defined iphonesim}
  125. {$setc TARGET_OS_MAC := FALSE}
  126. {$setc TARGET_OS_IPHONE := TRUE}
  127. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  128. {$elsec}
  129. {$setc TARGET_OS_MAC := TRUE}
  130. {$setc TARGET_OS_IPHONE := FALSE}
  131. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  132. {$endc}
  133. {$setc TARGET_OS_EMBEDDED := FALSE}
  134. {$elifc defined __arm__ and __arm__}
  135. {$setc TARGET_CPU_PPC := FALSE}
  136. {$setc TARGET_CPU_PPC64 := FALSE}
  137. {$setc TARGET_CPU_X86 := FALSE}
  138. {$setc TARGET_CPU_X86_64 := FALSE}
  139. {$setc TARGET_CPU_ARM := TRUE}
  140. {$setc TARGET_CPU_ARM64 := FALSE}
  141. {$setc TARGET_OS_MAC := FALSE}
  142. {$setc TARGET_OS_IPHONE := TRUE}
  143. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  144. {$setc TARGET_OS_EMBEDDED := TRUE}
  145. {$elifc defined __arm64__ and __arm64__}
  146. {$setc TARGET_CPU_PPC := FALSE}
  147. {$setc TARGET_CPU_PPC64 := FALSE}
  148. {$setc TARGET_CPU_X86 := FALSE}
  149. {$setc TARGET_CPU_X86_64 := FALSE}
  150. {$setc TARGET_CPU_ARM := FALSE}
  151. {$setc TARGET_CPU_ARM64 := TRUE}
  152. {$ifc defined ios}
  153. {$setc TARGET_OS_MAC := FALSE}
  154. {$setc TARGET_OS_IPHONE := TRUE}
  155. {$setc TARGET_OS_EMBEDDED := TRUE}
  156. {$elsec}
  157. {$setc TARGET_OS_MAC := TRUE}
  158. {$setc TARGET_OS_IPHONE := FALSE}
  159. {$setc TARGET_OS_EMBEDDED := FALSE}
  160. {$endc}
  161. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  162. {$elsec}
  163. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  164. {$endc}
  165. {$ifc defined __LP64__ and __LP64__ }
  166. {$setc TARGET_CPU_64 := TRUE}
  167. {$elsec}
  168. {$setc TARGET_CPU_64 := FALSE}
  169. {$endc}
  170. {$ifc defined FPC_BIG_ENDIAN}
  171. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  172. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  173. {$elifc defined FPC_LITTLE_ENDIAN}
  174. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  175. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  176. {$elsec}
  177. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  178. {$endc}
  179. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  180. {$setc CALL_NOT_IN_CARBON := FALSE}
  181. {$setc OLDROUTINENAMES := FALSE}
  182. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  183. {$setc OPAQUE_UPP_TYPES := TRUE}
  184. {$setc OTCARBONAPPLICATION := TRUE}
  185. {$setc OTKERNEL := FALSE}
  186. {$setc PM_USE_SESSION_APIS := TRUE}
  187. {$setc TARGET_API_MAC_CARBON := TRUE}
  188. {$setc TARGET_API_MAC_OS8 := FALSE}
  189. {$setc TARGET_API_MAC_OSX := TRUE}
  190. {$setc TARGET_CARBON := TRUE}
  191. {$setc TARGET_CPU_68K := FALSE}
  192. {$setc TARGET_CPU_MIPS := FALSE}
  193. {$setc TARGET_CPU_SPARC := FALSE}
  194. {$setc TARGET_OS_UNIX := FALSE}
  195. {$setc TARGET_OS_WIN32 := FALSE}
  196. {$setc TARGET_RT_MAC_68881 := FALSE}
  197. {$setc TARGET_RT_MAC_CFM := FALSE}
  198. {$setc TARGET_RT_MAC_MACHO := TRUE}
  199. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  200. {$setc TYPE_BOOL := FALSE}
  201. {$setc TYPE_EXTENDED := FALSE}
  202. {$setc TYPE_LONGLONG := TRUE}
  203. {$IFDEF FPC_DOTTEDUNITS}
  204. uses MacOsApi.ConditionalMacros;
  205. {$ELSE FPC_DOTTEDUNITS}
  206. uses ConditionalMacros;
  207. {$ENDIF FPC_DOTTEDUNITS}
  208. {$endc} {not MACOSALLINCLUDE}
  209. {$ALIGN MAC68K}
  210. {*******************************************************************************
  211. Base integer types for all target OS's and CPU's
  212. UInt8 8-bit unsigned integer
  213. SInt8 8-bit signed integer
  214. UInt16 16-bit unsigned integer
  215. SInt16 16-bit signed integer
  216. UInt32 32-bit unsigned integer
  217. SInt32 32-bit signed integer
  218. UInt64 64-bit unsigned integer
  219. SInt64 64-bit signed integer
  220. ********************************************************************************}
  221. type
  222. SInt8 = ShortInt;
  223. UInt8 = Byte;
  224. SInt16 = Integer;
  225. UInt16 = Word;
  226. SInt32 = LongInt;
  227. UInt32 = Longword;
  228. SInt64 = Int64;
  229. UInt64 = QWord;
  230. type
  231. UNSIGNEDBYTE = UInt8;
  232. SIGNEDBYTE = SInt8;
  233. UNSIGNEDWORD = UInt16;
  234. SIGNEDWORD = SInt16;
  235. UInt32_fix = UInt32;
  236. type
  237. {$ifc TARGET_CPU_64}
  238. UNSIGNEDLONG = UInt64;
  239. SIGNEDLONG = SInt64;
  240. {$elsec}
  241. UNSIGNEDLONG = UInt32;
  242. SIGNEDLONG = SInt32;
  243. {$endc}
  244. MacPtrUInt = UNSIGNEDLONG;
  245. MacPtrSInt = SIGNEDLONG;
  246. {$ifc TARGET_RT_BIG_ENDIAN}
  247. type
  248. wide = record
  249. case boolean of
  250. false:
  251. ( hi: SInt32;
  252. lo: UInt32);
  253. true:
  254. ( int: SInt64)
  255. end;
  256. UnsignedWide = record
  257. case boolean of
  258. false:
  259. ( hi: UInt32;
  260. lo: UInt32);
  261. true:
  262. ( int: UInt64)
  263. end;
  264. {$elsec}
  265. type
  266. wide = record
  267. case boolean of
  268. false:
  269. ( lo: UInt32;
  270. hi: SInt32);
  271. true:
  272. ( int: SInt64)
  273. end;
  274. UnsignedWide = record
  275. case boolean of
  276. false:
  277. ( lo: UInt32;
  278. hi: UInt32);
  279. true:
  280. ( int: UInt64)
  281. end;
  282. {$endc} {TARGET_RT_BIG_ENDIAN}
  283. type
  284. SInt8Ptr = ^SInt8;
  285. UInt8Ptr = ^UInt8;
  286. SInt16Ptr = ^SInt16;
  287. UInt16Ptr = ^UInt16;
  288. SInt32Ptr = ^SInt32;
  289. UInt32Ptr = ^UInt32;
  290. SInt64Ptr = ^SInt64;
  291. UInt64Ptr = ^UInt64;
  292. widePtr = ^wide;
  293. UnsignedWidePtr = ^UnsignedWide;
  294. SIGNEDLONGPtr = ^SIGNEDLONG;
  295. UNSIGNEDLONGPtr = ^UNSIGNEDLONG;
  296. { *******************************************************************************
  297. Special types for pascal
  298. ByteParameter UInt8 passed as an 8-bit parameter
  299. Note: The conventions for Pascal on 68K require that a UInt8 when
  300. passed as a parameter occupy 16-bits on the stack, whereas
  301. an SInt8 would only occupy 8-bits. To make C and Pascal
  302. compatable, in pascal all function parameters of type UInt8
  303. or equivalent are changed to ByteParameter.
  304. ******************************************************************************** }
  305. ByteParameter = SInt8;
  306. // For interfaces that use Cs "bool" type
  307. {$ifc TARGET_CPU_PPC}
  308. CBool = SInt32;
  309. {$elsec}
  310. CBool = SInt8;
  311. {$endc}
  312. {*******************************************************************************
  313. Base fixed point types
  314. Fixed 16-bit signed integer plus 16-bit fraction
  315. UnsignedFixed 16-bit unsigned integer plus 16-bit fraction
  316. Fract 2-bit signed integer plus 30-bit fraction
  317. ShortFixed 8-bit signed integer plus 8-bit fraction
  318. ********************************************************************************}
  319. type
  320. Fixed = SInt32;
  321. FixedPtr = ^Fixed;
  322. Fract = SInt32;
  323. FractPtr = ^Fract;
  324. UnsignedFixed = UInt32;
  325. UnsignedFixedPtr = ^UnsignedFixed;
  326. ShortFixed = SInt16;
  327. ShortFixedPtr = ^ShortFixed;
  328. {*******************************************************************************
  329. Base floating point types
  330. Float32 32 bit IEEE float: 1 sign bit, 8 exponent bits, 23 fraction bits
  331. Float64 64 bit IEEE float: 1 sign bit, 11 exponent bits, 52 fraction bits
  332. Float80 80 bit MacOS float: 1 sign bit, 15 exponent bits, 1 integer bit, 63 fraction bits
  333. Float96 96 bit 68881 float: 1 sign bit, 15 exponent bits, 16 pad bits, 1 integer bit, 63 fraction bits
  334. Note: These are fixed size floating point types, useful when writing a floating
  335. point value to disk. If your compiler does not support a particular size
  336. float, a struct is used instead.
  337. Use of of the NCEG types (e.g. double_t) or an ANSI C type (e.g. double) if
  338. you want a floating point representation that is natural for any given
  339. compiler, but might be a different size on different compilers.
  340. ********************************************************************************}
  341. type
  342. Float32 = Single;
  343. Float32Ptr = ^Float32;
  344. Float64 = Double;
  345. Float64Ptr = ^Float64;
  346. LongDouble = Double;
  347. Float80 = record
  348. exp: SInt16;
  349. man: array [0..3] of UInt16;
  350. end;
  351. const
  352. Float32_Min = 1.5e-45;
  353. Float32_Max = 3.4e+38;
  354. Float64_Min = 5.0e-324;
  355. Float64_Max = 1.7e+308;
  356. type
  357. Float96 = record
  358. exp: SInt16;
  359. filler: SInt16;
  360. man: array [0..3] of UInt16;
  361. end;
  362. type
  363. Float32Point = record
  364. x: Float32;
  365. y: Float32;
  366. end;
  367. {GK: Need in AudioUnitCarbonViews.pas }
  368. Float32PointPtr = ^Float32Point;
  369. {*******************************************************************************
  370. Unix compatibility types
  371. ********************************************************************************}
  372. type
  373. size_t = UNSIGNEDLONG;
  374. size_t_ptr = ^size_t;
  375. ssize_t = SIGNEDLONG;
  376. ssize_t_ptr = ^ssize_t;
  377. {*******************************************************************************
  378. MacOS Memory Manager types
  379. Ptr Pointer to a non-relocatable block
  380. Handle Pointer to a master pointer to a relocatable block
  381. Size The number of bytes in a block (signed for historical reasons)
  382. ********************************************************************************}
  383. type
  384. Ptr = ^SInt8;
  385. PtrPtr = ^Ptr;
  386. Handle = ^Ptr;
  387. Handle_fix = Handle; { used as field type when a record declaration contains a Handle field identifier }
  388. Size = SIGNEDLONG;
  389. Size_fix = Size; { used as field type when a record declaration contains a Size field identifier }
  390. SizePtr = ^Size;
  391. UnivPtr = Pointer;
  392. UnivPtrPtr = ^UnivPtr;
  393. {*******************************************************************************
  394. Higher level basic types
  395. OSErr 16-bit result error code
  396. OSStatus 32-bit result error code
  397. LogicalAddress Address in the clients virtual address space
  398. ConstLogicalAddress Address in the clients virtual address space that will only be read
  399. PhysicalAddress Real address as used on the hardware bus
  400. BytePtr Pointer to an array of bytes
  401. ByteCount The size of an array of bytes
  402. ByteOffset An offset into an array of bytes
  403. ItemCount 32-bit iteration count
  404. OptionBits Standard 32-bit set of bit flags
  405. PBVersion ?
  406. Duration 32-bit millisecond timer for drivers
  407. AbsoluteTime 64-bit clock
  408. ScriptCode A particular set of written characters (e.g. Roman vs Cyrillic) and their encoding
  409. LangCode A particular language (e.g. English), as represented using a particular ScriptCode
  410. RegionCode Designates a language as used in a particular region (e.g. British vs American
  411. English) together with other region-dependent characteristics (e.g. date format)
  412. FourCharCode A 32-bit value made by packing four 1 byte characters together
  413. OSType A FourCharCode used in the OS and file system (e.g. creator)
  414. ResType A FourCharCode used to tag resources (e.g. 'DLOG')
  415. ********************************************************************************}
  416. type
  417. OSErr = SInt16;
  418. OSStatus = SInt32;
  419. LogicalAddress = UnivPtr;
  420. ConstLogicalAddress = UnivPtr;
  421. PhysicalAddress = UnivPtr;
  422. BytePtr = UInt8Ptr;
  423. ByteCount = UNSIGNEDLONG;
  424. ByteCountPtr = ^ByteCount;
  425. ByteOffset = UNSIGNEDLONG;
  426. ByteOffsetPtr = ^ByteOffset;
  427. Duration = SInt32;
  428. AbsoluteTime = UnsignedWide;
  429. AbsoluteTimePtr = ^AbsoluteTime;
  430. OptionBits = UInt32;
  431. OptionBitsPtr = ^OptionBits;
  432. ItemCount = UNSIGNEDLONG;
  433. ItemCountPtr = ^ItemCount;
  434. PBVersion = UInt32;
  435. ScriptCode = SInt16;
  436. ScriptCodePtr = ^ScriptCode;
  437. LangCode = SInt16;
  438. LangCodePtr = ^LangCode;
  439. RegionCode = SInt16;
  440. RegionCodePtr = ^RegionCode;
  441. FourCharCode = UInt32;
  442. OSType = FourCharCode;
  443. OSType_fix = OSType; { used as field type when a record declaration contains a OSType field identifier }
  444. ResType = FourCharCode;
  445. OSTypePtr = ^OSType;
  446. OSTypeHandle = ^OSTypePtr;
  447. ResTypePtr = ^ResType;
  448. {*******************************************************************************
  449. Boolean types and values
  450. Boolean Mac OS historic type, sizeof(Boolean)==1
  451. bool Defined in stdbool.h, ISO C/C++ standard type
  452. false Now defined in stdbool.h
  453. true Now defined in stdbool.h
  454. ********************************************************************************}
  455. type
  456. { "Boolean", "true", and "false" are built into the Pascal language }
  457. BooleanPtr = ^Boolean;
  458. boolean_fix = boolean; { used as field type when a record declaration contains a boolean field identifier }
  459. {*******************************************************************************
  460. Function Pointer Types
  461. ProcPtr Generic pointer to a function
  462. Register68kProcPtr Pointer to a 68K function that expects parameters in registers
  463. UniversalProcPtr Pointer to classic 68K code or a RoutineDescriptor
  464. ProcHandle Pointer to a ProcPtr
  465. UniversalProcHandle Pointer to a UniversalProcPtr
  466. ********************************************************************************}
  467. type
  468. ProcPtr = Ptr;
  469. Register68kProcPtr = ProcPtr;
  470. UniversalProcPtr = ProcPtr;
  471. type
  472. ProcHandle = ^ProcPtr;
  473. UniversalProcHandle = ^UniversalProcPtr;
  474. {*******************************************************************************
  475. RefCon Types
  476. For access to private data in callbacks, etc.; refcons are generally
  477. used as a pointer to something, but in the 32-bit world refcons in
  478. different APIs have had various types: pointer, unsigned scalar, and
  479. signed scalar. The RefCon types defined here support the current 32-bit
  480. usage but provide normalization to pointer types for 64-bit.
  481. PRefCon is preferred for new APIs; URefCon and SRefCon are primarily
  482. for compatibility with existing APIs.
  483. ********************************************************************************}
  484. type
  485. PRefCon = UnivPtr;
  486. {$ifc TARGET_CPU_64}
  487. type
  488. URefCon = UnivPtr;
  489. SRefCon = UnivPtr;
  490. {$elsec}
  491. type
  492. URefCon = UInt32;
  493. SRefCon = SInt32;
  494. {$endc}
  495. {*******************************************************************************
  496. Common Constants
  497. noErr OSErr: function performed properly - no error
  498. kNilOptions OptionBits: all flags false
  499. kInvalidID KernelID: NULL is for pointers as kInvalidID is for ID's
  500. kVariableLengthArray array bounds: variable length array
  501. Note: kVariableLengthArray was used in array bounds to specify a variable length array,
  502. usually the last field in a struct. Now that the C language supports
  503. the concept of flexible array members, you can instead use:
  504. struct BarList
  505. (
  506. short listLength;
  507. Bar elements[];
  508. );
  509. However, this changes the semantics somewhat, as sizeof( BarList ) contains
  510. no space for any of the elements, so to allocate a list with space for
  511. the count elements
  512. struct BarList* l = (struct BarList*) malloc( sizeof(BarList) + count * sizeof(Bar) );
  513. ********************************************************************************}
  514. const
  515. noErr = 0;
  516. const
  517. kNilOptions = 0;
  518. const
  519. kInvalidID = 0;
  520. const
  521. kVariableLengthArray = 1;
  522. const
  523. kUnknownType = $3F3F3F3F; { "????" QuickTime 3.0: default unknown ResType or OSType }
  524. {*******************************************************************************
  525. String Types and Unicode Types
  526. UnicodeScalarValue, A complete Unicode character in UTF-32 format, with
  527. UTF32Char values from 0 through 0x10FFFF (excluding the surrogate
  528. range 0xD800-0xDFFF and certain disallowed values).
  529. UniChar, A 16-bit Unicode code value in the default UTF-16 format.
  530. UTF16Char UnicodeScalarValues 0-0xFFFF are expressed in UTF-16
  531. format using a single UTF16Char with the same value.
  532. UnicodeScalarValues 0x10000-0x10FFFF are expressed in
  533. UTF-16 format using a pair of UTF16Chars - one in the
  534. high surrogate range (0xD800-0xDBFF) followed by one in
  535. the low surrogate range (0xDC00-0xDFFF). All of the
  536. characters defined in Unicode versions through 3.0 are
  537. in the range 0-0xFFFF and can be expressed using a single
  538. UTF16Char, thus the term "Unicode character" generally
  539. refers to a UniChar = UTF16Char.
  540. UTF8Char An 8-bit code value in UTF-8 format. UnicodeScalarValues
  541. 0-0x7F are expressed in UTF-8 format using one UTF8Char
  542. with the same value. UnicodeScalarValues above 0x7F are
  543. expressed in UTF-8 format using 2-4 UTF8Chars, all with
  544. values in the range 0x80-0xF4 (UnicodeScalarValues
  545. 0x100-0xFFFF use two or three UTF8Chars,
  546. UnicodeScalarValues 0x10000-0x10FFFF use four UTF8Chars).
  547. UniCharCount A count of UTF-16 code values in an array or buffer.
  548. StrNNN Pascal string holding up to NNN bytes
  549. StringPtr Pointer to a pascal string
  550. StringHandle Pointer to a StringPtr
  551. ConstStringPtr Pointer to a read-only pascal string
  552. ConstStrNNNParam For function parameters only - means string is const
  553. CStringPtr Pointer to a C string (in C: AnsiChar*)
  554. ConstCStringPtr Pointer to a read-only C string (in C: const AnsiChar*)
  555. Note: The length of a pascal string is stored as the first byte.
  556. A pascal string does not have a termination byte.
  557. A pascal string can hold at most 255 bytes of data.
  558. The first character in a pascal string is offset one byte from the start of the string.
  559. A C string is terminated with a byte of value zero.
  560. A C string has no length limitation.
  561. The first character in a C string is the zeroth byte of the string.
  562. ********************************************************************************}
  563. type
  564. UnicodeScalarValue = UInt32;
  565. UTF32Char = UInt32;
  566. UTF32CharPtr = ^UTF32Char;
  567. UniChar = UInt16;
  568. UTF16Char = UInt16;
  569. UTF8Char = UInt8;
  570. UniCharPtr = ^UniChar;
  571. ConstUniCharPtr = UniCharPtr;
  572. UniCharCount = UNSIGNEDLONG;
  573. UniCharCountPtr = ^UniCharCount;
  574. Str15 = STRING[15];
  575. Str27 = STRING[27];
  576. Str31 = STRING[31];
  577. Str32 = STRING[32];
  578. Str36 = STRING[36];
  579. Str63 = STRING[63];
  580. Str255 = STRING[255];
  581. {
  582. The type Str32 is used in many AppleTalk based data structures.
  583. It holds up to 32 one byte chars. The problem is that with the
  584. length byte it is 33 bytes long. This can cause weird alignment
  585. problems in structures. To fix this the type "Str32Field" has
  586. been created. It should only be used to hold 32 chars, but
  587. it is 34 bytes long so that there are no alignment problems.
  588. }
  589. Str32Field = Str32;
  590. {
  591. QuickTime 3.0:
  592. The type StrFileName is used to make MacOS structs work
  593. cross-platform. For example FSSpec or SFReply previously
  594. contained a Str63 field. They now contain a StrFileName
  595. field which is the same when targeting the MacOS but is
  596. a 256 AnsiChar buffer for Win32 and unix, allowing them to
  597. contain long file names.
  598. }
  599. type
  600. StrFileName = Str63;
  601. StringPtr = ^Str255;
  602. StringHandle = ^StringPtr;
  603. ConstStringPtr = StringPtr;
  604. CStringPtr = PAnsiChar;
  605. ConstCStringPtr = CStringPtr;
  606. CStringPtrPtr = ^CStringPtr;
  607. ConstCStringPtrPtr = ^ConstCStringPtr;
  608. ConstStr255Param = Str255;
  609. ConstStr63Param = Str63;
  610. ConstStr36Param = Str36;
  611. ConstStr32Param = Str32;
  612. ConstStr31Param = Str31;
  613. ConstStr27Param = Str27;
  614. ConstStr15Param = Str15;
  615. ConstStrFileNameParam = ConstStr63Param;
  616. {*******************************************************************************
  617. Process Manager type ProcessSerialNumber (previously in Processes.h)
  618. ********************************************************************************}
  619. { type for unique process identifier }
  620. type
  621. ProcessSerialNumber = record
  622. highLongOfPSN: UInt32;
  623. lowLongOfPSN: UInt32;
  624. end;
  625. ProcessSerialNumberPtr = ^ProcessSerialNumber;
  626. {*******************************************************************************
  627. Quickdraw Types
  628. Point 2D Quickdraw coordinate, range: -32K to +32K
  629. Rect Rectangular Quickdraw area
  630. Style Quickdraw font rendering styles
  631. StyleParameter Style when used as a parameter (historical 68K convention)
  632. StyleField Style when used as a field (historical 68K convention)
  633. CharParameter AnsiChar when used as a parameter (historical 68K convention)
  634. Note: The original Macintosh toolbox in 68K Pascal defined Style as a SET.
  635. Both Style and AnsiChar occupy 8-bits in packed records or 16-bits when
  636. used as fields in non-packed records or as parameters.
  637. ********************************************************************************}
  638. type
  639. Point = record
  640. case SInt16 of
  641. 0: (
  642. v: SInt16;
  643. h: SInt16;
  644. );
  645. 1: (
  646. vh: array [0..1] of SInt16;
  647. );
  648. end;
  649. PointPtr = ^Point;
  650. type
  651. Rect = record
  652. case SInt16 of
  653. 0: (
  654. top: SInt16;
  655. left: SInt16;
  656. bottom: SInt16;
  657. right: SInt16;
  658. );
  659. 1: (
  660. topLeft: Point;
  661. botRight: Point;
  662. );
  663. end;
  664. RectPtr = ^Rect;
  665. type
  666. FixedPoint = record
  667. x: Fixed;
  668. y: Fixed;
  669. end;
  670. FixedPointPtr = ^FixedPoint;
  671. type
  672. FixedRect = record
  673. left: Fixed;
  674. top: Fixed;
  675. right: Fixed;
  676. bottom: Fixed;
  677. end;
  678. FixedRectPtr = ^FixedRect;
  679. type
  680. CharParameter = AnsiChar;
  681. const
  682. normal = 0;
  683. bold = 1;
  684. italic = 2;
  685. underline = 4;
  686. outline = 8;
  687. shadow = $10;
  688. condense = $20;
  689. extend = $40;
  690. type
  691. Style = SInt8;
  692. Style_fix = Style; { used as field type when a record declaration contains a Style field identifier }
  693. StyleParameter = SInt16;
  694. StyleField = Style;
  695. {*******************************************************************************
  696. QuickTime TimeBase types (previously in Movies.h)
  697. TimeValue Count of units
  698. TimeScale Units per second
  699. CompTimeValue 64-bit count of units (always a struct)
  700. TimeValue64 64-bit count of units (long long or struct)
  701. TimeBase An opaque reference to a time base
  702. TimeRecord Package of TimeBase, duration, and scale
  703. ********************************************************************************}
  704. type
  705. TimeValue = SInt32;
  706. TimeScale = SInt32;
  707. TimeScalePtr = ^TimeScale;
  708. TimeScale_fix = TimeScale; { used as field type when a record declaration contains a TimeScale field identifier }
  709. CompTimeValue = wide;
  710. CompTimeValuePtr = ^CompTimeValue;
  711. TimeValue64 = SInt64;
  712. TimeValue64Ptr = ^TimeValue64;
  713. TimeBase = ^SInt32; { an opaque 32-bit type }
  714. TimeBase_fix = TimeBase; { used as field type when a record declaration contains a TimeBase field identifier }
  715. TimeBasePtr = ^TimeBase;
  716. TimeRecord = record
  717. value: CompTimeValue; { units (duration or absolute) }
  718. scale: TimeScale; { units per second }
  719. base: TimeBase; { refernce to the time base }
  720. end;
  721. TimeRecordPtr = ^TimeRecord;
  722. {*******************************************************************************
  723. MacOS versioning structures
  724. VersRec Contents of a 'vers' resource
  725. VersRecPtr Pointer to a VersRecPtr
  726. VersRecHndl Resource Handle containing a VersRec
  727. NumVersion Packed BCD version representation (e.g. "4.2.1a3" is 0x04214003)
  728. UniversalProcPtr Pointer to classic 68K code or a RoutineDescriptor
  729. ProcHandle Pointer to a ProcPtr
  730. UniversalProcHandle Pointer to a UniversalProcPtr
  731. ********************************************************************************}
  732. {$ifc TARGET_RT_BIG_ENDIAN}
  733. type
  734. NumVersion = packed record
  735. { Numeric version part of 'vers' resource }
  736. majorRev: UInt8; {1st part of version number in BCD}
  737. minorAndBugRev: UInt8; {2nd & 3rd part of version number share a byte}
  738. stage: UInt8; {stage code: dev, alpha, beta, final}
  739. nonRelRev: UInt8; {revision level of non-released version}
  740. end;
  741. {$elsec}
  742. type
  743. NumVersion = packed record
  744. { Numeric version part of 'vers' resource accessable in little endian format }
  745. nonRelRev: UInt8; {revision level of non-released version}
  746. stage: UInt8; {stage code: dev, alpha, beta, final}
  747. minorAndBugRev: UInt8; {2nd & 3rd part of version number share a byte}
  748. majorRev: UInt8; {1st part of version number in BCD}
  749. end;
  750. {$endc} {TARGET_RT_BIG_ENDIAN}
  751. NumVersionPtr = ^NumVersion;
  752. const
  753. { Version Release Stage Codes }
  754. developStage = $20;
  755. alphaStage = $40;
  756. betaStage = $60;
  757. finalStage = $80;
  758. type
  759. NumVersionVariant = record
  760. case SInt16 of
  761. { NumVersionVariant is a wrapper so NumVersion can be accessed as a 32-bit value }
  762. 0: (
  763. parts: NumVersion;
  764. );
  765. 1: (
  766. whole: UInt32;
  767. );
  768. end;
  769. NumVersionVariantPtr = ^NumVersionVariant;
  770. NumVersionVariantHandle = ^NumVersionVariantPtr;
  771. VersRec = record
  772. { 'vers' resource format }
  773. numericVersion: NumVersion; {encoded version number}
  774. countryCode: SInt16; {country code from intl utilities}
  775. shortVersion: Str255; {version number string - worst case}
  776. reserved: Str255; {longMessage string packed after shortVersion}
  777. end;
  778. VersRecPtr = ^VersRec;
  779. type
  780. VersRecHndl = ^VersRecPtr;
  781. {********************************************************************************
  782. Old names for types
  783. ********************************************************************************}
  784. type
  785. extended80 = Float80;
  786. extended80Ptr = ^extended80;
  787. extended96 = Float96;
  788. extended96Ptr = ^extended96;
  789. VHSelect = SInt8;
  790. {********************************************************************************
  791. Debugger functions
  792. ********************************************************************************}
  793. {$ifc TARGET_OS_MAC}
  794. {
  795. * Debugger()
  796. *
  797. * Availability:
  798. * Mac OS X: in version 10.0 and later in CoreServices.framework
  799. * CarbonLib: in CarbonLib 1.0 and later
  800. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  801. }
  802. procedure Debugger; external name '_Debugger';
  803. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  804. {
  805. * DebugStr()
  806. *
  807. * Availability:
  808. * Mac OS X: in version 10.0 and later in CoreServices.framework
  809. * CarbonLib: in CarbonLib 1.0 and later
  810. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  811. }
  812. procedure DebugStr( const (*var*) debuggerMsg: Str255 ); external name '_DebugStr';
  813. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  814. {$endc}
  815. {
  816. * debugstr()
  817. *
  818. * Availability:
  819. * Mac OS X: not available
  820. * CarbonLib: not available
  821. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  822. }
  823. {$ifc TARGET_CPU_PPC}
  824. { Only for Mac OS native drivers }
  825. {
  826. * SysDebug()
  827. *
  828. * Availability:
  829. * Mac OS X: not available
  830. * CarbonLib: not available
  831. * Non-Carbon CFM: in DriverServicesLib 1.0 and later
  832. }
  833. {
  834. * SysDebugStr()
  835. *
  836. * Availability:
  837. * Mac OS X: not available
  838. * CarbonLib: not available
  839. * Non-Carbon CFM: in DriverServicesLib 1.0 and later
  840. }
  841. {$endc}
  842. {$ifc TARGET_OS_MAC}
  843. { SADE break points }
  844. {
  845. * SysBreak()
  846. *
  847. * Availability:
  848. * Mac OS X: in version 10.0 and later in CoreServices.framework
  849. * CarbonLib: in CarbonLib 1.0 and later
  850. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  851. }
  852. procedure SysBreak; external name '_SysBreak';
  853. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  854. {
  855. * SysBreakStr()
  856. *
  857. * Availability:
  858. * Mac OS X: in version 10.0 and later in CoreServices.framework
  859. * CarbonLib: in CarbonLib 1.0 and later
  860. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  861. }
  862. procedure SysBreakStr( const (*var*) debuggerMsg: Str255 ); external name '_SysBreakStr';
  863. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  864. {
  865. * SysBreakFunc()
  866. *
  867. * Availability:
  868. * Mac OS X: in version 10.0 and later in CoreServices.framework
  869. * CarbonLib: in CarbonLib 1.0 and later
  870. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  871. }
  872. procedure SysBreakFunc( const (*var*) debuggerMsg: Str255 ); external name '_SysBreakFunc';
  873. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA) *)
  874. {$endc}
  875. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  876. end.
  877. {$endc} {not MACOSALLINCLUDE}