2
0

som.pas 60 KB

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