1    /*******************************************************/
2    /*      "C" Language Integrated Production System      */
3    /*                                                     */
4    /*               CLIPS Version 6.30  08/16/14          */
5    /*                                                     */
6    /*                OBJECT SYSTEM DEFINITIONS            */
7    /*******************************************************/
8 
9 /*************************************************************/
10 /* Purpose:                                                  */
11 /*                                                           */
12 /* Principal Programmer(s):                                  */
13 /*      Brian L. Dantes                                      */
14 /*                                                           */
15 /* Contributing Programmer(s):                               */
16 /*                                                           */
17 /*                                                           */
18 /* Revision History:                                         */
19 /*                                                           */
20 /*      6.30: Changed integer type/precision.                */
21 /*                                                           */
22 /*            Changed garbage collection algorithm.          */
23 /*                                                           */
24 /*************************************************************/
25 
26 #ifndef _H_object
27 #define _H_object
28 
29 typedef struct defclassModule DEFCLASS_MODULE;
30 typedef struct defclass DEFCLASS;
31 typedef struct packedClassLinks PACKED_CLASS_LINKS;
32 typedef struct classLink CLASS_LINK;
33 typedef struct slotName SLOT_NAME;
34 typedef struct slotDescriptor SLOT_DESC;
35 typedef struct messageHandler HANDLER;
36 typedef struct instance INSTANCE_TYPE;
37 typedef struct instanceSlot INSTANCE_SLOT;
38 
39 /* Maximum # of simultaneous class hierarchy traversals
40    should be a multiple of BITS_PER_BYTE and less than MAX_INT      */
41 
42 #define MAX_TRAVERSALS  256
43 #define TRAVERSAL_BYTES 32       /* (MAX_TRAVERSALS / BITS_PER_BYTE) */
44 
45 #define VALUE_REQUIRED     0
46 #define VALUE_PROHIBITED   1
47 #define VALUE_NOT_REQUIRED 2
48 
49 #ifndef _H_constrct
50 #include "constrct.h"
51 #endif
52 #ifndef _H_constrnt
53 #include "constrnt.h"
54 #endif
55 #ifndef _H_moduldef
56 #include "moduldef.h"
57 #endif
58 #ifndef _H_evaluatn
59 #include "evaluatn.h"
60 #endif
61 #ifndef _H_expressn
62 #include "expressn.h"
63 #endif
64 #ifndef _H_multifld
65 #include "multifld.h"
66 #endif
67 #ifndef _H_symbol
68 #include "symbol.h"
69 #endif
70 
71 #ifndef _H_match
72 #include "match.h"
73 #endif
74 #ifndef _H_pattern
75 #include "pattern.h"
76 #endif
77 
78 #define GetInstanceSlotLength(sp) GetMFLength(sp->value)
79 
80 struct packedClassLinks
81   {
82    long classCount;
83    DEFCLASS **classArray;
84   };
85 
86 struct defclassModule
87   {
88    struct defmoduleItemHeader header;
89   };
90 
91 struct defclass
92   {
93    struct constructHeader header;
94    unsigned installed      : 1;
95    unsigned system         : 1;
96    unsigned abstract       : 1;
97    unsigned reactive       : 1;
98    unsigned traceInstances : 1;
99    unsigned traceSlots     : 1;
100    unsigned id;
101    unsigned busy,
102             hashTableIndex;
103    PACKED_CLASS_LINKS directSuperclasses,
104                       directSubclasses,
105                       allSuperclasses;
106    SLOT_DESC *slots,
107              **instanceTemplate;
108    unsigned *slotNameMap;
109    short slotCount;
110    short localInstanceSlotCount;
111    short instanceSlotCount;
112    short maxSlotNameID;
113    INSTANCE_TYPE *instanceList,
114                  *instanceListBottom;
115    HANDLER *handlers;
116    unsigned *handlerOrderMap;
117    short handlerCount;
118    DEFCLASS *nxtHash;
119    BITMAP_HN *scopeMap;
120    char traversalRecord[TRAVERSAL_BYTES];
121   };
122 
123 struct classLink
124   {
125    DEFCLASS *cls;
126    struct classLink *nxt;
127   };
128 
129 struct slotName
130   {
131    unsigned hashTableIndex,
132             use;
133    short id;
134    SYMBOL_HN *name,
135              *putHandlerName;
136    struct slotName *nxt;
137    long bsaveIndex;
138   };
139 
140 struct instanceSlot
141   {
142    SLOT_DESC *desc;
143    unsigned valueRequired : 1;
144    unsigned override      : 1;
145    unsigned short type;
146    void *value;
147   };
148 
149 struct slotDescriptor
150   {
151    unsigned shared                   : 1;
152    unsigned multiple                 : 1;
153    unsigned composite                : 1;
154    unsigned noInherit                : 1;
155    unsigned noWrite                  : 1;
156    unsigned initializeOnly           : 1;
157    unsigned dynamicDefault           : 1;
158    unsigned defaultSpecified         : 1;
159    unsigned noDefault                : 1;
160    unsigned reactive                 : 1;
161    unsigned publicVisibility         : 1;
162    unsigned createReadAccessor       : 1;
163    unsigned createWriteAccessor      : 1;
164    unsigned overrideMessageSpecified : 1;
165    DEFCLASS *cls;
166    SLOT_NAME *slotName;
167    SYMBOL_HN *overrideMessage;
168    void *defaultValue;
169    CONSTRAINT_RECORD *constraint;
170    unsigned sharedCount;
171    long bsaveIndex;
172    INSTANCE_SLOT sharedValue;
173   };
174 
175 struct instance
176   {
177    struct patternEntity header;
178    void *partialMatchList;
179    INSTANCE_SLOT *basisSlots;
180    unsigned installed            : 1;
181    unsigned garbage              : 1;
182    unsigned initSlotsCalled      : 1;
183    unsigned initializeInProgress : 1;
184    unsigned reteSynchronized     : 1;
185    SYMBOL_HN *name;
186    unsigned hashTableIndex;
187    unsigned busy;
188    DEFCLASS *cls;
189    INSTANCE_TYPE *prvClass,*nxtClass,
190                  *prvHash,*nxtHash,
191                  *prvList,*nxtList;
192    INSTANCE_SLOT **slotAddresses,
193                  *slots;
194   };
195 
196 struct messageHandler
197   {
198    unsigned system         : 1;
199    unsigned type           : 2;
200    unsigned mark           : 1;
201    unsigned trace          : 1;
202    unsigned busy;
203    SYMBOL_HN *name;
204    DEFCLASS *cls;
205    short minParams;
206    short maxParams;
207    short localVarCount;
208    EXPRESSION *actions;
209    char *ppForm;
210    struct userData *usrData;
211   };
212 
213 #endif /* _H_object */
214 
215 
216 
217 
218 
219