som.pas 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534
  1. {
  2. $Id$
  3. Copyright (c) 1994-1996 by International Business Machines Corporation
  4. Copyright (c) 1997 Antony T Curtis.
  5. Copyright (c) 2002-2003 by Yuri Prokushev ([email protected])
  6. System Object Model Run-time library API (SOM.DLL)
  7. This program is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU Library General Public License (LGPL) as
  9. published by the Free Software Foundation; either version 2 of the
  10. License, or (at your option) any later version. This program is
  11. distributed in the hope that it will be useful, but WITHOUT ANY
  12. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. FITNESS FOR A PARTICULAR PURPOSE.
  14. See the GNU Library General Public License for more details. You should
  15. have received a copy of the GNU Library General Public License along
  16. with this program; if not, write to the Free Software Foundation, Inc.,
  17. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. **********************************************************************}
  19. Unit SOM;
  20. Interface
  21. {$mode objfpc}
  22. {$warning This units doesn't work because FPC/2 doesn't implements external vars}
  23. {$warning This code is alpha!}
  24. //uses
  25. // SOMTypes;
  26. var
  27. {$warning support of external vars required}
  28. SOM_MajorVersion, SOM_MinorVersion :Longint; (* SOM Version Numbers *)
  29. //³ 00070 ³ SOM_MajorVersion
  30. //³ 00071 ³ SOM_MinorVersion
  31. {$warning support of external vars required}
  32. SOM_MaxThreads :Longint; // ³ 00095 ³ SOM_MaxThreads (* SOM Thread Support *)
  33. type
  34. Flags =Longint;
  35. type
  36. SOMObjectType = Pointer;
  37. SOMClassType = Pointer;
  38. SOMMSingleInstanceType = Pointer;
  39. SOMClassMgrType = Pointer;
  40. SOMClassPtr = ^SOMClassType;
  41. SOMObjectPtr = ^SOMObjectType;
  42. CORBAObjectType = SOMObjectType; (* in SOM, a CORBA object is a SOM object *)
  43. somToken =Pointer; (* Uninterpretted value *)
  44. somId =^PChar;
  45. somIdPtr =^somId;
  46. somMToken =somToken;
  47. somDToken =somToken;
  48. somMTokenPtr =^somMToken;
  49. somDTokenPtr =^somDToken;
  50. type
  51. ImplId =^PChar;
  52. RepositoryId = PChar;
  53. AttributeDef_AttributeMode = Cardinal;
  54. OperationDef_OperationMode = Longint;
  55. ParameterDef_ParameterMode = Cardinal;
  56. somMethodPtr =Pointer;
  57. somBooleanVector =^Byte;
  58. somCtrlInfo =somToken;
  59. somSharedMethodData =somToken;
  60. somSharedMethodDataPtr=^somSharedMethodData;
  61. somClassInfoPtr =^somClassInfo;
  62. somClassInfo =somToken;
  63. Identifier =PChar; (* CORBA 7.5.1, p. 129 *)
  64. TypeCode = pointer;
  65. (* CORBA 5.7, p.89 *)
  66. any = record
  67. _type : TypeCode;
  68. _value : Pointer;
  69. end;
  70. NamedValue =record
  71. name : Identifier;
  72. argument : any;
  73. len : Longint;
  74. arg_modes : Flags;
  75. end;
  76. (* -- Method/Data Tokens -- For locating methods and data members. *)
  77. somRdAppType =LongInt; (* method signature code -- see def below *)
  78. somFloatMap =Array[0..13] of LongInt; (* float map -- see def below *)
  79. somFloatMapPtr =^somFloatMapPtr;
  80. somMethodInfoStruct =record
  81. callType :somRdAppType;
  82. va_listSize :Longint;
  83. float_map :somFloatMapPtr;
  84. end;
  85. somMethodInfo =somMethodInfoStruct;
  86. somMethodInfoPtr =^somMethodInfo;
  87. somMethodDataStruct =record
  88. id :somId;
  89. ctype :Longint; (* 0=static, 1=dynamic 2=nonstatic *)
  90. descriptor :somId; (* for use with IR interfaces *)
  91. mToken :somMToken; (* NULL for dynamic methods *)
  92. method :somMethodPtr; (* depends on resolution context *)
  93. shared :somSharedMethodDataPtr;
  94. end;
  95. somMethodData =somMethodDataStruct;
  96. somMethodDataPtr =^somMethodDataStruct;
  97. somMethodProc =Procedure(somSelf:SOMObjectType);
  98. somMethodProcPtr =^somMethodProc;
  99. (*---------------------------------------------------------------------
  100. * C++-style constructors are called initializers in SOM. Initializers
  101. * are methods that receive a pointer to a somCtrlStruct as an argument.
  102. *)
  103. somInitInfo =record
  104. cls :SOMClassType;(* the class whose introduced data is to be initialized *)
  105. defaultInit :somMethodProc;
  106. defaultCopyInit :somMethodProc;
  107. defaultConstCopyInit:somMethodProc;
  108. defaultNCArgCopyInit:somMethodProc;
  109. dataOffset :Longint;
  110. legacyInit :somMethodProc;
  111. end;
  112. somDestructInfo =record
  113. cls :SOMClassType;(* the class whose introduced data is to be destroyed *)
  114. defaultDestruct :somMethodProc;
  115. dataOffset :Longint;
  116. legacyUninit :somMethodProc;
  117. end;
  118. somAssignInfo =record
  119. cls :SOMClassType;(* the class whose introduced data is to be assigned *)
  120. defaultAssign :somMethodProc;
  121. defaultConstAssign :somMethodProc;
  122. defaultNCArgAssign :somMethodProc;
  123. udaAssign :somMethodProc;
  124. udaConstAssign :somMethodProc;
  125. dataOffset :Longint;
  126. end;
  127. _IDL_SEQUENCE_octet = record
  128. _maximum : Cardinal;
  129. _length : Cardinal;
  130. _buffer : ^Byte;
  131. end;
  132. ReferenceData =_IDL_SEQUENCE_octet;
  133. (*
  134. * A special info access structure pointed to by
  135. * the parentMtab entry of somCClassDataStructure.
  136. *)
  137. somTD_somRenewNoInitNoZeroThunk =Procedure(var buf); cdecl;
  138. somInitInfoPtr =^somInitInfo;
  139. somInitCtrlStruct =record
  140. mask :somBooleanVector;(* an array of booleans to control ancestor calls *)
  141. info :somInitInfoPtr; (* an array of structs *)
  142. infoSize :Longint; (* increment for info access *)
  143. ctrlInfo :somCtrlInfo;
  144. end;
  145. somInitCtrl =somInitCtrlStruct;
  146. som3InitCtrl =somInitCtrlStruct;
  147. somDestructInfoPtr =^somDestructInfo;
  148. somDestructCtrlStruct =record
  149. mask :somBooleanVector;(* an array of booleans to control ancestor calls *)
  150. info :somDestructInfoPtr;(* an array of structs *)
  151. infoSize :Longint; (* increment for info access *)
  152. ctrlInfo :somCtrlInfo;
  153. end;
  154. somDestructCtrl =somDestructCtrlStruct;
  155. som3DestructCtrl =somDestructCtrlStruct;
  156. somAssignInfoPtr =^somAssignInfo;
  157. somAssignCtrlStruct =record
  158. mask :somBooleanVector;(* an array of booleans to control ancestor calls *)
  159. info :somAssignInfoPtr;(* an array of structs *)
  160. infoSize :Longint; (* increment for info access *)
  161. ctrlInfo :somCtrlInfo;
  162. end;
  163. somAssignCtrl =somAssignCtrlStruct;
  164. som3AssignCtrl =somAssignCtrlStruct;
  165. (*----------------------------------------------------------------------
  166. * The Class Data Structures -- these are used to implement static
  167. * method and data interfaces to SOM objects.
  168. *)
  169. type
  170. (* -- (Generic) Class data Structure *)
  171. somClassDataStructure =record
  172. classObject :SOMClassType; (* changed by shadowing *)
  173. tokens :Array[0..0] of somToken; (* method tokens, etc. *)
  174. end;
  175. somClassDataStructurePtr=^somClassDataStructure;
  176. somInitCtrlPtr =^somInitCtrl;
  177. somDestructCtrlPtr =^somDestructCtrl;
  178. somAssignCtrlPtr =^somAssignCtrl;
  179. (* -- For building lists of method tables *)
  180. somMethodTabPtr =^somMethodTab;
  181. somMethodTabs =^somMethodTabList;
  182. somMethodTabList =record
  183. mtab :somMethodTabPtr;
  184. next :somMethodTabs;
  185. end;
  186. somParentMtabStruct =record
  187. mtab :somMethodTabPtr; (* this class' mtab -- changed by shadowing *)
  188. next :somMethodTabs; (* the parent mtabs -- unchanged by shadowing *)
  189. classObject :SOMClassType; (* unchanged by shadowing *)
  190. somRenewNoInitNoZeroThunk:somTD_somRenewNoInitNoZeroThunk; (* changed by shadowing *)
  191. instanceSize :Longint; (* changed by shadowing *)
  192. initializers :somMethodProcPtr; (* resolved initializer array in releaseorder *)
  193. resolvedMTokens :somMethodProcPtr; (* resolved methods *)
  194. initCtrl :somInitCtrl; (* these fields are filled in if somDTSClass&2 is on *)
  195. destructCtrl :somDestructCtrl;
  196. assignCtrl :somAssignCtrl;
  197. embeddedTotalCount :Longint;
  198. hierarchyTotalCount :Longint;
  199. unused :Longint;
  200. end;
  201. somParentMtabStructPtr=^somParentMtabStruct;
  202. (*
  203. * (Generic) Auxiliary Class Data Structure
  204. *)
  205. somCClassDataStructure=record
  206. parentMtab :somParentMtabStructPtr;
  207. instanceDataToken :somDToken;
  208. wrappers :Array[0..0] of somMethodProc; (* for valist methods *)
  209. end;
  210. somCClassDataStructurePtr=^somCClassDataStructure;
  211. (*----------------------------------------------------------------------
  212. * The Method Table Structure
  213. *)
  214. (* -- to specify an embedded object (or array of objects). *)
  215. somEmbeddedObjStructPtr=^somEmbeddedObjStruct;
  216. somEmbeddedObjStruct =record
  217. copp :SOMClassType; (* address of class of object ptr *)
  218. cnt :Longint; (* object count *)
  219. offset :Longint; (* Offset to pointer (to embedded objs) *)
  220. end;
  221. somMethodTabStruct =record
  222. classObject :SOMClassType;
  223. classInfo :somClassInfoPtr;
  224. className :PChar;
  225. instanceSize :Longint;
  226. dataAlignment :Longint;
  227. mtabSize :Longint;
  228. protectedDataOffset :Longint; (* from class's introduced data *)
  229. protectedDataToken :somDToken;
  230. embeddedObjs :somEmbeddedObjStructPtr;
  231. (* remaining structure is opaque *)
  232. entries :Array[0..0] of somMethodProc;
  233. end;
  234. somMethodTab =somMethodTabStruct;
  235. (* -- For building lists of class objects *)
  236. somClasses =^somClassList;
  237. somClassList =record
  238. cls :SOMClassType;
  239. next :somClasses;
  240. end;
  241. (* -- For building lists of objects *)
  242. somObjects =^somObjectList;
  243. somObjectList =record
  244. obj :SOMObjectType;
  245. next :somObjects;
  246. end;
  247. (*----------------------------------------------------------------------
  248. * Method Stubs -- Signature Support
  249. *
  250. *
  251. * This section defines the structures used to pass method signature
  252. * ingo to the runtime. This supports selection of generic apply stubs
  253. * and runtime generation of redispatchstubs when these are needed. The
  254. * information is registered with the runtime when methods are defined.
  255. *
  256. * When calling somAddStaticMethod, if the redispatchStub is -1, then a
  257. * pointer to a struct of type somApRdInfo is passed as the applyStub.
  258. * Otherwise, the passed redispatchstub and applystub are taken as given.
  259. * When calling somAddDynamicMethod, an actual apply stub must be passed.
  260. * Redispatch stubs for dynamic methods are not available, nor is
  261. * automated support for dynamic method apply stubs. The following
  262. * atructures only appropriate in relation to static methods.
  263. *
  264. * In SOMr2, somAddStaticMethod can be called with an actual redispatchstub
  265. * and applystub *ONLY* if the method doesn't return a structure. Recall
  266. * that no SOMr1 methods returned structures, so SOMr1 binaries obey this
  267. * restriction. The reason for this rule is that SOMr2 *may* use thunks,
  268. * and thunks need to know if a structure is returned. We therefore assume
  269. * that if no signature information is provided for a method through the
  270. * somAddStaticMethod interface, then the method returns a scalar.
  271. *
  272. * If a structure is returned, then a -1 *must* be passed to
  273. * somAddStaticMethod as a redispatchstub. In any case, if a -1 is passed,
  274. * then this means that the applystub actually points to a structure of type
  275. * somApRdInfo. This structure is used to hold and access signature
  276. * information encoded as follows.
  277. *
  278. * If the somApRdInfo pointer is NULL, then, if the runtime was built with
  279. * SOM_METHOD_STUBS defined, a default signature is assumed (no arguments,
  280. * and no structure returned); otherwise, the stubs are taken as
  281. * somDefaultMethod (which produces a runtime error when used) if dynamic
  282. * stubs are not available.
  283. *
  284. * If the somApRdInfo pointer is not NULL, then the structure it points to can
  285. * either include (non-null) redispatch and applystubs (the method is then
  286. * assumed to return a structure), or null stubs followed by information needed
  287. * to generate necessary stubs dynamically.
  288. *)
  289. somApRdInfoStruct =record
  290. rdStub :somMethodProc;
  291. apStub :somMethodProc;
  292. stubInfo :somMethodInfoPtr;
  293. end;
  294. somApRdInfo =somApRdInfoStruct;
  295. (*
  296. * Values for somRdAppType are generated by summing one from column A and one
  297. * from column B of the following constants:
  298. *)
  299. (* Column A: return type *)
  300. const
  301. SOMRdRetsimple = 0; (* Return type is a non-float fullword *)
  302. SOMRdRetfloat = 2; (* Return type is (single) float *)
  303. SOMRdRetdouble = 4; (* Return type is double *)
  304. SOMRdRetlongdouble = 6; (* Return type is long double *)
  305. SOMRdRetaggregate = 8; (* Return type is struct or union *)
  306. SOMRdRetbyte =10; (* Return type is a byte *)
  307. SOMRdRethalf =12; (* Return type is a (2 byte) halfword *)
  308. (* Column B: are there any floating point scalar arguments? *)
  309. SOMRdNoFloatArgs = 0;
  310. SOMRdFloatArgs = 1;
  311. (* A somFloatMap is only needed on RS/6000 *)
  312. (*
  313. * This is an array of offsets for up to the first 13 floating point arguments.
  314. * If there are fewer than 13 floating point arguments, then there will be
  315. * zero entries following the non-zero entries which represent the float args.
  316. * A non-zero entry signals either a single- or a double-precision floating point
  317. * argument. For a double-precision argument, the entry is the stack
  318. * frame offset. For a single-precision argument the entry is the stack
  319. * frame offset + 1. For the final floating point argument, add 2 to the
  320. * code that would otherwise be used.
  321. *)
  322. SOMFMSingle = 1; (* add to indicate single-precision *)
  323. SOMFMLast = 2; (* add to indicate last floating point arg *)
  324. const
  325. SOM_SCILEVEL = 4;
  326. (* The SCI includes the following information:
  327. *
  328. * The address of a class's ClassData structure is passed.
  329. * This structure should have the external name,
  330. * <className>ClassData. The classObject field should be NULL
  331. * (if it is not NULL, then a new class will not be built). somBuildClass will
  332. * set this field to the address of the new class object when it is built.
  333. *
  334. * The address of the class's auxiliary ClassData structure is passed.
  335. * Thi structure should have the external name,
  336. * <className>CClassData. The parentMtab field will be set by somBuildClass.
  337. * This field often allows method calls to a class object to be avoided.
  338. *
  339. * The other structures referenced by the static class information (SCI)
  340. * are used to:
  341. *)
  342. (*
  343. * to specify a static method. The methodId used here must be
  344. * a simple name (i.e., no colons). In all other cases,
  345. * where a somId is used to identify a registered method,
  346. * the somId can include explicit scoping. An explicitly-scoped
  347. * method name is called a method descriptor. For example,
  348. * the method introduced by SOMObjectType as somGetClass has the
  349. * method descriptor "SOMObjectType::somGetClass". When a
  350. * class is contained in an IDL module, the descriptor syntax
  351. * <moduleName>::<className>::<methodName> can be used. Method
  352. * descriptors can be useful when a class supports different methods
  353. * that have the same name (note: IDL prevents this from occuring
  354. * statically, but SOM itself has no problems with this).
  355. *)
  356. type
  357. somStaticMethodStruct =record
  358. classData :somMTokenPtr;
  359. methodId :somIdPtr; (* this must be a simple name (no colons) *)
  360. methodDescriptor :somIdPtr;
  361. method :somMethodPtr;//somMethodProc;
  362. redispatchStub :somMethodPtr;//somMethodProc;
  363. applyStub :somMethodPtr;//somMethodProc;
  364. end;
  365. somStaticMethod_t =somStaticMethodStruct;
  366. somStaticMethod_p =^somStaticMethod_t;
  367. (* to specify an overridden method *)
  368. somOverideMethodStruct=record
  369. methodId :somIdPtr; (* this can be a method descriptor *)
  370. method :somMethodPtr;//somMethodProc;
  371. end;
  372. somOverrideMethod_t =somOverideMethodStruct;
  373. somOverrideMethod_p =^somOverrideMethod_t;
  374. (* to inherit a specific parent's method implementation *)
  375. somInheritedMethodStruct=record
  376. methodId :somIdPtr; (* identify the method *)
  377. parentNum :Longint; (* identify the parent *)
  378. mToken :somMTokenPtr; (* for parentNumresolve *)
  379. end;
  380. somInheritedMethod_t =somInheritedMethodStruct;
  381. somInheritedMethod_p =^somInheritedMethod_t;
  382. (* to register a method that has been moved from this *)
  383. (* class <cls> upwards in the class hierachy to class <dest> *)
  384. somMigratedMethodStruct=record
  385. clsMToken :somMTokenPtr;
  386. (* points into the <cls> classdata structure *)
  387. (* the method token in <dest> will copied here *)
  388. destMToken :somMTokenPtr;
  389. (* points into the <dest> classdata structure *)
  390. (* the method token here will be copied to <cls> *)
  391. end;
  392. somMigratedMethod_t =somMigratedMethodStruct;
  393. somMigratedMethod_p =^somMigratedMethod_t;
  394. (* to specify non-internal data *)
  395. somNonInternalDataStruct=record
  396. classData :somDTokenPtr;
  397. basisForDataOffset :PChar;
  398. end;
  399. somNonInternalData_t =somNonInternalDataStruct;
  400. somNonInternalData_p =^somNonInternalData_t;
  401. (* to specify a "procedure" or "classdata" *)
  402. somProcMethodsStruct =record
  403. classData :somMethodProcPtr;
  404. pEntry :somMethodProc;
  405. end;
  406. somProcMethods_t =somProcMethodsStruct;
  407. somProcMethods_p =^somProcMethods_t;
  408. (* to specify a general method "action" using somMethodStruct *)
  409. (*
  410. the type of action is specified by loading the type field of the
  411. somMethodStruct. There are three bit fields in the overall type:
  412. action (in type & 0xFF)
  413. 0: static -- (i.e., virtual) uses somAddStaticMethod
  414. 1: dynamic -- uses somAddDynamicMethod (classData==0)
  415. 2: nonstatic -- (i.e., nonvirtual) uses somAddMethod
  416. 3: udaAssign -- registers a method as the udaAssign (but doesn't add the method)
  417. 4: udaConstAssign -- like 3, this doesn't add the method
  418. 5: somClassResolve Override (using the class pointed to by *classData)
  419. 6: somMToken Override (using the method token pointed to by methodId)
  420. (note: classData==0 for this)
  421. 7: classAllocate -- indicates the default heap allocator for this class.
  422. If classData == 0, then method is the code address (or NULL)
  423. If classData != 0, then *classData is the code address.
  424. No other info required (or used)
  425. 8: classDeallocate -- like 7, but indicates the default heap deallocator.
  426. 9: classAllocator -- indicates a non default heap allocator for this class.
  427. like 7, but a methodDescriptor can be given.
  428. === the following is not currently supported ===
  429. binary data access -- in (type & 0x100), valid for actions 0,1,2,5,6
  430. 0: the method procedure doesn't want binary data access
  431. 1: the method procedure does want binary data access
  432. aggregate return -- in (type & 0x200), used when binary data access requested
  433. 0: method procedure doesn't return a structure
  434. 1: method procedure does return a structure
  435. *)
  436. somMethodStruct =record
  437. mtype :Longint;
  438. classData :somMTokenPtr;
  439. methodId :somIdPtr;
  440. methodDescriptor :somIdPtr;
  441. method :somMethodProc;
  442. redispatchStub :somMethodProc;
  443. applyStub :somMethodProc;
  444. end;
  445. somMethods_t =somMethodStruct;
  446. somMethods_p =^somMethods_t;
  447. (* to specify a varargs function *)
  448. somVarargsFuncsStruct =record
  449. classData :somMethodProcPtr;
  450. vEntry :somMethodProc;
  451. end;
  452. somVarargsFuncs_t =somVarargsFuncsStruct;
  453. somVarargsFuncs_p =^somVarargsFuncs_t;
  454. (* to specify dynamically computed information (incl. embbeded objs) *)
  455. somDynamicSCIPtr =^somDynamicSciPtr;
  456. somDynamicSCI =record
  457. version :Longint; (* 1 for now *)
  458. instanceDataSize :Longint; (* true size (incl. embedded objs) *)
  459. dataAlignment :Longint; (* true alignment *)
  460. embeddedObjs :somEmbeddedObjStructPtr; (* array end == null copp *)
  461. end;
  462. (*
  463. to specify a DTS class, use the somDTSClass entry in the following
  464. data structure. This entry is a bit vector interpreted as follows:
  465. (somDTSClass & 0x0001) == the class is a DTS C++ class
  466. (somDTSClass & 0x0002) == the class wants the initCtrl entries
  467. of the somParentMtabStruct filled in.
  468. *)
  469. (*
  470. * The Static Class Info Structure passed to somBuildClass
  471. *)
  472. somStaticClassInfoStruct=record
  473. layoutVersion :Longint; (* this struct defines layout version SOM_SCILEVEL *)
  474. numStaticMethods :Longint; (* count of smt entries *)
  475. numStaticOverrides :Longint; (* count of omt entries *)
  476. numNonInternalData :Longint; (* count of nit entries *)
  477. numProcMethods :Longint; (* count of pmt entries *)
  478. numVarargsFuncs :Longint; (* count of vft entries *)
  479. majorVersion :Longint;
  480. minorVersion :Longint;
  481. instanceDataSize :Longint; (* instance data introduced by this class *)
  482. maxMethods :Longint; (* count numStaticMethods and numMethods *)
  483. numParents :Longint;
  484. classId :somId;
  485. explicitMetaId :somId;
  486. implicitParentMeta :Longint;
  487. parents :somIdPtr;
  488. cds :somClassDataStructurePtr;
  489. ccds :somCClassDataStructurePtr;
  490. smt :somStaticMethod_p; (* basic "static" methods for mtab *)
  491. omt :somOverrideMethod_p; (* overrides for mtab *)
  492. nitReferenceBase :PChar;
  493. nit :somNonInternalData_p; (* datatokens for instance data *)
  494. pmt :somProcMethods_p; (* Arbitrary ClassData members *)
  495. vft :somVarargsFuncs_p; (* varargs stubs *)
  496. cif :pointer{^somTP_somClassInitFunc}; (* class init function *)
  497. (* end of layout version 1 *)
  498. (* begin layout version 2 extensions *)
  499. dataAlignment :Longint; (* the desired byte alignment for instance data *)
  500. (* end of layout version 2 *)
  501. //#define SOMSCIVERSION 1
  502. (* begin layout version 3 extensions *)
  503. numDirectInitClasses:Longint;
  504. directInitClasses :somIdPtr;
  505. numMethods :Longint; (* general (including nonstatic) methods for mtab *)
  506. mt :somMethods_p;
  507. protectedDataOffset :Longint; (* access = resolve(instanceDataToken) + offset *)
  508. somSCIVersion :Longint; (* used during development. currently = 1 *)
  509. numInheritedMethods :Longint;
  510. imt :somInheritedMethod_p; (* inherited method implementations *)
  511. numClassDataEntries :Longint; (* should always be filled in *)
  512. classDataEntryNames :somIdPtr; (* either NULL or ptr to an array of somIds *)
  513. numMigratedMethods :Longint;
  514. mmt :somMigratedMethod_p; (* migrated method implementations *)
  515. numInitializers :Longint; (* the initializers for this class *)
  516. initializers :somIdPtr; (* in order of release *)
  517. somDTSClass :Longint; (* used to identify a DirectToSOM class *)
  518. dsci :somDynamicSCIPtr; (* used to register dynamically computed info *)
  519. (* end of layout version 3 *)
  520. end;
  521. somStaticClassInfo =somStaticClassInfoStruct;
  522. somStaticClassInfoPtr =^somStaticClassInfoStruct;
  523. type
  524. (*----------------------------------------------------------------------
  525. * Typedefs for pointers to functions
  526. *)
  527. Contained_Description = record
  528. name : Identifier;
  529. value : any;
  530. end;
  531. InterfaceDef_FullInterfaceDescription = record
  532. name : Identifier;
  533. id, defined_in : RepositoryId;
  534. {operation : IDL_SEQUENCE_OperationDef_OperationDescription;
  535. attributes : IDL_SEQUENCE_AttributeDef_AttributeDescription;}
  536. end;
  537. InterfaceDef_InterfaceDescription = record
  538. name : Identifier;
  539. id, defined_in : RepositoryId;
  540. end;
  541. (* CORBA 7.6.1, p.139 plus 5.7, p.89 enum Data Type Mapping *)
  542. type
  543. TCKind = Cardinal;
  544. const
  545. TypeCode_tk_null = 1;
  546. TypeCode_tk_void = 2;
  547. TypeCode_tk_short = 3;
  548. TypeCode_tk_long = 4;
  549. TypeCode_tk_ushort = 5;
  550. TypeCode_tk_ulong = 6;
  551. TypeCode_tk_float = 7;
  552. TypeCode_tk_double = 8;
  553. TypeCode_tk_boolean = 9;
  554. TypeCode_tk_char = 10;
  555. TypeCode_tk_octet = 11;
  556. TypeCode_tk_any = 12;
  557. TypeCode_tk_TypeCode = 13;
  558. TypeCode_tk_Principal = 14;
  559. TypeCode_tk_objref = 15;
  560. TypeCode_tk_struct = 16;
  561. TypeCode_tk_union = 17;
  562. TypeCode_tk_enum = 18;
  563. TypeCode_tk_string = 19;
  564. TypeCode_tk_sequence = 20;
  565. TypeCode_tk_array = 21;
  566. TypeCode_tk_pointer = 101; (* SOM extension *)
  567. TypeCode_tk_self = 102; (* SOM extension *)
  568. TypeCode_tk_foreign = 103; (* SOM extension *)
  569. (* Short forms of tk_<x> enumerators *)
  570. tk_null = TypeCode_tk_null;
  571. tk_void = TypeCode_tk_void;
  572. tk_short = TypeCode_tk_short;
  573. tk_long = TypeCode_tk_long;
  574. tk_ushort = TypeCode_tk_ushort;
  575. tk_ulong = TypeCode_tk_ulong;
  576. tk_float = TypeCode_tk_float;
  577. tk_double = TypeCode_tk_double;
  578. tk_boolean = TypeCode_tk_boolean;
  579. tk_char = TypeCode_tk_char;
  580. tk_octet = TypeCode_tk_octet;
  581. tk_any = TypeCode_tk_any;
  582. tk_TypeCode = TypeCode_tk_TypeCode;
  583. tk_Principal = TypeCode_tk_Principal;
  584. tk_objref = TypeCode_tk_objref;
  585. tk_struct = TypeCode_tk_struct;
  586. tk_union = TypeCode_tk_union;
  587. tk_enum = TypeCode_tk_enum;
  588. tk_string = TypeCode_tk_string;
  589. tk_sequence = TypeCode_tk_sequence;
  590. tk_array = TypeCode_tk_array;
  591. tk_pointer = TypeCode_tk_pointer;
  592. tk_self = TypeCode_tk_self;
  593. tk_foreign = TypeCode_tk_foreign;
  594. type
  595. SOMClass_somOffsets = record
  596. cls : SOMClassType;
  597. offset : Longint;
  598. end;
  599. _IDL_SEQUENCE_SOMClass = record
  600. _maximum : Cardinal;
  601. _length : Cardinal;
  602. _buffer : SOMClassPtr;
  603. end;
  604. _IDL_SEQUENCE_SOMObject = record
  605. _maximum : Cardinal;
  606. _length : Cardinal;
  607. _buffer : SOMObjectPtr;
  608. end;
  609. SOMClass_SOMClassSequence = _IDL_SEQUENCE_SOMClass;
  610. (*----------------------------------------------------------------------
  611. * Windows extra procedures:
  612. *)
  613. (*
  614. * Replaceable character output handler.
  615. * Points to the character output routine to be used in development
  616. * support. Initialized to <somOutChar>, but may be reset at anytime.
  617. * Should return 0 (false) if an error occurs and 1 (true) otherwise.
  618. *)
  619. type
  620. somTD_SOMOutCharRoutine =Function(ch:Char):Longint; cdecl;
  621. var
  622. {$warning support of external vars required}
  623. SOMOutCharRoutine :somTD_SOMOutCharRoutine;//³ 00015 ³ SOMOutCharRoutine
  624. Procedure somSetOutChar(outch:somTD_SOMOutCharRoutine); cdecl;
  625. external 'som' name 'somSetOutChar'; {index 85}
  626. Function somMainProgram:SOMClassMgrType; cdecl;
  627. external 'som' name 'somMainProgram'; {index 88}
  628. Procedure somEnvironmentEnd; cdecl;
  629. external 'som' name 'somEnvironmentEnd'; {index 83}
  630. Function somAbnormalEnd:Boolean; cdecl;
  631. external 'som' name 'somAbnormalEnd'; {index 84}
  632. (*--------------------------------------------------------*)
  633. (*---------------------------------------------------------------------
  634. * Offset-based method resolution.
  635. *)
  636. Function somResolve(obj:SOMObjectType; mdata:somMToken):{somMethodProc}pointer; cdecl;
  637. external 'som' name 'somResolve'; {index 37}
  638. Function somParentResolve(parentMtabs:somMethodTabs;
  639. mToken:somMToken):somMethodProc; cdecl;
  640. external 'som' name 'somParentResolve'; {index 33}
  641. Function somParentNumResolve(parentMtabs:somMethodTabs;
  642. parentNum:Longint;mToken:somMToken):{somMethodProc}pointer; cdecl;
  643. external 'som' name 'somParentNumResolve'; {index 50}
  644. Function somClassResolve(obj:SOMClassType; mdata:somMToken):{somMethodProc}pointer; cdecl;
  645. external 'som' name 'somClassResolve'; {index 48}
  646. Function somAncestorResolve(obj:SOMObjectType; (* the object *)
  647. var ccds:somCClassDataStructure; (* id the ancestor *)
  648. mToken:somMToken):{somMethodProc}pointer; cdecl;
  649. external 'som' name 'somAncestorResolve'; {index 74}
  650. Function somResolveByName(obj:SOMObjectType;
  651. methodName:PChar):{somMethodProc}pointer; cdecl;
  652. external 'som' name 'somResolveByName'; {index 61}
  653. (*------------------------------------------------------------------------------
  654. * Offset-based data resolution
  655. *)
  656. Function somDataResolve(obj:SOMObjectType; dataId:somDToken):somToken; cdecl;
  657. external 'som' name 'somDataResolve'; {index 47}
  658. Function somDataResolveChk(obj:SOMObjectType; dataId:somDToken):somToken; cdecl;
  659. external 'som' name 'somDataResolveChk'; {index 72}
  660. (*----------------------------------------------------------------------
  661. * Misc. procedures:
  662. *)
  663. (*
  664. * Create and initialize the SOM environment
  665. *
  666. * Can be called repeatedly
  667. *
  668. * Will be called automatically when first object (including a class
  669. * object) is created, if it has not already been done.
  670. *
  671. * Returns the SOMClassMgrObject
  672. *)
  673. Function somEnvironmentNew:SOMClassMgrType; cdecl;
  674. external 'som' name 'somEnvironmentNew'; {index 30}
  675. (*
  676. * Test whether <obj> is a valid SOM object. This test is based solely on
  677. * the fact that (on this architecture) the first word of a SOM object is a
  678. * pointer to its method table. The test is therefore most correctly understood
  679. * as returning true if and only if <obj> is a pointer to a pointer to a
  680. * valid SOM method table. If so, then methods can be invoked on <obj>.
  681. *)
  682. Function somIsObj(obj:somToken):Boolean; cdecl;
  683. external 'som' name 'somIsObj'; {index 60}
  684. (*
  685. * Return the class that introduced the method represented by a given method token.
  686. *)
  687. Function somGetClassFromMToken(mToken:somMToken):SOMClassType; cdecl;
  688. external 'som' name 'somGetClassFromMToken'; {index 82}
  689. (*----------------------------------------------------------------------
  690. * String Manager: stem <somsm>
  691. *)
  692. Function somCheckID(id:somId):somId; cdecl;
  693. external 'som' name 'somCheckId'; {index 26}
  694. (* makes sure that the id is registered and in normal form, returns *)
  695. (* the id *)
  696. Function somRegisterId(id:somId):Longint; cdecl;
  697. external 'som' name 'somRegisterId'; {index 36}
  698. (* Same as somCheckId except returns 1 (true) if this is the first *)
  699. (* time the string associated with this id has been registered, *)
  700. (* returns 0 (false) otherwise *)
  701. Function somIDFromString(aString:PChar):somId; cdecl;
  702. external 'som' name 'somIdFromString'; {index 31}
  703. (* caller is responsible for freeing the returned id with SOMFree *)
  704. // Not found
  705. //Function somIdFromStringNoFree(aString:PChar):somId; cdecl;
  706. (* call is responsible for *not* freeing the returned id *)
  707. Function somStringFromId(id:somId):PChar; cdecl;
  708. external 'som' name 'somStringFromId'; {index 40}
  709. Function somCompareIds(id1,id2:somId):Longint; cdecl;
  710. external 'som' name 'somCompareIds'; {index 27}
  711. (* returns true (1) if the two ids are equal, else false (0) *)
  712. Function somTotalRegIds:Longint; cdecl;
  713. external 'som' name 'somTotalRegIds'; {index 43}
  714. (* Returns the total number of ids that have been registered so far, *)
  715. (* you can use this to advise the SOM runtime concerning expected *)
  716. (* number of ids in later executions of your program, via a call to *)
  717. (* somSetExpectedIds defined below *)
  718. Procedure somSetExpectedIds(numIds:Longint{ulong}); cdecl;
  719. external 'som' name 'somSetExpectedIds'; {index 39}
  720. (* Tells the SOM runtime how many unique ids you expect to use during *)
  721. (* the execution of your program, this can improve space and time *)
  722. (* utilization slightly, this routine must be called before the SOM *)
  723. (* environment is created to have any effect *)
  724. Function somUniqueKey(id:somId):Longint{ulong}; cdecl;
  725. external 'som' name 'somUniqueKey'; {index 44}
  726. (* Returns the unique key for this id, this key will be the same as the *)
  727. (* key in another id if and only if the other id refers to the same *)
  728. (* name as this one *)
  729. Procedure somBeginPersistentIds; cdecl;
  730. external 'som' name 'somBeginPersistentIds'; {index 24}
  731. (* Tells the id manager that strings for any new ids that are *)
  732. (* registered will never be freed or otherwise modified. This allows *)
  733. (* the id manager to just use a pointer to the string in the *)
  734. (* unregistered id as the master copy of the ids string. Thus saving *)
  735. (* space *)
  736. (* Under normal use (where ids are static varibles) the string *)
  737. (* associated with an id would only be freed if the code module in *)
  738. (* which it occured was unloaded *)
  739. Procedure somEndPersistentIds; cdecl;
  740. external 'som' name 'somEndPersistentIds'; {index 29}
  741. (* Tells the id manager that strings for any new ids that are *)
  742. (* registered may be freed or otherwise modified. Therefore the id *)
  743. (* manager must copy the strings inorder to remember the name of an *)
  744. (* id. *)
  745. (*----------------------------------------------------------------------
  746. * Class Manager: SOMClassMgrType, stem <somcm>
  747. *)
  748. (* Global class manager object *)
  749. var
  750. {$warning support of external vars required}
  751. SOMClassMgrObject : SOMClassMgrType;//³ 00007 ³ SOMClassMgrObject
  752. (* The somRegisterClassLibrary function is provided for use
  753. * in SOM class libraries on platforms that have loader-invoked
  754. * entry points associated with shared libraries (DLLs).
  755. *
  756. * This function registers a SOM Class Library with the SOM Kernel.
  757. * The library is identified by its file name and a pointer
  758. * to its initialization routine. Since this call may occur
  759. * prior to the invocation of somEnvironmentNew, its actions
  760. * are deferred until the SOM environment has been initialized.
  761. * At that time, the SOMClassMgrObject is informed of all
  762. * pending library initializations via the _somRegisterClassLibrary
  763. * method. The actual invocation of the library's initialization
  764. * routine will occur during the execution of the SOM_MainProgram
  765. * macro (for statically linked libraries), or during the _somFindClass
  766. * method (for libraries that are dynamically loaded).
  767. *)
  768. Procedure somRegisterClassLibrary(libraryName:PChar;
  769. libraryInitRun:somMethodProc); cdecl;
  770. external 'som' name 'somRegisterClassLibrary'; {index 86}
  771. (*----------------------------------------------------------------------
  772. * -- somApply --
  773. *
  774. * This routine replaces direct use of applyStubs in SOMr1. The reason
  775. * for the replacement is that the SOMr1 style of applyStub is not
  776. * generally available in SOMr2, which uses a fixed set of applyStubs,
  777. * according to method information in the somMethodData. In particular,
  778. * neither the redispatch stub nor the apply stub found in the method
  779. * data structure are necessarily useful as such. The method somGetRdStub
  780. * is the way to get a redispatch stub, and the above function is the
  781. * way to call an apply stub. If an appropriate apply stub for the
  782. * method indicated by md is available, then this is invoked and TRUE is
  783. * returned; otherwise FALSE is returned.
  784. *
  785. * The va_list passed to somApply *must* include the target object,
  786. * somSelf, as its first entry, and any single precision floating point
  787. * arguments being passed to the the method procedure must be
  788. * represented on the va_list using double precision values. retVal cannot
  789. * be NULL.
  790. *)
  791. Function somApply(var somSelf:SOMObjectType;
  792. var retVal:somToken;
  793. mdPtr:somMethodDataPtr;
  794. var ap):Boolean; cdecl;
  795. external 'som' name 'somApply'; {index 69}
  796. (*---------------------------------------------------------------------
  797. * -- somBuildClass --
  798. *
  799. * This procedure automates construction of a new class object. A variety of
  800. * special structures are used to allow language bindings to statically define
  801. * the information necessary to specify a class. Pointers to these static
  802. * structures are accumulated into an overall "static class information"
  803. * structure or SCI, passed to somBuildClass. The SCI has evolved over time.
  804. * The current version is defined here.
  805. *)
  806. Function somBuildClass(inherit_vars:Longint;
  807. var sci:somStaticClassInfo;
  808. majorVersion,minorVersion:Longint):SOMClassType; cdecl;
  809. external 'som' name 'somBuildClass'; {index 49}
  810. (*
  811. The arguments to somBuildClass are as follows:
  812. inherit_vars: a bit mask used to control inheritance of implementation
  813. Implementation is inherited from parent i iff the bit 1<<i is on, or i>=32.
  814. sci: the somStaticClassInfo defined above.
  815. majorVersion, minorVersion: the version of the class implementation.
  816. *)
  817. (*---------------------------------------------------------------------
  818. * Used by old single-inheritance emitters to make class creation
  819. * an atomic operation. Kept for backwards compatability.
  820. *)
  821. type
  822. somTD_classInitRoutine=Procedure(var a,b:SOMClassType); cdecl;
  823. Procedure somConstructClass(classInitRoutine:somTD_ClassInitRoutine;
  824. parentClass,metaClass:SOMClassType;
  825. var cds :somClassDataStructure); cdecl;
  826. external 'som' name 'somConstructClass'; {index 28}
  827. (*
  828. * Uses <SOMOutCharRoutine> to output its arguments under control of the ANSI C
  829. * style format. Returns the number of characters output.
  830. *)
  831. Function somPrintf(fnt:PChar;buf:pointer):Longint; cdecl;
  832. external 'som' name 'somPrintf'; {index 35}
  833. // vprint form of somPrintf
  834. Function somVPrintf(fnt:PChar;var ap):Longint; cdecl;
  835. external 'som' name 'somVprintf'; {index 45}
  836. // Outputs (via somPrintf) blanks to prefix a line at the indicated level
  837. Procedure somPrefixLevel(level:Longint); cdecl;
  838. external 'som' name 'somPrefixLevel'; {index 34}
  839. // Combines somPrefixLevel and somPrintf
  840. Procedure somLPrintf(level:Longint;fmt:PChar;var buf); cdecl;
  841. external 'som' name 'somLPrintf'; {index 32}
  842. Function SOMObjectNewClass(majorVersion,minorVersion:Longint):SOMClassType; cdecl;
  843. external 'som' name 'SOMObjectNewClass'; {index 22}
  844. Function SOMClassNewClass(majorVersion,minorVersion:Longint):SOMClassType; cdecl;
  845. external 'som' name 'SOMClassNewClass'; {index 21}
  846. Function SOMClassMgrNewClass(majorVersion,minorVersion:Longint):SOMClassType; cdecl;
  847. external 'som' name 'SOMClassMgrNewClass'; {index 20}
  848. (*----------------------------------------------------------------------
  849. * Pointers to routines used to do dynamic code loading and deleting
  850. *)
  851. type
  852. somTD_SOMLoadModule =Function({IN}Module:PChar (* className *);
  853. {IN}FileName:PChar (* fileName *);
  854. {IN}FuncName:PChar (* functionName *);
  855. {IN}MajorVer:Longint (* majorVersion *);
  856. {IN}MinorVer:Longint (* minorVersion *);
  857. {OUT}var ref:somToken (* modHandle *)):Longint; cdecl;
  858. somTD_SOMDeleteModule =Function({IN} ref:somToken (* modHandle *)):Longint; cdecl;
  859. somTD_SOMClassInitFuncName =Function:PChar; cdecl;
  860. var
  861. {$warning support of external vars required}
  862. SOMLoadModule :somTD_SOMLoadModule;//³ 00011 ³ SOMLoadModule
  863. {$warning support of external vars required}
  864. SOMDeleteModule :somTD_SOMDeleteModule;//³ 00008 ³ SOMDeleteModule
  865. {$warning support of external vars required}
  866. SOMClassInitFuncName :somTD_SOMClassInitFuncName; //³ 00004 ³ SOMClassInitFuncName
  867. (*----------------------------------------------------------------------
  868. * Replaceable SOM Memory Management Interface
  869. *
  870. * External procedure variables SOMCalloc, SOMFree, SOMMalloc, SOMRealloc
  871. * have the same interface as their standard C-library analogs.
  872. *)
  873. type
  874. somTD_SOMMalloc =Function({IN} size_t:Longint (* nbytes *)):somToken; cdecl;
  875. somTD_SOMCalloc =Function({IN} size_c:Longint (* element_count *);
  876. {IN} size_e:Longint (* element_size *)):somToken; cdecl;
  877. somTD_SOMRealloc =Function({IN} ref:somToken (* memory *);
  878. {IN} size:Longint (* nbytes *)):somToken; cdecl;
  879. somTD_SOMFree =Procedure({IN} ref:somToken (* memory *)); cdecl;
  880. var
  881. {$warning support of external vars required}
  882. SOMCalloc :somTD_SOMCalloc; // ³ 00001 ³ SOMCalloc
  883. {$warning support of external vars required}
  884. SOMFree :somTD_SOMFree; //³ 00010 ³ SOMFree
  885. {$warning support of external vars required}
  886. SOMMalloc :somTD_SOMMalloc;//³ 00012 ³ SOMMalloc
  887. {$warning support of external vars required}
  888. SOMRealloc :somTD_SOMRealloc;//³ 00016 ³ SOMRealloc
  889. (*----------------------------------------------------------------------
  890. * Replaceable SOM Error handler
  891. *)
  892. type
  893. somTD_SOMError =Procedure({IN} code:Longint (* code *);
  894. {IN} fn:PChar (* fileName *);
  895. {IN} ln:Longint (* linenum *)); cdecl;
  896. var
  897. {$warning support of external vars required}
  898. SOMError :somTD_SOMError;//³ 00009 ³ SOMError
  899. (*----------------------------------------------------------------------
  900. * Replaceable SOM Semaphore Operations
  901. *
  902. * These operations are used by the SOM Kernel to make thread-safe
  903. * state changes to internal resources.
  904. *)
  905. type
  906. somTD_SOMCreateMutexSem =Function({OUT}var sem:somToken ):Longint; cdecl;
  907. somTD_SOMRequestMutexSem =Function({IN}sem:somToken ):Longint; cdecl;
  908. somTD_SOMReleaseMutexSem =Function({IN}sem:somToken ):Longint; cdecl;
  909. somTD_SOMDestroyMutexSem =Function({IN}sem:somToken ):Longint; cdecl;
  910. var
  911. {$warning support of external vars required}
  912. SOMCreateMutexSem :somTD_SOMCreateMutexSem;//³ 00090 ³ SOMCreateMutexSem
  913. {$warning support of external vars required}
  914. SOMRequestMutexSem :somTD_SOMRequestMutexSem;//³ 00091 ³ SOMRequestMutexSem
  915. {$warning support of external vars required}
  916. SOMReleaseMutexSem :somTD_SOMReleaseMutexSem;//³ 00092 ³ SOMReleaseMutexSem
  917. {$warning support of external vars required}
  918. SOMDestroyMutexSem :somTD_SOMDestroyMutexSem;//³ 00093 ³ SOMDestroyMutexSem
  919. (*----------------------------------------------------------------------
  920. * Replaceable SOM Thread Identifier Operation
  921. *
  922. * This operation is used by the SOM Kernel to index data unique to the
  923. * currently executing thread. It must return a small integer that
  924. * uniquely represents the current thread within the current process.
  925. *)
  926. type
  927. somTD_SOMGetThreadId =Function:Longint; cdecl;
  928. var
  929. {$warning support of external vars required}
  930. SOMGetThreadId :somTD_SOMGetThreadId;//³ 00094 ³ SOMGetThreadId
  931. (*----------------------------------------------------------------------
  932. * Externals used in the implementation of SOM, but not part of the
  933. * SOM API.
  934. *)
  935. Function somTestCls(obj:SOMObjectType; classObj:SOMClassType;
  936. fileName:PChar; lineNumber:Longint):SOMObjectType; cdecl;
  937. external 'som' name 'somTestCls'; {index 42}
  938. Procedure somTest(condition,severity:Longint;fileName:PChar;
  939. lineNum:Longint;msg:PChar); cdecl;
  940. external 'som' name 'somTest'; {index 41}
  941. Procedure somAssert(condition,ecode:Longint;
  942. fileName:PChar;lineNum:Longint;msg:PChar); cdecl;
  943. external 'som' name 'somAssert'; {index 23}
  944. type
  945. exception_type = (NO_EXCEPTION, USER_EXCEPTION, SYSTEM_EXCEPTION);
  946. completion_status = (YES, NO, MAYBE);
  947. StExcep = record
  948. minot : Cardinal;
  949. completed : completion_status;
  950. end;
  951. Environment =^EnvironmentType;
  952. EnvironmentType = record
  953. _major : exception_type;
  954. exception : record
  955. _exception_name : PChar;
  956. _params : Pointer;
  957. end;
  958. _somdAnchor : pointer;
  959. end;
  960. Function somExceptionId(ev:Environment):PChar; cdecl;
  961. external 'som' name 'somExceptionId'; {index 52}
  962. Function somExceptionValue(ev:Environment):Pointer; cdecl;
  963. external 'som' name 'somExceptionValue'; {index 53}
  964. Procedure somExceptionFree(ev:Environment); cdecl;
  965. external 'som' name 'somExceptionFree'; {index 54}
  966. Procedure somSetException(ev:Environment;major:exception_type;exception_name:PChar;params:pointer); cdecl;
  967. external 'som' name 'somSetException'; {index 55}
  968. Function somGetGlobalEnvironment:Environment; cdecl;
  969. external 'som' name 'somGetGlobalEnvironment'; {index 58}
  970. (* Exception function names per CORBA 5.19, p.99 *)
  971. Function exception_id(ev:Environment):PChar; cdecl;
  972. Function exception_value(ev:Environment):Pointer; cdecl;
  973. Procedure exception_free(ev:Environment); cdecl;
  974. (* Convenience macros for manipulating environment structures
  975. *
  976. * SOM_CreateLocalEnvironment returns a pointer to an Environment.
  977. * The other 3 macros all expect a single argument that is also
  978. * a pointer to an Environment. Use the create/destroy forms for
  979. * a dynamic local environment and the init/uninit forms for a stack-based
  980. * local environment.
  981. *
  982. * For example
  983. *
  984. * Environment *ev;
  985. * ev = SOM_CreateLocalEnvironment ();
  986. * ... Use ev in methods
  987. * SOM_DestroyLocalEnvironment (ev);
  988. *
  989. * or
  990. *
  991. * Environment ev;
  992. * SOM_InitEnvironment (&ev);
  993. * ... Use &ev in methods
  994. * SOM_UninitEnvironment (&ev);
  995. *)
  996. Function SOM_CreateLocalEnvironment:Environment; cdecl;
  997. Procedure SOM_DestroyLocalEnvironment(ev:Environment); cdecl;
  998. Procedure SOM_InitEnvironment(ev:Environment); cdecl;
  999. Procedure SOM_UninitEnvironment(ev:Environment); cdecl;
  1000. (*----------------------------------------------------------------------
  1001. * Macros are used in the C implementation of SOM... However, Pascal
  1002. * doesn't have macro capability... (from SOMCDEV.H)
  1003. *)
  1004. { Change SOM_Resolve(o,ocn,mn) to...
  1005. somTD_ocn_mn(somResolve(SOM_TestCls(o, ocnClassData.classObject), ocnClassData.mn)))
  1006. Change SOM_ResolveNoCheck(o,ocn,mn) to...
  1007. somTD_ocn_mn(somResolve(o,ocnClassData,mn))
  1008. Change SOM_ParentNumResolveCC(pcn,pcp,ocn,mn) to...
  1009. somTD_pcn_mn(somParentNumResolve(ocn_CClassData.parentMtab,pcp,pcnClassData.mn))
  1010. Change SOM_ParentNumResolve(pcn,pcp,mtabs,mn) to...
  1011. somTD_pcn_mn(somParentNumResolve(mtabs,pcp,pcnClassData.mn))
  1012. Change SOM_ClassResolve(cn,class,mn) to...
  1013. somTD_cn_mn(somClassResolve(class,cnClassData.mn))
  1014. Change SOM_ResolveD(o,tdc,cdc,mn) to...
  1015. somTD_tdc_mn(somResolve(SOM_TestCls(o,cdcClassData.classObject), cdcClassData.mn)))
  1016. Change SOM_ParentResolveE(pcn,mtbls,mn) to...
  1017. somTD_pcn_mn(somParentResolve(mtbls,pcnClassData.mn))
  1018. Change SOM_DataResolve(obj,dataId) to...
  1019. somDataResolve(obj, dataId)
  1020. Change SOM_ClassLibrary(name) to...
  1021. somRegisterClassLibrary(name,somMethodProc(SOMInitModule))
  1022. }
  1023. type
  1024. SOMClassCClassDataStructure = record
  1025. parentMtab : somMethodTabs;
  1026. instanceDataToken : somDToken;
  1027. end;
  1028. var
  1029. {$warning support of external vars required}
  1030. SOMClassCClassData : SOMClassCClassDataStructure;//³ 00002 ³ SOMClassCClassData
  1031. type
  1032. SOMClassClassDataStructure = record
  1033. classObject : SOMClassType;
  1034. somNew : somMToken;
  1035. somRenew : somMToken;
  1036. somInitClass : somMToken;
  1037. somClassReady : somMToken;
  1038. somGetName : somMToken;
  1039. somGetParent : somMToken;
  1040. somDescendedFrom : somMToken;
  1041. somCheckVersion : somMToken;
  1042. somFindMethod : somMToken;
  1043. somFindMethodOk : somMToken;
  1044. somSupportsMethod : somMToken;
  1045. somGetNumMethods : somMToken;
  1046. somGetInstanceSize : somMToken;
  1047. somGetInstanceOffset : somMToken;
  1048. somGetInstancePartSize : somMToken;
  1049. somGetMethodIndex : somMToken;
  1050. somGetNumStaticMethods : somMToken;
  1051. somGetPClsMtab : somMToken;
  1052. somGetClassMtab : somMToken;
  1053. somAddStaticMethod : somMToken;
  1054. somOverrideSMethod : somMToken;
  1055. somAddDynamicMethod : somMToken;
  1056. somcPrivate0 : somMToken;
  1057. somGetApplyStub : somMToken;
  1058. somFindSMethod : somMToken;
  1059. somFindSMethodOk : somMToken;
  1060. somGetMethodDescriptor : somMToken;
  1061. somGetNthMethodInfo : somMToken;
  1062. somSetClassData : somMToken;
  1063. somGetClassData : somMToken;
  1064. somNewNoInit : somMToken;
  1065. somRenewNoInit : somMToken;
  1066. somGetInstanceToken : somMToken;
  1067. somGetMemberToken : somMToken;
  1068. somSetMethodDescriptor : somMToken;
  1069. somGetMethodData : somMToken;
  1070. somOverrideMtab : somMToken;
  1071. somGetMethodToken : somMToken;
  1072. somGetParents : somMToken;
  1073. somGetPClsMtabs : somMToken;
  1074. somInitMIClass : somMToken;
  1075. somGetVersionNumbers : somMToken;
  1076. somLookupMethod : somMToken;
  1077. _get_somInstanceDataOffsets : somMToken;
  1078. somRenewNoZero : somMToken;
  1079. somRenewNoInitNoZero : somMToken;
  1080. somAllocate : somMToken;
  1081. somDeallocate : somMToken;
  1082. somGetRdStub : somMToken;
  1083. somGetNthMethodData : somMToken;
  1084. somcPrivate1 : somMToken;
  1085. somcPrivate2 : somMToken;
  1086. _get_somDirectInitClasses : somMToken;
  1087. _set_somDirectInitClasses : somMToken;
  1088. somGetInstanceInitMask : somMToken;
  1089. somGetInstanceDestructionMask : somMToken;
  1090. somcPrivate3 : somMToken;
  1091. somcPrivate4 : somMToken;
  1092. somcPrivate5 : somMToken;
  1093. somcPrivate6 : somMToken;
  1094. somcPrivate7 : somMToken;
  1095. somDefinedMethod : somMToken;
  1096. somcPrivate8 : somMToken;
  1097. somcPrivate9 : somMToken;
  1098. somcPrivate10 : somMToken;
  1099. somcPrivate11 : somMToken;
  1100. somcPrivate12 : somMToken;
  1101. somcPrivate13 : somMToken;
  1102. somcPrivate14 : somMToken;
  1103. somcPrivate15 : somMToken;
  1104. _get_somDataAlignment : somMToken;
  1105. somGetInstanceAssignmentMask : somMToken;
  1106. somcPrivate16 : somMToken;
  1107. somcPrivate17 : somMToken;
  1108. _get_somClassAllocate : somMToken;
  1109. _get_somClassDeallocate : somMToken;
  1110. end;
  1111. var
  1112. {$warning support of external vars required}
  1113. SOMClassClassData : SOMClassClassDataStructure;//³ 00003 ³ SOMClassClassData
  1114. {$warning support of external vars required}
  1115. SOMClassMgrCClassData : somCClassDataStructure;//³ 00005 ³ SOMClassMgrCClassData
  1116. type
  1117. SOMClassMgrClassDataStructure = record
  1118. classObject : SOMClassType;
  1119. somFindClsInFile : somMToken;
  1120. somFindClass : somMToken;
  1121. somClassFromId : somMToken;
  1122. somRegisterClass : somMToken;
  1123. somUnregisterClass : somMToken;
  1124. somLocateClassFile : somMToken;
  1125. somLoadClassFile : somMToken;
  1126. somUnloadClassFile : somMToken;
  1127. somGetInitFunction : somMToken;
  1128. somMergeInto : somMToken;
  1129. somGetRelatedClasses : somMToken;
  1130. somSubstituteClass : somMToken;
  1131. _get_somInterfaceRepository : somMToken;
  1132. _set_somInterfaceRepository : somMToken;
  1133. _get_somRegisteredClasses : somMToken;
  1134. somBeginPersistentClasses : somMToken;
  1135. somEndPersistentClasses : somMToken;
  1136. somcmPrivate1 : somMToken;
  1137. somcmPrivate2 : somMToken;
  1138. somRegisterClassLibrary : somMToken;
  1139. somJoinAffinityGroup : somMToken;
  1140. end;
  1141. var
  1142. {$warning support of external vars required}
  1143. SOMClassMgrClassData : SOMClassMgrClassDataStructure;//³ 00006 ³ SOMClassMgrClassData
  1144. type
  1145. SOMObjectCClassDataStructure = record
  1146. parentMtab :somMethodTabs;
  1147. instanceDataToken :somDToken;
  1148. end;
  1149. var
  1150. {$warning support of external vars required}
  1151. SOMObjectCClassData : SOMObjectCClassDataStructure;//³ 00013 ³ SOMObjectCClassData
  1152. type
  1153. SOMObjectClassDataStructure = record
  1154. classObject : SOMClassType;
  1155. somInit : somMToken;
  1156. somUninit : somMToken;
  1157. somFree : somMToken;
  1158. somDefaultVCopyInit : somMToken;
  1159. somGetClassName : somMToken;
  1160. somGetClass : somMToken;
  1161. somIsA : somMToken;
  1162. somRespondsTo : somMToken;
  1163. somIsInstanceOf : somMToken;
  1164. somGetSize : somMToken;
  1165. somDumpSelf : somMToken;
  1166. somDumpSelfInt : somMToken;
  1167. somPrintSelf : somMToken;
  1168. somDefaultConstVCopyInit : somMToken;
  1169. somDispatchV : somMToken;
  1170. somDispatchL : somMToken;
  1171. somDispatchA : somMToken;
  1172. somDispatchD : somMToken;
  1173. somDispatch : somMToken;
  1174. somClassDispatch : somMToken;
  1175. somCastObj : somMToken;
  1176. somResetObj : somMToken;
  1177. somDefaultInit : somMToken;
  1178. somDestruct : somMToken;
  1179. somPrivate1 : somMToken;
  1180. somPrivate2 : somMToken;
  1181. somDefaultCopyInit : somMToken;
  1182. somDefaultConstCopyInit : somMToken;
  1183. somDefaultAssign : somMToken;
  1184. somDefaultConstAssign : somMToken;
  1185. somDefaultVAssign : somMToken;
  1186. somDefaultConstVAssign : somMToken;
  1187. end;
  1188. var
  1189. {$warning support of external vars required}
  1190. SOMObjectClassData : SOMObjectClassDataStructure;//³ 00014 ³ SOMObjectClassData
  1191. (* Another not ported vars *)
  1192. // Control the printing of method and procedure entry messages,
  1193. // 0-none, 1-user, 2-core&user */
  1194. SOM_TraceLevel: Longint; //³ 00018 ³ SOM_TraceLevel
  1195. // Control the printing of warning messages, 0-none, 1-all
  1196. SOM_WarnLevel: Longint; //³ 00019 ³ SOM_WarnLevel
  1197. // Control the printing of successful assertions, 0-none, 1-user,
  1198. // 2-core&user
  1199. SOM_AssertLevel: Longint; //³ 00017 ³ SOM_AssertLevel
  1200. // ToDo: Move this to corresponding place
  1201. Procedure somCheckArgs(argc: longint; argv: array of pchar); cdecl;
  1202. external 'som' name 'somCheckArgs'; {index 25}
  1203. Procedure somUnregisterClassLibrary (libraryName: PChar); cdecl;
  1204. external 'som' name 'somUnregisterClassLibrary'; {index 89}
  1205. Function somResolveTerminal(x : SOMClassPtr; mdata: somMToken): somMethodProcPtr; cdecl;
  1206. external 'som' name 'somResolveTerminal'; {index 133}
  1207. Function somPCallResolve(obj: SOMObjectPtr; callingCls: SOMClassPtr; method: somMToken): somMethodProcPtr; cdecl;
  1208. external 'som' name 'somPCallResolve'; {index 362}
  1209. Implementation
  1210. Function exception_id(ev:Environment):PChar; cdecl;
  1211. begin
  1212. Result := somExceptionId(ev)
  1213. end;
  1214. Function exception_value(ev:Environment):Pointer; cdecl;
  1215. begin
  1216. Result := somExceptionValue(ev)
  1217. end;
  1218. Procedure exception_free(ev:Environment); cdecl;
  1219. begin
  1220. somExceptionFree(ev)
  1221. end;
  1222. Function SOM_CreateLocalEnvironment:Environment; cdecl;
  1223. begin
  1224. Result:=SOMCalloc(1, sizeof(EnvironmentType))
  1225. end;
  1226. Procedure SOM_DestroyLocalEnvironment(ev:Environment); cdecl;
  1227. begin
  1228. somExceptionFree(ev);
  1229. if somGetGlobalEnvironment<>ev then SOMFree(ev);
  1230. end;
  1231. Procedure SOM_InitEnvironment(ev:Environment); cdecl;
  1232. begin
  1233. if somGetGlobalEnvironment<>ev then FillChar(ev^,sizeof(EnvironmentType),0);
  1234. end;
  1235. Procedure SOM_UninitEnvironment(ev:Environment); cdecl;
  1236. begin
  1237. somExceptionFree(ev);
  1238. end;
  1239. End.
  1240. (* Don't know how to port ... thing
  1241. Function va_SOMObject_somDispatchA(SOMObject *somSelf,
  1242. somId methodId,
  1243. somId descriptor,
  1244. ...): Pointer; cdecl;
  1245. ³ 00064 ³ va_SOMObject_somDispatchA
  1246. double va_SOMObject_somDispatchD(SOMObject *somSelf,
  1247. somId methodId,
  1248. somId descriptor,
  1249. ...)
  1250. ³ 00065 ³ va_SOMObject_somDispatchD
  1251. long va_SOMObject_somDispatchL(SOMObject *somSelf,
  1252. somId methodId,
  1253. somId descriptor,
  1254. ...)
  1255. ³ 00066 ³ va_SOMObject_somDispatchL
  1256. void va_SOMObject_somDispatchV(SOMObject *somSelf,
  1257. somId methodId,
  1258. somId descriptor,
  1259. ...)
  1260. ³ 00067 ³ va_SOMObject_somDispatchV
  1261. boolean va_SOMObject_somDispatch(SOMObject *somSelf,
  1262. somToken* retValue,
  1263. somId methodId,
  1264. ...)
  1265. ³ 00068 ³ va_SOMObject_somDispatch
  1266. void* SOMLINK somva_SOMObject_somDispatchA(SOMObject *somSelf,
  1267. somId methodId,
  1268. somId descriptor,
  1269. ...)
  1270. ³ 00096 ³ somva_SOMObject_somDispatchA
  1271. double SOMLINK somva_SOMObject_somDispatchD(SOMObject *somSelf,
  1272. somId methodId,
  1273. somId descriptor,
  1274. ...)
  1275. ³ 00097 ³ somva_SOMObject_somDispatchD
  1276. long SOMLINK somva_SOMObject_somDispatchL(SOMObject *somSelf,
  1277. somId methodId,
  1278. somId descriptor,
  1279. ...)
  1280. ³ 00098 ³ somva_SOMObject_somDispatchL
  1281. void SOMLINK somva_SOMObject_somDispatchV(SOMObject *somSelf,
  1282. somId methodId,
  1283. somId descriptor,
  1284. ...)
  1285. ³ 00099 ³ somva_SOMObject_somDispatchV
  1286. boolean SOMLINK somva_SOMObject_somDispatch(SOMObject *somSelf,
  1287. somToken* retValue,
  1288. somId methodId,
  1289. ...)
  1290. ³ 00100 ³ somva_SOMObject_somDispatch
  1291. boolean SOMLINK somva_SOMObject_somClassDispatch(SOMObject *somSelf,
  1292. SOMClass* clsObj,
  1293. somToken* retValue,
  1294. somId methodId,
  1295. ...)
  1296. ³ 00101 ³ somva_SOMObject_somClassDispatch
  1297. *)
  1298. (*
  1299. ³ 00038 ³ somSaveMetrics // not found
  1300. ³ 00046 ³ somWriteMetrics // not found
  1301. ³ 00051 ³ somCreateDynamicClass // not found
  1302. ³ 00056 ³ SOM_IdTable // not found
  1303. ³ 00057 ³ SOM_IdTableSize // not found
  1304. ³ 00062 ³ somStartCriticalSection // not found
  1305. ³ 00063 ³ somEndCriticalSection // not found
  1306. ³ 00080 ³ somfixMsgTemplate // not found
  1307. ³ 00087 ³ SOMParentDerivedMetaclassClassData // not found
  1308. ³ 00132 ³ somFreeThreadData // not found
  1309. ³ 00135 ³ somIdMarshal // not found
  1310. ³ 00361 ³ somMakeUserRdStub // Not found
  1311. *)
  1312. {
  1313. $Log$
  1314. Revision 1.2 2003-11-30 08:13:14 yuri
  1315. * more ported functions
  1316. Revision 1.1 2003/09/22 13:52:59 yuri
  1317. + Initial import. Mostly backup.
  1318. }