home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v5.zip / TOOLKT21 / C / OS2H / SOMCDEV.H < prev    next >
C/C++ Source or Header  |  1993-03-12  |  6KB  |  204 lines

  1. /*
  2.  *    SOMCDEV.H
  3.  *    System Object Model development support for ANSI C
  4.  *
  5.  *    Copyright (c) International Business Machines Corporation
  6.  *                  1991, 1992
  7.  *
  8.  *    @(#)somcdev.h 1.23 1/30/92 16:53:06 [1/30/92] (c)IBM Corp. 1992
  9.  */
  10.  
  11. #ifndef somcdev_h
  12. #define somcdev_h
  13.  
  14. /*
  15.  *    Class data used in the C object model
  16.  */
  17.  
  18. typedef struct {
  19.     somMethodTab *parentMtab;
  20.     integer4 instanceDataOffset;
  21.     somMethodProc *wrappers[1];
  22. } somCClassDataStructure;
  23.  
  24. /*
  25.  *  Resolution macros
  26.  */
  27.  
  28. #ifdef SOM_CPP1 /* Some C compilers prefer this form */
  29.  
  30.   #define SOM_Resolve(obj, cn, mn) \
  31.     (( somTD_ ## cn ## _ ## mn ) \
  32.     somResolve(SOM_TestCls(obj, cn ## ClassData.classObject), \
  33.     cn ## ClassData.mn ))
  34.  
  35.   #define SOM_ResolveNoCheck(obj, cn, mn) \
  36.     (( somTD_ ## cn ## _ ## mn ) \
  37.     somResolve(obj, cn ## ClassData.mn ))
  38.  
  39.   #define SOM_ParentResolve(pcn, cn, mn) \
  40.     (( somTD_ ## pcn ## _ ## mn ) \
  41.     somParentResolve( cn ## CClassData.parentMtab, \
  42.     pcn ## ClassData.mn ))
  43.  
  44.   /* Next form provided for emitter usage */
  45.   #define SOM_ParentResolveE(pcn, cpmt, mn) \
  46.     (( somTD_ ## pcn ## _ ## mn ) \
  47.     somParentResolve( cpmt, \
  48.     pcn ## ClassData.mn ))
  49.  
  50. #else /* ANSI conforming form */
  51.  
  52.   #define SOM_Resolve(obj, cn, mn) \
  53.     (( somTD_ ## cn ## _ ## mn ) \
  54.     somResolve(SOM_TestCls(obj, cn ## ClassData.classObject), \
  55.     cn ## ClassData ## . ## mn ))
  56.  
  57.   #define SOM_ResolveNoCheck(obj, cn, mn) \
  58.     (( somTD_ ## cn ## _ ## mn ) \
  59.     somResolve(obj, cn ## ClassData ## . ## mn ))
  60.  
  61.   #define SOM_ParentResolve(pcn, cn, mn) \
  62.     (( somTD_ ## pcn ## _ ## mn ) \
  63.     somParentResolve( cn ## CClassData.parentMtab, \
  64.     pcn ## ClassData ## . ## mn ))
  65.  
  66.   /* Next form provided for emitter usage */
  67.   #define SOM_ParentResolveE(pcn, cpmt, mn) \
  68.     (( somTD_ ## pcn ## _ ## mn ) \
  69.     somParentResolve( cpmt, pcn ## ClassData ## . ## mn ))
  70.  
  71. #endif  /* _SOM_CPP1 */
  72.  
  73.  
  74. #define SOM_DataResolve(obj, dataId) \
  75.   (somDataResolve(obj, dataId))
  76.  
  77. /*  -------------------------------------------------------------------
  78.  *  The following macros are for purposes of backward compatibility
  79.  *  with prior versions of SOM.  There is no advantage to using them
  80.  *  over a direct call to the corresponding routine.
  81.  */
  82.  
  83. #define SOM_CompareValidIds(id1,id2) (somCompareIds(id1,id2))
  84.  
  85. #define SOM_CompareIds(id1,id2) (somCompareIds(id1,id2))
  86.  
  87. #define SOM_StringFromId(id) (somStringFromId(id))
  88.  
  89. #define SOM_IdFromString(str) (somIdFromString(str))
  90.  
  91. #define SOM_CheckId(id) (somCheckId(id))
  92.  
  93. /*
  94.  * Macro to get class object
  95.  */
  96. #define SOM_GetClass(obj) ((obj->mtab)->classObject)
  97.  
  98. /*
  99.  *   Development support macros and globals
  100.  */
  101.  
  102. /* Check the validity of method resolution using the specified target  */
  103. /* object.  Note: this macro makes programs bigger and slower.  After  */
  104. /* you are confident that your program is running correctly you should */
  105. /* turn off this macro by defining SOM_NoTest, or adding -DSOM_NoTest  */
  106. /* to your makefile.                                                   */
  107.  
  108. #ifndef SOM_NoTest
  109. #define SOM_TestCls(obj, class) (somTestCls(obj, class, __FILE__, __LINE__))
  110. #define SOM_Measure
  111. #else
  112. #define SOM_TestCls(obj, class) (obj)
  113. #endif
  114.  
  115. /* Control the printing of method and procedure entry messages, */
  116. /* 0-none, 1-user, 2-core&user */
  117. SOMEXTERN int SOM_TraceLevel;
  118.  
  119. /* Control the printing of warning messages, 0-none, 1-all */
  120. SOMEXTERN int SOM_WarnLevel;
  121.  
  122. /* Control the printing of successful assertions, 0-none, 1-user, */
  123. /* 2-core&user */
  124. SOMEXTERN int SOM_AssertLevel;
  125.  
  126. /*
  127.  *  Scans argv looking for flags -somt, -somtc, -soma -somac -somw setting
  128.  *  SOM_TraceLevel, SOM_AssertLevel and SOM_WarnLevel as appropriate.
  129.  *  argv is not modified
  130.  */
  131. #ifdef __IBMC__
  132.   #pragma linkage(somCheckArgs, system)
  133. #endif
  134. SOMEXTERN void SOMLINK somCheckArgs(int argc, zString argv[]);
  135.  
  136. #define SOM_Error(c) ((*SOMError) (c,__FILE__, __LINE__))
  137.  
  138. #define SOM_NoTrace(c,m)
  139.  
  140. #ifdef _RETAIL
  141.   #define SOM_Trace(c,m)
  142.   #define SOM_TraceCore(c,m)
  143. #else
  144.   #define SOM_Trace(c,m) if (SOM_TraceLevel > 0) \
  145.       somPrintf("\"%s\": %d:\tIn %s:%s \n", \
  146.           __FILE__, __LINE__, c, m)
  147.  
  148.   #define SOM_TraceCore(c,m) if (SOM_TraceLevel > 1) \
  149.       somPrintf("\"%s\": %d:\tIn %s:%s \n", \
  150.           __FILE__, __LINE__, c, m)
  151. #endif
  152.  
  153. #define SOM_Assert(condition,ecode) \
  154.   (somAssert(condition, ecode, __FILE__, __LINE__, # condition))
  155.  
  156. #define SOM_AssertCore(condition,ecode) \
  157.   (somAssertCore(condition, ecode, __FILE__, __LINE__, # condition))
  158.  
  159. #define SOM_Expect(condition) \
  160.       somTest(condition, SOM_Warn, __FILE__, __LINE__, # condition)
  161.  
  162. #define SOM_WarnMsg(msg) \
  163.   if (SOM_WarnLevel > 0) \
  164.       somPrintf("\"%s\": %d:\tWarning: %s\n", __FILE__, __LINE__, msg)
  165.  
  166. #define SOM_Test(boolexp) \
  167.     somTest(boolexp, SOM_Fatal, __FILE__, __LINE__, # boolexp)
  168.  
  169. #define SOM_TestC(boolexp) \
  170.     somTest(boolexp, SOM_Warn, __FILE__, __LINE__, # boolexp)
  171.  
  172. /*
  173.  *   Default method debug macro, can be overridden
  174.  */
  175. #ifndef SOMMethodDebug
  176. #define SOMMethodDebug(c,m) SOM_Trace(c,m)
  177. #endif
  178.  
  179. /*--------------------------------------------------------------------
  180.  *  Error severity codes, these are added to the base error number to
  181.  *  produce the full error code
  182.  */
  183.  
  184. #define SOM_Ok        0x0
  185. #define SOM_Warn      0x1
  186.  
  187. /* don't do anything */
  188. #define SOM_Ignore    0x2
  189.  
  190. /* terminate the program */
  191. #define SOM_Fatal     0x9
  192.  
  193. /* use to identify msg templates */
  194. #define SOM_Template  0x5
  195.  
  196. #define SOM_FatalCode(code) (SOM_EB + (code)*10 + SOM_Fatal)
  197. #define SOM_WarnCode(code) (SOM_EB + (code)*10 + SOM_Warn)
  198. #define SOM_IgnoreCode(code) (SOM_EB + (code)*10 + SOM_Ignore)
  199. #define SOM_OkCode(code) (SOM_EB + (code)*10 + SOM_Ok)
  200. #define SOM_TemplateCode(code) (SOM_EB + (code)*10 + SOM_Template)
  201.  
  202.  
  203. #endif /* somcdev_h */
  204.