source: trunk/Lucide/SOURCE/sominc/somcdev.h @ 88

Last change on this file since 88 was 88, checked in by Eugene Romanenko, 15 years ago

UI improvements, save files, ability to compile plugins with gcc, saveAs for djvu plugin, djvu plugin compiled with gcc, get rid of ddjvuapi.dll

File size: 9.4 KB
Line 
1/*
2 *   COMPONENT_NAME: somk
3 *
4 *   ORIGINS: 27
5 *
6 *
7 *    25H7912  (C)  COPYRIGHT International Business Machines Corp. 1992,1994,1996
8 *   All Rights Reserved
9 *   Licensed Materials - Property of IBM
10 *   US Government Users Restricted Rights - Use, duplication or
11 *   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
12 */
13/* @(#) 2.22.1.2 src/somk/somcdev.h, somk.api, som2.1 1/3/96 11:26:42 [7/30/96 14:46:36] */
14
15/*
16 */
17
18/*
19 *    SOMCDEV.H
20 *    System Object Model development support for ANSI C
21 *    Multiple Inheritance Version
22 */
23
24#ifndef somcdev_h
25#define somcdev_h
26
27#include <somtypes.h>
28#if !defined(__SOMDLL__)
29  #include <stdlib.h>  /* needed for atexit, used below */
30#endif /* __SOMDLL__ */
31
32
33/*
34 *  Method and Data Resolution macros
35 */
36
37/*
38 *  Method Resolution. Methods are invoked on an object o of some
39 *  object class oc, where oc has immediate ancestor classes
40 *  called parent classes. Macro arguments include method names
41 *  (e.g., mn), object class and parent class names (e.g., ocn, pcn)
42 *  and parent class positions (e.g., pcp), expressed in terms of the
43 *  left-to-right ordering (beginning with 1, for the first parent)
44 *  used when declaring oc's parents. The choice of resolution
45 *  macro determines the method table from which methods are selected.
46 *
47 *  Macros are available to select a method from ...
48 */
49
50/*
51 * Default definition of somresolve_ to call the procedure, somResolve.
52 * This may be be changed by emitters on systems for which method
53 * tokens are thunks.
54 */
55#define somresolve_(obj,mToken) (somResolve(obj,mToken))
56
57/* from oc's mtbl, with verification of o */
58#define SOM_Resolve(o, ocn, mn) \
59    (( somTD_ ## ocn ## _ ## mn ) \
60     somresolve_(SOM_TestCls(o, ocn ## ClassData.classObject), \
61                ocn ## ClassData.mn ))
62
63/* from oc's mtbl, without verification of o */
64#define SOM_ResolveNoCheck(o, ocn, mn) \
65    (( somTD_ ## ocn ## _ ## mn ) \
66     somresolve_(o, \
67                ocn ## ClassData.mn ))
68
69/* from the pcp'th element of oc's CClassData.parentMtab list */
70#define SOM_ParentNumResolveCC(pcn, pcp, ocn, mn) \
71    (( somTD_ ## pcn ## _ ## mn ) \
72     somParentNumResolve( ocn ## CClassData.parentMtab, pcp, \
73                         pcn ## ClassData.mn ))
74
75/* from the pcp'th element of an argument mtab list */
76#define SOM_ParentNumResolve(pcn, pcp, mtabs, mn) \
77    (( somTD_ ## pcn ## _ ## mn ) \
78     somParentNumResolve(mtabs, pcp, \
79                         pcn ## ClassData.mn ))
80
81/* from an argument class's method table */
82#define SOM_ClassResolve(cn, class, mn) \
83    (( somTD_ ## cn ## _ ## mn ) \
84     somClassResolve(class, \
85                     cn ## ClassData.mn ))
86
87
88/* support reintroduction of methods */
89/* tdc == typedef class name; cdc == classdata class name */
90#define SOM_ResolveD(o, tdc, cdc, mn) \
91        (( somTD_ ## tdc ## _ ## mn ) \
92          somresolve_(SOM_TestCls(o, cdc ## ClassData.classObject),\
93                     cdc ## ClassData.mn))
94
95
96/* from the first mtbl in an argument mtbl list ...
97
98  This macro is here primarily to document the behavior
99  of previously-compiled single inheritance code that used
100  the macro of this name. The behavior is that of using
101  SOM_ParentNumResolve with a pcp of 1.
102*/
103#define SOM_ParentResolveE(pcn, mtbls, mn) \
104    (( somTD_ ## pcn ## _ ## mn ) \
105     somParentResolve(mtbls, \
106                      pcn ## ClassData.mn ))
107
108
109
110/*
111 * Data resolution macro
112 */
113
114#define SOM_DataResolve(obj, dataId) \
115  (somDataResolve(obj, dataId))
116
117
118/*  -------------------------------------------------------------------
119 *  The following macros are for purposes of backward compatibility
120 *  with prior versions of SOM.  There is no advantage to using them
121 *  over a direct call to the corresponding routine.
122 */
123
124#define SOM_CompareValidIds(id1,id2) (somCompareIds(id1,id2))
125
126#define SOM_CompareIds(id1,id2) (somCompareIds(id1,id2))
127
128#define SOM_StringFromId(id) (somStringFromId(id))
129
130#define SOM_IdFromString(str) (somIdFromString(str))
131
132#define SOM_CheckId(id) (somCheckId(id))
133
134/*
135 * Convenience macro for somSubstituteClass method.
136 */
137#ifdef __cplusplus     
138#define SOM_SubstituteClass(old,new) \
139    (old##NewClass(old##_MajorVersion, old##_MinorVersion),\
140     new##NewClass(new##_MajorVersion, new##_MinorVersion),\
141         SOMClassMgrObject->somSubstituteClass(_##old->somGetName(),\
142                                               _##new->somGetName()))
143
144
145#else
146#define SOM_SubstituteClass(old,new) \
147    (old##NewClass(old##_MajorVersion, old##_MinorVersion),\
148     new##NewClass(new##_MajorVersion, new##_MinorVersion),\
149     _somSubstituteClass(SOMClassMgrObject,\
150                         _somGetName(_##old),\
151                         _somGetName(_##new)))
152#endif
153
154
155#if !defined(__SOMDLL__)
156
157  /*
158   * Main programs should register for SOM cleanup at exit
159   */
160
161   #define SOM_MainProgram()\
162    (atexit(somEnvironmentEnd), somMainProgram())
163
164  /*
165   * somEnvironmentEnd may not have the right
166   * linkage to be called by atexit. Allow a user to
167   * create a routine that can be called by atexit
168   * and which will call somEnvironmentEnd.
169   */
170
171   #define SOM_MainProgramWithUserExit( userExitFcn ) \
172    (atexit( userExitFcn ), somMainProgram())
173
174#endif /* __SOMDLL__ */
175
176/*
177 * Platform provided automatic class library initialization rtns
178 * should use this macro to inform the SOM Class Manager that
179 * they have been loaded.
180 */
181#define SOM_ClassLibrary(name)\
182    (somRegisterClassLibrary(name,\
183        (somMethodProc *) &SOMInitModule))
184
185
186/*
187 *   Development support macros and globals
188 */
189
190#ifdef SOM_STRICT_IDL
191#define SOMSTAR
192#else
193#define SOMSTAR *
194#endif
195
196/*
197 * Macro to get class object
198 */
199#define SOM_GetClass(obj) (**(SOMClass SOMSTAR **)obj)
200
201/*
202 * This macro is used throughout the generated source
203 * to prevent compiler warnings for unreferenced variables
204 */
205#ifndef SOM_IgnoreWarning
206    #ifdef __xlC__
207        #define SOM_IgnoreWarning(v)   
208    #else
209        #define SOM_IgnoreWarning(v)    (void) v
210    #endif
211#endif /* SOM_IgnoreWarning */
212
213/* Check the validity of method resolution using the specified target  */
214/* object.  Note: this macro makes programs bigger and slower.  After  */
215/* you are confident that your program is running correctly you should */
216/* turn off this macro by defining SOM_NoTest, or adding -DSOM_NoTest  */
217/* to your makefile.                                                   */
218
219#if !defined(SOM_NoTest) && defined(SOM_TestOn)
220  #define SOM_TestCls(obj, class) (somTestCls(((SOMObject SOMSTAR)\
221    ((void *)obj)), ((SOMClass SOMSTAR)((void *)class)), __FILE__, __LINE__))
222  #define SOM_Measure
223#else
224  #define SOM_TestCls(obj, class) ((SOMObject SOMSTAR)((void *)obj))
225#endif
226
227/* Control the printing of method and procedure entry messages, */
228/* 0-none, 1-user, 2-core&user */
229SOMEXTERN int SOMDLINK SOM_TraceLevel;
230
231/* Control the printing of warning messages, 0-none, 1-all */
232SOMEXTERN int SOMDLINK SOM_WarnLevel;
233
234/* Control the printing of successful assertions, 0-none, 1-user, */
235/* 2-core&user */
236SOMEXTERN int SOMDLINK SOM_AssertLevel;
237
238/*
239 *  Scans argv looking for flags -somt, -somtc, -soma -somac -somw setting
240 *  SOM_TraceLevel, SOM_AssertLevel and SOM_WarnLevel as appropriate.
241 *  argv is not modified
242 */
243#ifdef __IBMC__
244  #pragma linkage(somCheckArgs, system)
245#endif
246SOMEXTERN void SOMLINK somCheckArgs(int argc, zString argv[]);
247
248#define SOM_Error(c) ((*SOMError) (c,__FILE__, __LINE__))
249
250#define SOM_NoTrace(c,m)
251
252#ifdef _RETAIL
253  #define SOM_Trace(c,m)
254  #define SOM_TraceCore(c,m)
255#else
256  #define SOM_Trace(c,m) if (SOM_TraceLevel > 0) \
257      somPrintf("\"%s\": %d:\tIn %s:%s \n", \
258          __FILE__, __LINE__, c, m)
259
260  #define SOM_TraceCore(c,m) if (SOM_TraceLevel > 1) \
261      somPrintf("\"%s\": %d:\tIn %s:%s \n", \
262          __FILE__, __LINE__, c, m)
263#endif
264
265#define SOM_Assert(condition,ecode) \
266  (somAssert(condition, ecode, __FILE__, __LINE__, # condition))
267
268#define SOM_AssertCore(condition,ecode) \
269  (somAssertCore(condition, ecode, __FILE__, __LINE__, # condition))
270
271#define SOM_Expect(condition) \
272      somTest(condition, SOM_Warn, __FILE__, __LINE__, # condition)
273
274#define SOM_WarnMsg(msg) \
275  if (SOM_WarnLevel > 0) \
276      somPrintf("\"%s\": %d:\tWarning: %s\n", __FILE__, __LINE__, msg)
277
278#define SOM_Test(boolexp) \
279    somTest(boolexp, SOM_Fatal, __FILE__, __LINE__, # boolexp)
280
281#define SOM_TestC(boolexp) \
282    somTest(boolexp, SOM_Warn, __FILE__, __LINE__, # boolexp)
283
284/*
285 *   Default method debug macro, can be overridden
286 */
287#ifndef SOMMethodDebug
288#define SOMMethodDebug(c,m) SOM_Trace(c,m)
289#endif
290
291/*
292 *  Error severity codes, these are added to the base error number to
293 *  produce the full error code
294 */
295
296#define SOM_Ok        0x0
297#define SOM_Warn      0x1
298#define SOM_Ignore    0x2 /* don't do anything */
299#define SOM_Fatal     0x9 /* terminate the program */
300#define SOM_Template  0x5 /* use to identify msg templates */
301
302#define SOM_EB 20000
303#define SOM_FatalCode(code) (SOM_EB + (code)*10 + SOM_Fatal)
304#define SOM_WarnCode(code) (SOM_EB + (code)*10 + SOM_Warn)
305#define SOM_IgnoreCode(code) (SOM_EB + (code)*10 + SOM_Ignore)
306#define SOM_OkCode(code) (SOM_EB + (code)*10 + SOM_Ok)
307#define SOM_TemplateCode(code) (SOM_EB + (code)*10 + SOM_Template)
308#define SOM_MsgCode(ecode) (((ecode)-SOM_EB)/10)
309
310#define SOMERROR_MustOverride SOM_FatalCode(18)
311
312#endif /* somcdev_h */
Note: See TracBrowser for help on using the repository browser.