som.pas 60 KB

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