source: trunk/nom/include/nomapi.h@ 251

Last change on this file since 251 was 251, checked in by cinc, 18 years ago

Implemented some methods. Bug fixes and documentation.

File size: 8.4 KB
Line 
1/* ***** BEGIN LICENSE BLOCK *****
2* Version: CDDL 1.0/LGPL 2.1
3*
4* The contents of this file are subject to the COMMON DEVELOPMENT AND
5* DISTRIBUTION LICENSE (CDDL) Version 1.0 (the "License"); you may not use
6* this file except in compliance with the License. You may obtain a copy of
7* the License at http://www.sun.com/cddl/
8*
9* Software distributed under the License is distributed on an "AS IS" basis,
10* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11* for the specific language governing rights and limitations under the
12* License.
13*
14* The Original Code is "NOM" Netlabs Object Model
15*
16* The Initial Developer of the Original Code is
17* netlabs.org: Chris Wohlgemuth <cinc-ml@netlabs.org>.
18* Portions created by the Initial Developer are Copyright (C) 2005-2007
19* the Initial Developer. All Rights Reserved.
20*
21* Contributor(s):
22*
23* Alternatively, the contents of this file may be used under the terms of
24* the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
25* case the provisions of the LGPL are applicable instead of those above. If
26* you wish to allow use of your version of this file only under the terms of
27* the LGPL, and not to allow others to use your version of this file under
28* the terms of the CDDL, indicate your decision by deleting the provisions
29* above and replace them with the notice and other provisions required by the
30* LGPL. If you do not delete the provisions above, a recipient may use your
31* version of this file under the terms of any one of the CDDL or the LGPL.
32*
33* ***** END LICENSE BLOCK ***** */
34
35#ifndef NOMAPI_H_INCLUDED
36#define NOMAPI_H_INCLUDED
37
38/* Method and data Tokens. */
39typedef nomToken nomMToken;
40typedef nomToken nomDToken;
41
42
43#ifndef NOM_CLASSINFO_DEFINED
44#define NOM_CLASSINFO_DEFINED
45typedef nomToken nomClassInfo;
46#endif
47
48typedef struct nomMethodTabStruct {
49 NOMClass *nomClassObject; /* Pointer to the class object */
50 nomClassInfo *nomClsInfo; /* Pointer to NOMClassPriv. That struct holds
51 thunking code and extended info. */
52 char *nomClassName; /* Pointer to this class' name */
53 gulong ulInstanceSize; /* Size of an instance of this class */
54 gulong mtabSize; /* Size of this mtab (includes method ptrs.) */
55 nomMethodProc* entries[1];
56} nomMethodTab, *nomMethodTabPtr;
57
58typedef struct nomMethodTabList {
59 nomMethodTab *mtab;
60 struct nomMethodTabList *next;
61} nomMethodTabList, *nomMethodTabs;
62
63typedef struct {
64 nomMethodTab *mtab; /* This class' mtab */
65 nomMethodTabs next; /* The parent mtabs */
66 NOMClass *nomClassObject;
67 gulong ulInstanceSize;
68} nomParentMtabStruct, *nomParentMtabStructPtr;
69
70typedef struct {
71 NOMClass *nomClassObject;
72 nomToken nomTokens[1]; /* method tokens, etc. */
73} nomClassDataStructure, *NomClassDataStructurePtr;
74
75/**
76 Structure describing the parameters of a static method. The information
77 is used for runtime type information.
78 */
79typedef struct nomParmInfoStruct {
80 gulong ulNumParms; /* The number of parameters for this method */
81 gchar* pReturnType;
82 gchar* pParm[]; /* Parameter types */
83}nomParmInfo;
84
85/**
86 This structure defines the method introduced by a class. The IDL compiler
87 puts an array of such structs into the *.ih file which is used by the NOM
88 kernel to build the class.
89 */
90typedef struct nomStaticMethodDescStruct {
91 nomMToken *nomMAddressInClassData; /* Method token in class data struct */
92 nomID nomMethodId; /* This is a 'gchar**' pointing to something like
93 "wpQueryContainerHandle" */
94 char** chrMethodDescriptor; /* This points to something like:
95 "WPFolderWindow:wpQueryContainerHandle" */
96 nomMethodProc *nomMethod; /* Address of the function implementing this
97 method. */
98 nomParmInfo *pParamInfo; /* Information about the parameter types */
99} nomStaticMethodDesc;
100
101/**
102 Structure describing an overriden method. An array of these structures
103 is put into the *.ih file.
104 */
105typedef struct nomOverridenMethodDescStruct {
106 nomID nomMethodId;
107 nomMethodProc *nomMethod;
108 nomMethodProc **nomParentMethod;
109} nomOverridenMethodDesc;
110
111typedef struct {
112 nomParentMtabStructPtr parentMtab;
113 nomDToken instanceDataToken;
114} nomCClassDataStructure, *nomCClassDataStructurePtr;
115
116
117/* This struct carries quite some dead entries (for us)... */
118typedef struct nomStaticClassInfoStruct {
119 gulong ulVersion;
120 gulong ulNumStaticMethods;
121 gulong ulNumStaticOverrides;
122 gulong ulMajorVersion;
123 gulong ulMinorVersion;
124 gulong ulInstanceDataSize;
125 gulong ulNumParents; /* Used for multiple inheritance */
126 nomID nomClassId;
127 nomID nomExplicitMetaId;
128
129 nomClassDataStructure *nomCds;
130 nomCClassDataStructure *ccds;
131 nomStaticMethodDesc* nomSMethods;
132 nomID *nomIdAllParents;
133 char** chrParentClassNames;
134 gulong ulNumParentsInChain;
135 nomOverridenMethodDesc* nomOverridenMethods;
136} nomStaticClassInfo, *nomStaticClassInfoPtr;
137
138
139typedef struct
140{
141 ULONG thunk[4];
142}nomMethodThunk;
143
144#define NOM_FLG_IS_METACLASS 0x00000001
145#define NOM_FLG_NOMUNINIT_OVERRIDEN 0x00000002
146
147/* This structure holds additional informationen about a class not to be found in nomMethodTab.
148 It holds the default method table of the class and the thunking code necessary to access
149 data and methods. Note that the name may be slightly misleading. This structure is not
150 limited to objects/classes which are related to NOMClass. It's a structure used by every NOM
151 class (be it a normal class or a meta class).
152*/
153typedef struct
154{
155 nomMethodTab *mtab; /* This is the mtab for this class it points to thisMtab at the
156 end. This is not an mtab for objects created by a meta class.
157 Meta classes store the pointer to a NOMClassPriv which specify
158 the objects they may create in a private instance variable. */
159 gulong ulClassSize; /* The size of an instance (mtab+ instance vars) */
160 gulong ulPrivClassSize; /* The size of this private struct including mtab (not pointr but
161 real filled structure. Do we need this? */
162 gulong ulClassFlags; /* Set to 1 if this is a metaclass */
163 nomStaticClassInfo *sci; /* Class description */
164 /* FIXME: the following list may be obsolete maybe when we just use the parentMtabStruc?? */
165 nomMethodTabList mtabList; /* The (private) internal list of mtabs we maintain
166 struct nomMethodTabList {
167 nomMethodTab *mtab; /mtab for this class
168 struct nomMethodTabList *next; / parents
169 } nomMethodTabList, *nomMethodTabs; */
170 nomParentMtabStruct parentMtabStruct; /* used for method lookup and other stuff */
171 gulong thunk[3]; /* Thunking code to get the address of an instance var */
172 nomMethodThunk *mThunk; /* The thunk code to call the methods of this class */
173 NOMClass** entries0; /* Address where our part of the mtab starts (classObject pointer) */
174 nomMethodTab thisMtab; /* mtab structure of this class */
175}NOMClassPriv;
176
177/* For holding a list of class objects */
178typedef struct nomClassList {
179 NOMClass *cls;
180 struct nomClassList *next;
181} nomClassList, *nomClasses;
182
183NOMEXTERN NOMClass * NOMLINK nomBuildClass (gulong ulReserved,
184 nomStaticClassInfo *sci,
185 gulong ulMajorVersion,
186 gulong ulMinorVersion);
187
188//#define nomIsObj(a) ((a)!= 0)
189#endif /* NOMAPI_H_INCLUDED */
190
Note: See TracBrowser for help on using the repository browser.