home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / devtools / toolkt21 / cplus / os2h / som.xh < prev    next >
Encoding:
Text File  |  1993-04-30  |  8.6 KB  |  244 lines

  1. /*
  2.  *    SOM.XH
  3.  *    First level include file for System Object Model
  4.  *
  5.  *    Copyright (c) International Business Machines Corporation
  6.  *            1991, 1992
  7.  *
  8.  *    @(#)som.xh 1.1 5/13/92 12:55:15 [5/14/92] (c)IBM Corp. 1992
  9.  */
  10.  
  11. #ifndef som_h
  12. #define som_h
  13.  
  14. #include <somnames.h>
  15.  
  16. #ifdef __cplusplus
  17. #define SOMEXTERN extern "C"
  18. #else
  19. #define SOMEXTERN extern
  20. #endif
  21.  
  22. #ifndef SOMLINK
  23.   #define SOMLINK _System
  24. #endif
  25.  
  26.  
  27.  
  28. #include <stdarg.h>
  29. #include <stddef.h>
  30. #include <somtypes.xh>
  31. #include <somerr.h>
  32. #include <somcdev.h>
  33.  
  34. /* Declare Global class manager object */
  35. SOMEXTERN SOMClassMgr *SOMClassMgrObject;
  36.  
  37. /*----------------------------------------------------------------------
  38.  *  Typedefs for pointers to functions
  39.  */
  40.  
  41. typedef void    SOMLINK somTD_classInitRoutine(SOMClass *, SOMClass *);
  42. typedef int    SOMLINK somTD_SOMOutCharRoutine(char);
  43. typedef int    SOMLINK somTD_SOMLoadModule(IN zString /* className */,
  44.                     IN zString     /* fileName */,
  45.                     IN zString     /* functionName */,
  46.                     IN integer4    /* majorVersion */,
  47.                     IN integer4    /* minorVersion */,
  48.                     OUT somToken * /* modHandle */);
  49. typedef int    SOMLINK somTD_SOMDeleteModule(IN somToken /* modHandle */);
  50. typedef zString SOMLINK somTD_SOMClassInitFuncName(void);
  51. typedef void *    SOMLINK somTD_SOMMalloc(IN size_t /* nbytes */);
  52. typedef void *    SOMLINK somTD_SOMCalloc(IN size_t /* element_count */,
  53.                     IN size_t /* element_size */);
  54. typedef void *    SOMLINK somTD_SOMRealloc(IN void * /* memory */,
  55.                      IN size_t /* nbytes */);
  56. typedef void    SOMLINK somTD_SOMFree(IN void * /* memory */);
  57. typedef void    SOMLINK somTD_SOMError(IN int       /* code */,
  58.                        IN zString  /* fileName */,
  59.                        IN int       /* lineNum */);
  60.  
  61. /*----------------------------------------------------------------------
  62.  *  Misc. procedures:
  63.  */
  64.  
  65. /*
  66.  *  Create and initialize the SOM environment
  67.  *
  68.  *  Can be called repeatedly
  69.  *
  70.  *  Will be called automatically when first object (including a class
  71.  *  object) is created, if it has not already been done.
  72.  *
  73.  *  Returns the SOMClassMgrObject
  74.  */
  75.  
  76. SOMEXTERN SOMClassMgr * SOMLINK somEnvironmentNew (void);
  77.  
  78. /*----------------------------------------------------------------------
  79.  *  String Manager: stem <somsm>
  80.  */
  81. SOMEXTERN somId SOMLINK somCheckId (somId id);
  82. /* makes sure that the id is registered and in normal form, returns */
  83. /* the id */
  84.  
  85. SOMEXTERN int SOMLINK somRegisterId(somId id);
  86. /* Same as somCheckId except returns 1 (true) if this is the first */
  87. /* time the string associated with this id has been registered, */
  88. /* returns 0 (false) otherwise */
  89.  
  90. SOMEXTERN somId SOMLINK somIdFromString (zString aString);
  91.  
  92. SOMEXTERN zString SOMLINK somStringFromId (somId id);
  93.  
  94. SOMEXTERN int SOMLINK somCompareIds(somId id1, somId id2);
  95.  
  96. SOMEXTERN unsigned long SOMLINK somTotalRegIds(void);
  97. /* Returns the total number of ids that have been registered so far, */
  98. /* you can use this to advise the SOM runtime concerning expected */
  99. /* number of ids in later executions of your program, via a call to */
  100. /* somSetExpectedIds defined below */
  101.  
  102. SOMEXTERN void SOMLINK somSetExpectedIds(unsigned long numIds);
  103. /* Tells the SOM runtime how many unique ids you expect to use during */
  104. /* the execution of your program, this can improve space and time */
  105. /* utilization slightly, this routine must be called before the SOM */
  106. /* environment is created to have any effect */
  107.  
  108. SOMEXTERN unsigned long SOMLINK somUniqueKey(somId id);
  109. /* Returns the unique key for this id, this key will be the same as the */
  110. /* key in another id if and only if the other id refers to the same */
  111. /* name as this one */
  112.  
  113. SOMEXTERN void SOMLINK somBeginPersistentIds(void);
  114. /* Tells the id manager that strings for any new ids that are */
  115. /* registered will never be freed or otherwise modified. This allows */
  116. /* the id manager to just use a pointer to the string in the */
  117. /* unregistered id as the master copy of the ids string. Thus saving */
  118. /* space */
  119. /* Under normal use (where ids are static varibles) the string */
  120. /* associated with an id would only be freed if the code module in */
  121. /* which it occured was unloaded */
  122.  
  123. SOMEXTERN void SOMLINK somEndPersistentIds(void);
  124. /* Tells the id manager that strings for any new ids that are */
  125. /* registered may be freed or otherwise modified.  Therefore the id */
  126. /* manager must copy the strings inorder to remember the name of an */
  127. /* id. */
  128.  
  129. /*---------------------------------------------------------------------
  130.  *  Basic offset based method resolution, this is used in every method
  131.  *  class that uses offset resolution
  132.  *  It returns the appropriate method procedure for the method
  133.  *  identified by <mdata>, Mdata id the 32 bit value stored in the
  134.  *  class data structure in the entry with the methods name. I.e., if
  135.  *  a object, obj, of class, Foo, has a method, bar, then:
  136.  *    somResolve(obj, FooClassData.bar)
  137.  *  will return the appropriate method procedure for bar.
  138.  *  The way that <mdata> identifies a method and the algorithm used by
  139.  *  somResolve to locate the appropriate method procedure is not part
  140.  *  of the visible SOM architecture and is subject to change in
  141.  *  subsequent releases.
  142.  */
  143. SOMEXTERN somMethodProc * SOMLINK somResolve(SOMAny *obj, somMToken mdata);
  144. SOMEXTERN somMethodProc * SOMLINK somParentResolve(somMethodTab *parentMtab,
  145.                      somMToken mdata);
  146. SOMEXTERN void * SOMLINK somDataResolve(SOMAny *obj, somDToken dataId);
  147.  
  148. /*---------------------------------------------------------------------
  149.  *  Used to make class object creation an atomic operation, this is
  150.  *  called by the generated <class name>NewClass routine.  You should
  151.  *  never call this routine directly.
  152.  */
  153. typedef struct {
  154.     SOMClass *classObject;
  155. } somClassDataStructure;
  156.  
  157. SOMEXTERN void SOMLINK somConstructClass (
  158.             somTD_classInitRoutine classInitRoutine,
  159.             SOMClass *parentClass,
  160.             SOMClass *metaClass,
  161.             somClassDataStructure *cds);
  162.  
  163. /*---------------------------------------------------------------------
  164.  *  Generic apply function
  165.  */
  166. SOMEXTERN void SOMLINK somGenericApply (SOMAny *obj,
  167.        somId methodID,
  168.        somId methodDescriptor,
  169.        va_list ap);
  170.  
  171. /*
  172.  * Convenience function to obtain the class object for a given object
  173.  */
  174. #ifndef SOMObject_Class_Source
  175. SOMEXTERN SOMClass * SOMLINK somGetClass (SOMAny *self);
  176. #endif
  177.  
  178. /*
  179.  * Uses <SOMOutCharRoutine> to output its arguments under control of the ANSI C
  180.  * style format.  Returns the number of characters output.
  181.  */
  182. SOMEXTERN int SOMLINK somPrintf (zString fmt, ...);
  183. /*
  184.  * vprint form of somPrintf
  185.  */
  186. SOMEXTERN int SOMLINK somVprintf (zString fmt, va_list ap);
  187. /*
  188.  * Outputs (via somPrintf) blanks to prefix a line at the indicated level
  189.  */
  190. SOMEXTERN void SOMLINK somPrefixLevel (int level);
  191. /*
  192.  * Combines somPrefixLevel and somPrintf
  193.  */
  194. SOMEXTERN int SOMLINK somLPrintf (int level, zString fmt, ...);
  195.  
  196. /*
  197.  *  Replaceable character output handler.
  198.  *  Points to the character output routine to be used in development
  199.  *  support.  Initialized to <somOutChar>, but may be reset at anytime.
  200.  *  Should return 0 (false) if an error occurs and 1 (true) otherwise.
  201.  */
  202.  
  203. SOMEXTERN somTD_SOMOutCharRoutine *SOMOutCharRoutine;
  204.  
  205. /*----------------------------------------------------------------------
  206.  * Pointers to routines used to do dynamic code loading and deleting
  207.  */
  208.  
  209. SOMEXTERN somTD_SOMLoadModule      *SOMLoadModule;
  210. SOMEXTERN somTD_SOMDeleteModule   *SOMDeleteModule;
  211. SOMEXTERN somTD_SOMClassInitFuncName *SOMClassInitFuncName;
  212.  
  213. /*----------------------------------------------------------------------
  214.  *  Replaceable SOM Memory Management Interface
  215.  *
  216.  *  External procedure variables SOMCalloc, SOMFree, SOMMalloc, SOMRealloc
  217.  *  have the same interface as their standard C-library analogs.
  218.  */
  219.  
  220. SOMEXTERN somTD_SOMCalloc    *SOMCalloc;
  221. SOMEXTERN somTD_SOMFree *SOMFree;
  222. SOMEXTERN somTD_SOMMalloc    *SOMMalloc;
  223. SOMEXTERN somTD_SOMRealloc *SOMRealloc;
  224.  
  225. /*----------------------------------------------------------------------
  226.  *  Replaceable SOM Error handler
  227.  */
  228.  
  229. SOMEXTERN somTD_SOMError *SOMError;
  230.  
  231. /*----------------------------------------------------------------------
  232.  * Externals used in the implementation of SOM, but not part of the
  233.  * SOM API.
  234.  */
  235.  
  236. SOMEXTERN SOMAny * SOMLINK somTestCls(SOMAny *obj, SOMClass *classObj,
  237.                    zString fileName, int lineNumber);
  238. SOMEXTERN void SOMLINK somTest(int condition, int severity, zString fileName,
  239.                 int lineNum, zString msg);
  240. SOMEXTERN void SOMLINK somAssert(int condition, int ecode,
  241.                  zString fileName, int lineNum, zString msg);
  242.  
  243. #endif
  244.