00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <stdlib.h>
00031
00032 #include "setup.h"
00033
00034 #if OBJECT_SYSTEM && (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE)
00035
00036 #include "bload.h"
00037 #include "bsave.h"
00038 #include "classcom.h"
00039 #include "classfun.h"
00040 #include "classini.h"
00041 #include "cstrcbin.h"
00042 #include "cstrnbin.h"
00043 #include "envrnmnt.h"
00044 #include "insfun.h"
00045 #include "memalloc.h"
00046 #include "modulbin.h"
00047 #include "msgcom.h"
00048 #include "msgfun.h"
00049 #include "prntutil.h"
00050 #include "router.h"
00051
00052 #define _OBJBIN_SOURCE_
00053 #include "objbin.h"
00054
00055
00056
00057
00058
00059
00060
00061 #define SlotIndex(p) (((p) != NULL) ? (p)->bsaveIndex : -1L)
00062 #define SlotNameIndex(p) (p)->bsaveIndex
00063
00064 #define LinkPointer(i) (((i) == -1L) ? NULL : (DEFCLASS **) &ObjectBinaryData(theEnv)->LinkArray[i])
00065 #define SlotPointer(i) (((i) == -1L) ? NULL : (SLOT_DESC *) &ObjectBinaryData(theEnv)->SlotArray[i])
00066 #define TemplateSlotPointer(i) (((i) == -1L) ? NULL : (SLOT_DESC **) &ObjectBinaryData(theEnv)->TmpslotArray[i])
00067 #define OrderedSlotPointer(i) (((i) == -1L) ? NULL : (unsigned *) &ObjectBinaryData(theEnv)->MapslotArray[i])
00068 #define SlotNamePointer(i) ((SLOT_NAME *) &ObjectBinaryData(theEnv)->SlotNameArray[i])
00069 #define HandlerPointer(i) (((i) == -1L) ? NULL : (HANDLER *) &ObjectBinaryData(theEnv)->HandlerArray[i])
00070 #define OrderedHandlerPointer(i) (((i) == -1L) ? NULL : (unsigned *) &ObjectBinaryData(theEnv)->MaphandlerArray[i])
00071
00072 typedef struct bsaveDefclassModule
00073 {
00074 struct bsaveDefmoduleItemHeader header;
00075 } BSAVE_DEFCLASS_MODULE;
00076
00077 typedef struct bsavePackedClassLinks
00078 {
00079 long classCount;
00080 long classArray;
00081 } BSAVE_PACKED_CLASS_LINKS;
00082
00083 typedef struct bsaveDefclass
00084 {
00085 struct bsaveConstructHeader header;
00086 unsigned abstract : 1;
00087 unsigned reactive : 1;
00088 unsigned system : 1;
00089 unsigned id;
00090 BSAVE_PACKED_CLASS_LINKS directSuperclasses,
00091 directSubclasses,
00092 allSuperclasses;
00093 short slotCount,localInstanceSlotCount,
00094 instanceSlotCount,maxSlotNameID;
00095 short handlerCount;
00096 long slots,
00097 instanceTemplate,
00098 slotNameMap,
00099 handlers,
00100 scopeMap;
00101 } BSAVE_DEFCLASS;
00102
00103 typedef struct bsaveSlotName
00104 {
00105 short id;
00106 unsigned hashTableIndex;
00107 long name,
00108 putHandlerName;
00109 } BSAVE_SLOT_NAME;
00110
00111 typedef struct bsaveSlotDescriptor
00112 {
00113 unsigned shared : 1;
00114 unsigned multiple : 1;
00115 unsigned composite : 1;
00116 unsigned noInherit : 1;
00117 unsigned noWrite : 1;
00118 unsigned initializeOnly : 1;
00119 unsigned dynamicDefault : 1;
00120 unsigned noDefault : 1;
00121 unsigned reactive : 1;
00122 unsigned publicVisibility : 1;
00123 unsigned createReadAccessor : 1;
00124 unsigned createWriteAccessor : 1;
00125 long cls,
00126 slotName,
00127 defaultValue,
00128 constraint,
00129 overrideMessage;
00130 } BSAVE_SLOT_DESC;
00131
00132 typedef struct bsaveMessageHandler
00133 {
00134 unsigned system : 1;
00135 unsigned type : 2;
00136 short minParams,
00137 maxParams,
00138 localVarCount;
00139 long name,
00140 cls,
00141 actions;
00142 } BSAVE_HANDLER;
00143
00144 typedef struct handlerBsaveInfo
00145 {
00146 HANDLER *handlers;
00147 unsigned *handlerOrderMap;
00148 unsigned handlerCount;
00149 } HANDLER_BSAVE_INFO;
00150
00151
00152
00153
00154
00155
00156
00157 #if BLOAD_AND_BSAVE
00158
00159 static void BsaveObjectsFind(void *);
00160 static void MarkDefclassItems(void *,struct constructHeader *,void *);
00161 static void BsaveObjectsExpressions(void *,FILE *);
00162 static void BsaveDefaultSlotExpressions(void *,struct constructHeader *,void *);
00163 static void BsaveHandlerActionExpressions(void *,struct constructHeader *,void *);
00164 static void BsaveStorageObjects(void *,FILE *);
00165 static void BsaveObjects(void *,FILE *);
00166 static void BsaveDefclass(void *,struct constructHeader *,void *);
00167 static void BsaveClassLinks(void *,struct constructHeader *,void *);
00168 static void BsaveSlots(void *,struct constructHeader *,void *);
00169 static void BsaveTemplateSlots(void *,struct constructHeader *,void *);
00170 static void BsaveSlotMap(void *,struct constructHeader *,void *);
00171 static void BsaveHandlers(void *,struct constructHeader *,void *);
00172 static void BsaveHandlerMap(void *,struct constructHeader *,void *);
00173
00174 #endif
00175
00176 static void BloadStorageObjects(void *);
00177 static void BloadObjects(void *);
00178 static void UpdatePrimitiveClassesMap(void *);
00179 static void UpdateDefclassModule(void *,void *,long);
00180 static void UpdateDefclass(void *,void *,long);
00181 static void UpdateLink(void *,void *,long);
00182 static void UpdateSlot(void *,void *,long);
00183 static void UpdateSlotName(void *,void *,long);
00184 static void UpdateTemplateSlot(void *,void *,long);
00185 static void UpdateHandler(void *,void *,long);
00186 static void ClearBloadObjects(void *);
00187 static void DeallocateObjectBinaryData(void *);
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205 globle void SetupObjectsBload(
00206 void *theEnv)
00207 {
00208 AllocateEnvironmentData(theEnv,OBJECTBIN_DATA,sizeof(struct objectBinaryData),DeallocateObjectBinaryData);
00209
00210 AddAbortBloadFunction(theEnv,"defclass",CreateSystemClasses,0);
00211
00212 #if BLOAD_AND_BSAVE
00213 AddBinaryItem(theEnv,"defclass",0,BsaveObjectsFind,BsaveObjectsExpressions,
00214 BsaveStorageObjects,BsaveObjects,
00215 BloadStorageObjects,BloadObjects,
00216 ClearBloadObjects);
00217 #endif
00218 #if BLOAD || BLOAD_ONLY
00219 AddBinaryItem(theEnv,"defclass",0,NULL,NULL,NULL,NULL,
00220 BloadStorageObjects,BloadObjects,
00221 ClearBloadObjects);
00222 #endif
00223
00224 }
00225
00226
00227
00228
00229
00230 static void DeallocateObjectBinaryData(
00231 void *theEnv)
00232 {
00233 size_t space;
00234 long i;
00235
00236 #if (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE) && (! RUN_TIME)
00237
00238 space = (sizeof(DEFCLASS_MODULE) * ObjectBinaryData(theEnv)->ModuleCount);
00239 if (space != 0) genfree(theEnv,(void *) ObjectBinaryData(theEnv)->ModuleArray,space);
00240
00241 if (ObjectBinaryData(theEnv)->ClassCount != 0)
00242 {
00243 if (DefclassData(theEnv)->ClassIDMap != NULL)
00244 { rm(theEnv,(void *) DefclassData(theEnv)->ClassIDMap,(sizeof(DEFCLASS *) * DefclassData(theEnv)->AvailClassID)); }
00245
00246 for (i = 0L ; i < ObjectBinaryData(theEnv)->SlotCount ; i++)
00247 {
00248 if ((ObjectBinaryData(theEnv)->SlotArray[i].defaultValue != NULL) && (ObjectBinaryData(theEnv)->SlotArray[i].dynamicDefault == 0))
00249 { rtn_struct(theEnv,dataObject,ObjectBinaryData(theEnv)->SlotArray[i].defaultValue); }
00250 }
00251
00252 space = (sizeof(DEFCLASS) * ObjectBinaryData(theEnv)->ClassCount);
00253 if (space != 0L)
00254 { genfree(theEnv,(void *) ObjectBinaryData(theEnv)->DefclassArray,space); }
00255
00256 space = (sizeof(DEFCLASS *) * ObjectBinaryData(theEnv)->LinkCount);
00257 if (space != 0L)
00258 { genfree(theEnv,(void *) ObjectBinaryData(theEnv)->LinkArray,space); }
00259
00260 space = (sizeof(SLOT_DESC) * ObjectBinaryData(theEnv)->SlotCount);
00261 if (space != 0L)
00262 { genfree(theEnv,(void *) ObjectBinaryData(theEnv)->SlotArray,space); }
00263
00264 space = (sizeof(SLOT_NAME) * ObjectBinaryData(theEnv)->SlotNameCount);
00265 if (space != 0L)
00266 { genfree(theEnv,(void *) ObjectBinaryData(theEnv)->SlotNameArray,space); }
00267
00268 space = (sizeof(SLOT_DESC *) * ObjectBinaryData(theEnv)->TemplateSlotCount);
00269 if (space != 0L)
00270 { genfree(theEnv,(void *) ObjectBinaryData(theEnv)->TmpslotArray,space); }
00271
00272 space = (sizeof(unsigned) * ObjectBinaryData(theEnv)->SlotNameMapCount);
00273 if (space != 0L)
00274 { genfree(theEnv,(void *) ObjectBinaryData(theEnv)->MapslotArray,space); }
00275 }
00276
00277 if (ObjectBinaryData(theEnv)->HandlerCount != 0L)
00278 {
00279 space = (sizeof(HANDLER) * ObjectBinaryData(theEnv)->HandlerCount);
00280 if (space != 0L)
00281 {
00282 genfree(theEnv,(void *) ObjectBinaryData(theEnv)->HandlerArray,space);
00283 space = (sizeof(unsigned) * ObjectBinaryData(theEnv)->HandlerCount);
00284 genfree(theEnv,(void *) ObjectBinaryData(theEnv)->MaphandlerArray,space);
00285 }
00286 }
00287 #endif
00288 }
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299 globle void *BloadDefclassModuleReference(
00300 void *theEnv,
00301 int theIndex)
00302 {
00303 return ((void *) &ObjectBinaryData(theEnv)->ModuleArray[theIndex]);
00304 }
00305
00306
00307
00308
00309
00310
00311
00312 #if BLOAD_AND_BSAVE
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328 static void BsaveObjectsFind(
00329 void *theEnv)
00330 {
00331 register unsigned i;
00332 SLOT_NAME *snp;
00333
00334
00335
00336
00337 SaveBloadCount(theEnv,ObjectBinaryData(theEnv)->ModuleCount);
00338 SaveBloadCount(theEnv,ObjectBinaryData(theEnv)->ClassCount);
00339 SaveBloadCount(theEnv,ObjectBinaryData(theEnv)->LinkCount);
00340 SaveBloadCount(theEnv,ObjectBinaryData(theEnv)->SlotNameCount);
00341 SaveBloadCount(theEnv,ObjectBinaryData(theEnv)->SlotCount);
00342 SaveBloadCount(theEnv,ObjectBinaryData(theEnv)->TemplateSlotCount);
00343 SaveBloadCount(theEnv,ObjectBinaryData(theEnv)->SlotNameMapCount);
00344 SaveBloadCount(theEnv,ObjectBinaryData(theEnv)->HandlerCount);
00345
00346 ObjectBinaryData(theEnv)->ModuleCount= 0L;
00347 ObjectBinaryData(theEnv)->ClassCount = 0L;
00348 ObjectBinaryData(theEnv)->SlotCount = 0L;
00349 ObjectBinaryData(theEnv)->SlotNameCount = 0L;
00350 ObjectBinaryData(theEnv)->LinkCount = 0L;
00351 ObjectBinaryData(theEnv)->TemplateSlotCount = 0L;
00352 ObjectBinaryData(theEnv)->SlotNameMapCount = 0L;
00353 ObjectBinaryData(theEnv)->HandlerCount = 0L;
00354
00355
00356
00357
00358 ObjectBinaryData(theEnv)->ModuleCount =
00359 DoForAllConstructs(theEnv,MarkDefclassItems,DefclassData(theEnv)->DefclassModuleIndex,
00360 FALSE,NULL);
00361
00362
00363
00364
00365 for (i = 0 ; i < SLOT_NAME_TABLE_HASH_SIZE ; i++)
00366 for (snp = DefclassData(theEnv)->SlotNameTable[i] ; snp != NULL ; snp = snp->nxt)
00367 {
00368 if ((snp->id != ISA_ID) && (snp->id != NAME_ID))
00369 {
00370 snp->bsaveIndex = ObjectBinaryData(theEnv)->SlotNameCount++;
00371 snp->name->neededSymbol = TRUE;
00372 snp->putHandlerName->neededSymbol = TRUE;
00373 }
00374 }
00375 }
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387 #if WIN_BTC
00388 #pragma argsused
00389 #endif
00390 static void MarkDefclassItems(
00391 void *theEnv,
00392 struct constructHeader *theDefclass,
00393 void *buf)
00394 {
00395 #if MAC_MCW || WIN_MCW || MAC_XCD
00396 #pragma unused(buf)
00397 #endif
00398 DEFCLASS *cls = (DEFCLASS *) theDefclass;
00399 long i;
00400 EXPRESSION *tmpexp;
00401
00402 MarkConstructHeaderNeededItems(&cls->header,ObjectBinaryData(theEnv)->ClassCount++);
00403 ObjectBinaryData(theEnv)->LinkCount += cls->directSuperclasses.classCount +
00404 cls->directSubclasses.classCount +
00405 cls->allSuperclasses.classCount;
00406
00407 #if DEFMODULE_CONSTRUCT
00408 cls->scopeMap->neededBitMap = TRUE;
00409 #endif
00410
00411
00412
00413
00414 for (i = 0 ; i < cls->slotCount ; i++)
00415 {
00416 cls->slots[i].bsaveIndex = ObjectBinaryData(theEnv)->SlotCount++;
00417 cls->slots[i].overrideMessage->neededSymbol = TRUE;
00418 if (cls->slots[i].defaultValue != NULL)
00419 {
00420 if (cls->slots[i].dynamicDefault)
00421 {
00422 ExpressionData(theEnv)->ExpressionCount +=
00423 ExpressionSize((EXPRESSION *) cls->slots[i].defaultValue);
00424 MarkNeededItems(theEnv,(EXPRESSION *) cls->slots[i].defaultValue);
00425 }
00426 else
00427 {
00428
00429
00430
00431
00432 tmpexp =
00433 ConvertValueToExpression(theEnv,(DATA_OBJECT *) cls->slots[i].defaultValue);
00434 ExpressionData(theEnv)->ExpressionCount += ExpressionSize(tmpexp);
00435 MarkNeededItems(theEnv,tmpexp);
00436 ReturnExpression(theEnv,tmpexp);
00437 }
00438 }
00439 }
00440
00441
00442
00443
00444 ObjectBinaryData(theEnv)->TemplateSlotCount += (long) cls->instanceSlotCount;
00445 if (cls->instanceSlotCount != 0)
00446 ObjectBinaryData(theEnv)->SlotNameMapCount += (long) cls->maxSlotNameID + 1;
00447
00448
00449
00450
00451 for (i = 0 ; i < cls->handlerCount ; i++)
00452 {
00453 cls->handlers[i].name->neededSymbol = TRUE;
00454 ExpressionData(theEnv)->ExpressionCount += ExpressionSize(cls->handlers[i].actions);
00455 MarkNeededItems(theEnv,cls->handlers[i].actions);
00456 }
00457 ObjectBinaryData(theEnv)->HandlerCount += (long) cls->handlerCount;
00458 }
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469 static void BsaveObjectsExpressions(
00470 void *theEnv,
00471 FILE *fp)
00472 {
00473 if ((ObjectBinaryData(theEnv)->ClassCount == 0L) && (ObjectBinaryData(theEnv)->HandlerCount == 0L))
00474 return;
00475
00476
00477
00478
00479 DoForAllConstructs(theEnv,BsaveDefaultSlotExpressions,DefclassData(theEnv)->DefclassModuleIndex,
00480 FALSE,(void *) fp);
00481
00482
00483
00484
00485 DoForAllConstructs(theEnv,BsaveHandlerActionExpressions,DefclassData(theEnv)->DefclassModuleIndex,
00486 FALSE,(void *) fp);
00487 }
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499 static void BsaveDefaultSlotExpressions(
00500 void *theEnv,
00501 struct constructHeader *theDefclass,
00502 void *buf)
00503 {
00504 DEFCLASS *cls = (DEFCLASS *) theDefclass;
00505 long i;
00506 EXPRESSION *tmpexp;
00507
00508 for (i = 0 ; i < cls->slotCount ; i++)
00509 {
00510 if (cls->slots[i].defaultValue != NULL)
00511 {
00512 if (cls->slots[i].dynamicDefault)
00513 BsaveExpression(theEnv,(EXPRESSION *) cls->slots[i].defaultValue,(FILE *) buf);
00514 else
00515 {
00516
00517
00518
00519
00520 tmpexp =
00521 ConvertValueToExpression(theEnv,(DATA_OBJECT *) cls->slots[i].defaultValue);
00522 BsaveExpression(theEnv,tmpexp,(FILE *) buf);
00523 ReturnExpression(theEnv,tmpexp);
00524 }
00525 }
00526 }
00527 }
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539 static void BsaveHandlerActionExpressions(
00540 void *theEnv,
00541 struct constructHeader *theDefclass,
00542 void *buf)
00543 {
00544 DEFCLASS *cls = (DEFCLASS *) theDefclass;
00545 long i;
00546
00547 for (i = 0 ; i < cls->handlerCount ; i++)
00548 BsaveExpression(theEnv,cls->handlers[i].actions,(FILE *) buf);
00549 }
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567 static void BsaveStorageObjects(
00568 void *theEnv,
00569 FILE *fp)
00570 {
00571 size_t space;
00572 long maxClassID;
00573
00574 if ((ObjectBinaryData(theEnv)->ClassCount == 0L) && (ObjectBinaryData(theEnv)->HandlerCount == 0L))
00575 {
00576 space = 0L;
00577 GenWrite((void *) &space,sizeof(size_t),fp);
00578 return;
00579 }
00580 space = sizeof(long) * 9;
00581 GenWrite((void *) &space,sizeof(long),fp);
00582 GenWrite((void *) &ObjectBinaryData(theEnv)->ModuleCount,sizeof(long),fp);
00583 GenWrite((void *) &ObjectBinaryData(theEnv)->ClassCount,sizeof(long),fp);
00584 GenWrite((void *) &ObjectBinaryData(theEnv)->LinkCount,sizeof(long),fp);
00585 GenWrite((void *) &ObjectBinaryData(theEnv)->SlotNameCount,sizeof(long),fp);
00586 GenWrite((void *) &ObjectBinaryData(theEnv)->SlotCount,sizeof(long),fp);
00587 GenWrite((void *) &ObjectBinaryData(theEnv)->TemplateSlotCount,sizeof(long),fp);
00588 GenWrite((void *) &ObjectBinaryData(theEnv)->SlotNameMapCount,sizeof(long),fp);
00589 GenWrite((void *) &ObjectBinaryData(theEnv)->HandlerCount,sizeof(long),fp);
00590 maxClassID = DefclassData(theEnv)->MaxClassID;
00591 GenWrite((void *) &maxClassID,sizeof(long),fp);
00592 }
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604 static void BsaveObjects(
00605 void *theEnv,
00606 FILE *fp)
00607 {
00608 size_t space;
00609 struct defmodule *theModule;
00610 DEFCLASS_MODULE *theModuleItem;
00611 BSAVE_DEFCLASS_MODULE dummy_mitem;
00612 BSAVE_SLOT_NAME dummy_slot_name;
00613 SLOT_NAME *snp;
00614 register unsigned i;
00615
00616 if ((ObjectBinaryData(theEnv)->ClassCount == 0L) && (ObjectBinaryData(theEnv)->HandlerCount == 0L))
00617 {
00618 space = 0L;
00619 GenWrite((void *) &space,sizeof(size_t),fp);
00620 return;
00621 }
00622 space = (ObjectBinaryData(theEnv)->ModuleCount * sizeof(BSAVE_DEFCLASS_MODULE)) +
00623 (ObjectBinaryData(theEnv)->ClassCount * sizeof(BSAVE_DEFCLASS)) +
00624 (ObjectBinaryData(theEnv)->LinkCount * sizeof(long)) +
00625 (ObjectBinaryData(theEnv)->SlotCount * sizeof(BSAVE_SLOT_DESC)) +
00626 (ObjectBinaryData(theEnv)->SlotNameCount * sizeof(BSAVE_SLOT_NAME)) +
00627 (ObjectBinaryData(theEnv)->TemplateSlotCount * sizeof(long)) +
00628 (ObjectBinaryData(theEnv)->SlotNameMapCount * sizeof(unsigned)) +
00629 (ObjectBinaryData(theEnv)->HandlerCount * sizeof(BSAVE_HANDLER)) +
00630 (ObjectBinaryData(theEnv)->HandlerCount * sizeof(unsigned));
00631 GenWrite((void *) &space,sizeof(size_t),fp);
00632
00633 ObjectBinaryData(theEnv)->ClassCount = 0L;
00634 ObjectBinaryData(theEnv)->LinkCount = 0L;
00635 ObjectBinaryData(theEnv)->SlotCount = 0L;
00636 ObjectBinaryData(theEnv)->SlotNameCount = 0L;
00637 ObjectBinaryData(theEnv)->TemplateSlotCount = 0L;
00638 ObjectBinaryData(theEnv)->SlotNameMapCount = 0L;
00639 ObjectBinaryData(theEnv)->HandlerCount = 0L;
00640
00641
00642
00643
00644 theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL);
00645 while (theModule != NULL)
00646 {
00647 theModuleItem = (DEFCLASS_MODULE *)
00648 GetModuleItem(theEnv,theModule,FindModuleItem(theEnv,"defclass")->moduleIndex);
00649 AssignBsaveDefmdlItemHdrVals(&dummy_mitem.header,&theModuleItem->header);
00650 GenWrite((void *) &dummy_mitem,sizeof(BSAVE_DEFCLASS_MODULE),fp);
00651 theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,(void *) theModule);
00652 }
00653
00654
00655
00656
00657 DoForAllConstructs(theEnv,BsaveDefclass,DefclassData(theEnv)->DefclassModuleIndex,FALSE,(void *) fp);
00658
00659
00660
00661
00662 ObjectBinaryData(theEnv)->LinkCount = 0L;
00663 DoForAllConstructs(theEnv,BsaveClassLinks,DefclassData(theEnv)->DefclassModuleIndex,FALSE,(void *) fp);
00664
00665
00666
00667
00668 for (i = 0 ; i < SLOT_NAME_TABLE_HASH_SIZE ; i++)
00669 for (snp = DefclassData(theEnv)->SlotNameTable[i] ; snp != NULL ; snp = snp->nxt)
00670 {
00671 if ((snp->id != ISA_ID) && (snp->id != NAME_ID))
00672 {
00673 dummy_slot_name.id = snp->id;
00674 dummy_slot_name.hashTableIndex = snp->hashTableIndex;
00675 dummy_slot_name.name = (long) snp->name->bucket;
00676 dummy_slot_name.putHandlerName = (long) snp->putHandlerName->bucket;
00677 GenWrite((void *) &dummy_slot_name,sizeof(BSAVE_SLOT_NAME),fp);
00678 }
00679 }
00680
00681
00682
00683
00684 DoForAllConstructs(theEnv,BsaveSlots,DefclassData(theEnv)->DefclassModuleIndex,FALSE,(void *) fp);
00685
00686
00687
00688
00689 DoForAllConstructs(theEnv,BsaveTemplateSlots,DefclassData(theEnv)->DefclassModuleIndex,FALSE,(void *) fp);
00690
00691
00692
00693
00694 DoForAllConstructs(theEnv,BsaveSlotMap,DefclassData(theEnv)->DefclassModuleIndex,FALSE,(void *) fp);
00695
00696
00697
00698
00699 DoForAllConstructs(theEnv,BsaveHandlers,DefclassData(theEnv)->DefclassModuleIndex,FALSE,(void *) fp);
00700
00701
00702
00703
00704 DoForAllConstructs(theEnv,BsaveHandlerMap,DefclassData(theEnv)->DefclassModuleIndex,FALSE,(void *) fp);
00705
00706 RestoreBloadCount(theEnv,&ObjectBinaryData(theEnv)->ModuleCount);
00707 RestoreBloadCount(theEnv,&ObjectBinaryData(theEnv)->ClassCount);
00708 RestoreBloadCount(theEnv,&ObjectBinaryData(theEnv)->LinkCount);
00709 RestoreBloadCount(theEnv,&ObjectBinaryData(theEnv)->SlotCount);
00710 RestoreBloadCount(theEnv,&ObjectBinaryData(theEnv)->SlotNameCount);
00711 RestoreBloadCount(theEnv,&ObjectBinaryData(theEnv)->TemplateSlotCount);
00712 RestoreBloadCount(theEnv,&ObjectBinaryData(theEnv)->SlotNameMapCount);
00713 RestoreBloadCount(theEnv,&ObjectBinaryData(theEnv)->HandlerCount);
00714 }
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725 static void BsaveDefclass(
00726 void *theEnv,
00727 struct constructHeader *theDefclass,
00728 void *buf)
00729 {
00730 DEFCLASS *cls = (DEFCLASS *) theDefclass;
00731 BSAVE_DEFCLASS dummy_class;
00732
00733 AssignBsaveConstructHeaderVals(&dummy_class.header,&cls->header);
00734 dummy_class.abstract = cls->abstract;
00735 dummy_class.reactive = cls->reactive;
00736 dummy_class.system = cls->system;
00737 dummy_class.id = cls->id;
00738 dummy_class.slotCount = cls->slotCount;
00739 dummy_class.instanceSlotCount = cls->instanceSlotCount;
00740 dummy_class.localInstanceSlotCount = cls->localInstanceSlotCount;
00741 dummy_class.maxSlotNameID = cls->maxSlotNameID;
00742 dummy_class.handlerCount = cls->handlerCount;
00743 dummy_class.directSuperclasses.classCount = cls->directSuperclasses.classCount;
00744 dummy_class.directSubclasses.classCount = cls->directSubclasses.classCount;
00745 dummy_class.allSuperclasses.classCount = cls->allSuperclasses.classCount;
00746 if (cls->directSuperclasses.classCount != 0)
00747 {
00748 dummy_class.directSuperclasses.classArray = ObjectBinaryData(theEnv)->LinkCount;
00749 ObjectBinaryData(theEnv)->LinkCount += cls->directSuperclasses.classCount;
00750 }
00751 else
00752 dummy_class.directSuperclasses.classArray = -1L;
00753 if (cls->directSubclasses.classCount != 0)
00754 {
00755 dummy_class.directSubclasses.classArray = ObjectBinaryData(theEnv)->LinkCount;
00756 ObjectBinaryData(theEnv)->LinkCount += cls->directSubclasses.classCount;
00757 }
00758 else
00759 dummy_class.directSubclasses.classArray = -1L;
00760 if (cls->allSuperclasses.classCount != 0)
00761 {
00762 dummy_class.allSuperclasses.classArray = ObjectBinaryData(theEnv)->LinkCount;
00763 ObjectBinaryData(theEnv)->LinkCount += cls->allSuperclasses.classCount;
00764 }
00765 else
00766 dummy_class.allSuperclasses.classArray = -1L;
00767 if (cls->slots != NULL)
00768 {
00769 dummy_class.slots = ObjectBinaryData(theEnv)->SlotCount;
00770 ObjectBinaryData(theEnv)->SlotCount += (long) cls->slotCount;
00771 }
00772 else
00773 dummy_class.slots = -1L;
00774 if (cls->instanceTemplate != NULL)
00775 {
00776 dummy_class.instanceTemplate = ObjectBinaryData(theEnv)->TemplateSlotCount;
00777 ObjectBinaryData(theEnv)->TemplateSlotCount += (long) cls->instanceSlotCount;
00778 dummy_class.slotNameMap = ObjectBinaryData(theEnv)->SlotNameMapCount;
00779 ObjectBinaryData(theEnv)->SlotNameMapCount += (long) cls->maxSlotNameID + 1;
00780 }
00781 else
00782 {
00783 dummy_class.instanceTemplate = -1L;
00784 dummy_class.slotNameMap = -1L;
00785 }
00786 if (cls->handlers != NULL)
00787 {
00788 dummy_class.handlers = ObjectBinaryData(theEnv)->HandlerCount;
00789 ObjectBinaryData(theEnv)->HandlerCount += (long) cls->handlerCount;
00790 }
00791 else
00792 dummy_class.handlers = -1L;
00793 #if DEFMODULE_CONSTRUCT
00794 dummy_class.scopeMap = (long) cls->scopeMap->bucket;
00795 #else
00796 dummy_class.scopeMap = -1L;
00797 #endif
00798 GenWrite((void *) &dummy_class,sizeof(BSAVE_DEFCLASS),(FILE *) buf);
00799 }
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810 static void BsaveClassLinks(
00811 void *theEnv,
00812 struct constructHeader *theDefclass,
00813 void *buf)
00814 {
00815 DEFCLASS *cls = (DEFCLASS *) theDefclass;
00816 long i;
00817 long dummy_class_index;
00818
00819 for (i = 0 ; i < cls->directSuperclasses.classCount ; i++)
00820 {
00821 dummy_class_index = DefclassIndex(cls->directSuperclasses.classArray[i]);
00822 GenWrite((void *) &dummy_class_index,sizeof(long),(FILE *) buf);
00823 }
00824 ObjectBinaryData(theEnv)->LinkCount += cls->directSuperclasses.classCount;
00825 for (i = 0 ; i < cls->directSubclasses.classCount ; i++)
00826 {
00827 dummy_class_index = DefclassIndex(cls->directSubclasses.classArray[i]);
00828 GenWrite((void *) &dummy_class_index,sizeof(long),(FILE *) buf);
00829 }
00830 ObjectBinaryData(theEnv)->LinkCount += cls->directSubclasses.classCount;
00831 for (i = 0 ; i < cls->allSuperclasses.classCount ; i++)
00832 {
00833 dummy_class_index = DefclassIndex(cls->allSuperclasses.classArray[i]);
00834 GenWrite((void *) &dummy_class_index,sizeof(long),(FILE *) buf);
00835 }
00836 ObjectBinaryData(theEnv)->LinkCount += cls->allSuperclasses.classCount;
00837 }
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848 static void BsaveSlots(
00849 void *theEnv,
00850 struct constructHeader *theDefclass,
00851 void *buf)
00852 {
00853 DEFCLASS *cls = (DEFCLASS *) theDefclass;
00854 long i;
00855 BSAVE_SLOT_DESC dummy_slot;
00856 SLOT_DESC *sp;
00857 EXPRESSION *tmpexp;
00858
00859 for (i = 0 ; i < cls->slotCount ; i++)
00860 {
00861 sp = &cls->slots[i];
00862 dummy_slot.dynamicDefault = sp->dynamicDefault;
00863 dummy_slot.noDefault = sp->noDefault;
00864 dummy_slot.shared = sp->shared;
00865 dummy_slot.multiple = sp->multiple;
00866 dummy_slot.composite = sp->composite;
00867 dummy_slot.noInherit = sp->noInherit;
00868 dummy_slot.noWrite = sp->noWrite;
00869 dummy_slot.initializeOnly = sp->initializeOnly;
00870 dummy_slot.reactive = sp->reactive;
00871 dummy_slot.publicVisibility = sp->publicVisibility;
00872 dummy_slot.createReadAccessor = sp->createReadAccessor;
00873 dummy_slot.createWriteAccessor = sp->createWriteAccessor;
00874 dummy_slot.cls = DefclassIndex(sp->cls);
00875 dummy_slot.slotName = SlotNameIndex(sp->slotName);
00876 dummy_slot.overrideMessage = (long) sp->overrideMessage->bucket;
00877 if (sp->defaultValue != NULL)
00878 {
00879 dummy_slot.defaultValue = ExpressionData(theEnv)->ExpressionCount;
00880 if (sp->dynamicDefault)
00881 ExpressionData(theEnv)->ExpressionCount += ExpressionSize((EXPRESSION *) sp->defaultValue);
00882 else
00883 {
00884 tmpexp = ConvertValueToExpression(theEnv,(DATA_OBJECT *) sp->defaultValue);
00885 ExpressionData(theEnv)->ExpressionCount += ExpressionSize(tmpexp);
00886 ReturnExpression(theEnv,tmpexp);
00887 }
00888 }
00889 else
00890 dummy_slot.defaultValue = -1L;
00891 dummy_slot.constraint = ConstraintIndex(sp->constraint);
00892 GenWrite((void *) &dummy_slot,sizeof(BSAVE_SLOT_DESC),(FILE *) buf);
00893 }
00894 }
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905 #if WIN_BTC
00906 #pragma argsused
00907 #endif
00908 static void BsaveTemplateSlots(
00909 void *theEnv,
00910 struct constructHeader *theDefclass,
00911 void *buf)
00912 {
00913 DEFCLASS *cls = (DEFCLASS *) theDefclass;
00914 long i;
00915 long tsp;
00916 #if MAC_MCW || WIN_MCW || MAC_XCD
00917 #pragma unused(theEnv)
00918 #endif
00919
00920 for (i = 0 ; i < cls->instanceSlotCount ; i++)
00921 {
00922 tsp = SlotIndex(cls->instanceTemplate[i]);
00923 GenWrite((void *) &tsp,sizeof(long),(FILE *) buf);
00924 }
00925 }
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936 #if WIN_BTC
00937 #pragma argsused
00938 #endif
00939 static void BsaveSlotMap(
00940 void *theEnv,
00941 struct constructHeader *theDefclass,
00942 void *buf)
00943 {
00944 DEFCLASS *cls = (DEFCLASS *) theDefclass;
00945 #if MAC_MCW || WIN_MCW || MAC_XCD
00946 #pragma unused(theEnv)
00947 #endif
00948
00949 if (cls->instanceSlotCount != 0)
00950 GenWrite((void *) cls->slotNameMap,
00951 (sizeof(unsigned) * (cls->maxSlotNameID + 1)),(FILE *) buf);
00952 }
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963 static void BsaveHandlers(
00964 void *theEnv,
00965 struct constructHeader *theDefclass,
00966 void *buf)
00967 {
00968 DEFCLASS *cls = (DEFCLASS *) theDefclass;
00969 long i;
00970 BSAVE_HANDLER dummy_handler;
00971 HANDLER *hnd;
00972
00973 for (i = 0 ; i < cls->handlerCount ; i++)
00974 {
00975 hnd = &cls->handlers[i];
00976 dummy_handler.system = hnd->system;
00977 dummy_handler.type = hnd->type;
00978 dummy_handler.minParams = hnd->minParams;
00979 dummy_handler.maxParams = hnd->maxParams;
00980 dummy_handler.localVarCount = hnd->localVarCount;
00981 dummy_handler.cls = DefclassIndex(hnd->cls);
00982 dummy_handler.name = (long) hnd->name->bucket;
00983 if (hnd->actions != NULL)
00984 {
00985 dummy_handler.actions = ExpressionData(theEnv)->ExpressionCount;
00986 ExpressionData(theEnv)->ExpressionCount += ExpressionSize(hnd->actions);
00987 }
00988 else
00989 dummy_handler.actions = -1L;
00990 GenWrite((void *) &dummy_handler,sizeof(BSAVE_HANDLER),(FILE *) buf);
00991 }
00992 }
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003 #if WIN_BTC
01004 #pragma argsused
01005 #endif
01006 static void BsaveHandlerMap(
01007 void *theEnv,
01008 struct constructHeader *theDefclass,
01009 void *buf)
01010 {
01011 DEFCLASS *cls = (DEFCLASS *) theDefclass;
01012 #if MAC_MCW || WIN_MCW || MAC_XCD
01013 #pragma unused(theEnv)
01014 #endif
01015
01016 GenWrite((void *) cls->handlerOrderMap,
01017 (sizeof(unsigned) * cls->handlerCount),(FILE *) buf);
01018 }
01019
01020 #endif
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037 static void BloadStorageObjects(
01038 void *theEnv)
01039 {
01040 size_t space;
01041 long counts[9];
01042
01043 if ((DefclassData(theEnv)->ClassIDMap != NULL) || (DefclassData(theEnv)->MaxClassID != 0))
01044 {
01045 SystemError(theEnv,"OBJBIN",1);
01046 EnvExitRouter(theEnv,EXIT_FAILURE);
01047 }
01048 GenReadBinary(theEnv,(void *) &space,sizeof(size_t));
01049 if (space == 0L)
01050 {
01051 ObjectBinaryData(theEnv)->ClassCount = ObjectBinaryData(theEnv)->HandlerCount = 0L;
01052 return;
01053 }
01054 GenReadBinary(theEnv,(void *) counts,space);
01055 ObjectBinaryData(theEnv)->ModuleCount = counts[0];
01056 ObjectBinaryData(theEnv)->ClassCount = counts[1];
01057 ObjectBinaryData(theEnv)->LinkCount = counts[2];
01058 ObjectBinaryData(theEnv)->SlotNameCount = counts[3];
01059 ObjectBinaryData(theEnv)->SlotCount = counts[4];
01060 ObjectBinaryData(theEnv)->TemplateSlotCount = counts[5];
01061 ObjectBinaryData(theEnv)->SlotNameMapCount = counts[6];
01062 ObjectBinaryData(theEnv)->HandlerCount = counts[7];
01063 DefclassData(theEnv)->MaxClassID = (unsigned short) counts[8];
01064 DefclassData(theEnv)->AvailClassID = (unsigned short) counts[8];
01065 if (ObjectBinaryData(theEnv)->ModuleCount != 0L)
01066 {
01067 space = (sizeof(DEFCLASS_MODULE) * ObjectBinaryData(theEnv)->ModuleCount);
01068 ObjectBinaryData(theEnv)->ModuleArray = (DEFCLASS_MODULE *) genalloc(theEnv,space);
01069 }
01070 if (ObjectBinaryData(theEnv)->ClassCount != 0L)
01071 {
01072 space = (sizeof(DEFCLASS) * ObjectBinaryData(theEnv)->ClassCount);
01073 ObjectBinaryData(theEnv)->DefclassArray = (DEFCLASS *) genalloc(theEnv,space);
01074 DefclassData(theEnv)->ClassIDMap = (DEFCLASS **) gm2(theEnv,(sizeof(DEFCLASS *) * DefclassData(theEnv)->MaxClassID));
01075 }
01076 if (ObjectBinaryData(theEnv)->LinkCount != 0L)
01077 {
01078 space = (sizeof(DEFCLASS *) * ObjectBinaryData(theEnv)->LinkCount);
01079 ObjectBinaryData(theEnv)->LinkArray = (DEFCLASS * *) genalloc(theEnv,space);
01080 }
01081 if (ObjectBinaryData(theEnv)->SlotCount != 0L)
01082 {
01083 space = (sizeof(SLOT_DESC) * ObjectBinaryData(theEnv)->SlotCount);
01084 ObjectBinaryData(theEnv)->SlotArray = (SLOT_DESC *) genalloc(theEnv,space);
01085 }
01086 if (ObjectBinaryData(theEnv)->SlotNameCount != 0L)
01087 {
01088 space = (sizeof(SLOT_NAME) * ObjectBinaryData(theEnv)->SlotNameCount);
01089 ObjectBinaryData(theEnv)->SlotNameArray = (SLOT_NAME *) genalloc(theEnv,space);
01090 }
01091 if (ObjectBinaryData(theEnv)->TemplateSlotCount != 0L)
01092 {
01093 space = (sizeof(SLOT_DESC *) * ObjectBinaryData(theEnv)->TemplateSlotCount);
01094 ObjectBinaryData(theEnv)->TmpslotArray = (SLOT_DESC * *) genalloc(theEnv,space);
01095 }
01096 if (ObjectBinaryData(theEnv)->SlotNameMapCount != 0L)
01097 {
01098 space = (sizeof(unsigned) * ObjectBinaryData(theEnv)->SlotNameMapCount);
01099 ObjectBinaryData(theEnv)->MapslotArray = (unsigned *) genalloc(theEnv,space);
01100 }
01101 if (ObjectBinaryData(theEnv)->HandlerCount != 0L)
01102 {
01103 space = (sizeof(HANDLER) * ObjectBinaryData(theEnv)->HandlerCount);
01104 ObjectBinaryData(theEnv)->HandlerArray = (HANDLER *) genalloc(theEnv,space);
01105 space = (sizeof(unsigned) * ObjectBinaryData(theEnv)->HandlerCount);
01106 ObjectBinaryData(theEnv)->MaphandlerArray = (unsigned *) genalloc(theEnv,space);
01107 }
01108 }
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119 static void BloadObjects(
01120 void *theEnv)
01121 {
01122 size_t space;
01123
01124 GenReadBinary(theEnv,(void *) &space,sizeof(size_t));
01125 if (space == 0L)
01126 return;
01127 if (ObjectBinaryData(theEnv)->ModuleCount != 0L)
01128 BloadandRefresh(theEnv,ObjectBinaryData(theEnv)->ModuleCount,sizeof(BSAVE_DEFCLASS_MODULE),UpdateDefclassModule);
01129 if (ObjectBinaryData(theEnv)->ClassCount != 0L)
01130 {
01131 BloadandRefresh(theEnv,ObjectBinaryData(theEnv)->ClassCount,sizeof(BSAVE_DEFCLASS),UpdateDefclass);
01132 BloadandRefresh(theEnv,ObjectBinaryData(theEnv)->LinkCount,sizeof(DEFCLASS *),UpdateLink);
01133 BloadandRefresh(theEnv,ObjectBinaryData(theEnv)->SlotNameCount,sizeof(BSAVE_SLOT_NAME),UpdateSlotName);
01134 BloadandRefresh(theEnv,ObjectBinaryData(theEnv)->SlotCount,sizeof(BSAVE_SLOT_DESC),UpdateSlot);
01135 if (ObjectBinaryData(theEnv)->TemplateSlotCount != 0L)
01136 BloadandRefresh(theEnv,ObjectBinaryData(theEnv)->TemplateSlotCount,sizeof(long),UpdateTemplateSlot);
01137 if (ObjectBinaryData(theEnv)->SlotNameMapCount != 0L)
01138 {
01139 space = (sizeof(unsigned) * ObjectBinaryData(theEnv)->SlotNameMapCount);
01140 GenReadBinary(theEnv,(void *) ObjectBinaryData(theEnv)->MapslotArray,space);
01141 }
01142 if (ObjectBinaryData(theEnv)->HandlerCount != 0L)
01143 {
01144 BloadandRefresh(theEnv,ObjectBinaryData(theEnv)->HandlerCount,sizeof(BSAVE_HANDLER),UpdateHandler);
01145 space = (sizeof(unsigned) * ObjectBinaryData(theEnv)->HandlerCount);
01146 GenReadBinary(theEnv,(void *) ObjectBinaryData(theEnv)->MaphandlerArray,space);
01147 }
01148 UpdatePrimitiveClassesMap(theEnv);
01149 }
01150 }
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163 static void UpdatePrimitiveClassesMap(
01164 void *theEnv)
01165 {
01166 register unsigned i;
01167
01168 for (i = 0 ; i < OBJECT_TYPE_CODE ; i++)
01169 DefclassData(theEnv)->PrimitiveClassMap[i] = (DEFCLASS *) &ObjectBinaryData(theEnv)->DefclassArray[i];
01170 }
01171
01172
01173
01174
01175 static void UpdateDefclassModule(
01176 void *theEnv,
01177 void *buf,
01178 long obji)
01179 {
01180 BSAVE_DEFCLASS_MODULE *bdptr;
01181
01182 bdptr = (BSAVE_DEFCLASS_MODULE *) buf;
01183 UpdateDefmoduleItemHeader(theEnv,&bdptr->header,&ObjectBinaryData(theEnv)->ModuleArray[obji].header,
01184 (int) sizeof(DEFCLASS),(void *) ObjectBinaryData(theEnv)->DefclassArray);
01185 }
01186
01187 static void UpdateDefclass(
01188 void *theEnv,
01189 void *buf,
01190 long obji)
01191 {
01192 BSAVE_DEFCLASS *bcls;
01193 DEFCLASS *cls;
01194
01195 bcls = (BSAVE_DEFCLASS *) buf;
01196 cls = (DEFCLASS *) &ObjectBinaryData(theEnv)->DefclassArray[obji];
01197
01198 UpdateConstructHeader(theEnv,&bcls->header,&cls->header,
01199 (int) sizeof(DEFCLASS_MODULE),(void *) ObjectBinaryData(theEnv)->ModuleArray,
01200 (int) sizeof(DEFCLASS),(void *) ObjectBinaryData(theEnv)->DefclassArray);
01201 cls->abstract = bcls->abstract;
01202 cls->reactive = bcls->reactive;
01203 cls->system = bcls->system;
01204 cls->id = bcls->id;
01205 DefclassData(theEnv)->ClassIDMap[cls->id] = cls;
01206 #if DEBUGGING_FUNCTIONS
01207 cls->traceInstances = DefclassData(theEnv)->WatchInstances;
01208 cls->traceSlots = DefclassData(theEnv)->WatchSlots;
01209 #endif
01210 cls->slotCount = bcls->slotCount;
01211 cls->instanceSlotCount = bcls->instanceSlotCount;
01212 cls->localInstanceSlotCount = bcls->localInstanceSlotCount;
01213 cls->maxSlotNameID = bcls->maxSlotNameID;
01214 cls->handlerCount = bcls->handlerCount;
01215 cls->directSuperclasses.classCount =bcls->directSuperclasses.classCount;
01216 cls->directSuperclasses.classArray = LinkPointer(bcls->directSuperclasses.classArray);
01217 cls->directSubclasses.classCount =bcls->directSubclasses.classCount;
01218 cls->directSubclasses.classArray = LinkPointer(bcls->directSubclasses.classArray);
01219 cls->allSuperclasses.classCount =bcls->allSuperclasses.classCount;
01220 cls->allSuperclasses.classArray = LinkPointer(bcls->allSuperclasses.classArray);
01221 cls->slots = SlotPointer(bcls->slots);
01222 cls->instanceTemplate = TemplateSlotPointer(bcls->instanceTemplate);
01223 cls->slotNameMap = OrderedSlotPointer(bcls->slotNameMap);
01224 cls->instanceList = NULL;
01225 cls->handlers = HandlerPointer(bcls->handlers);
01226 cls->handlerOrderMap = OrderedHandlerPointer(bcls->handlers);
01227 cls->installed = 1;
01228 cls->busy = 0;
01229 cls->instanceList = NULL;
01230 cls->instanceListBottom = NULL;
01231 #if DEFMODULE_CONSTRUCT
01232 cls->scopeMap = BitMapPointer(bcls->scopeMap);
01233 IncrementBitMapCount(cls->scopeMap);
01234 #else
01235 cls->scopeMap = NULL;
01236 #endif
01237 PutClassInTable(theEnv,cls);
01238 }
01239
01240 static void UpdateLink(
01241 void *theEnv,
01242 void *buf,
01243 long obji)
01244 {
01245 long *blink;
01246
01247 blink = (long *) buf;
01248 ObjectBinaryData(theEnv)->LinkArray[obji] = DefclassPointer(*blink);
01249 }
01250
01251 static void UpdateSlot(
01252 void *theEnv,
01253 void *buf,
01254 long obji)
01255 {
01256 SLOT_DESC *sp;
01257 BSAVE_SLOT_DESC *bsp;
01258
01259 sp = (SLOT_DESC *) &ObjectBinaryData(theEnv)->SlotArray[obji];
01260 bsp = (BSAVE_SLOT_DESC *) buf;
01261 sp->dynamicDefault = bsp->dynamicDefault;
01262 sp->noDefault = bsp->noDefault;
01263 sp->shared = bsp->shared;
01264 sp->multiple = bsp->multiple;
01265 sp->composite = bsp->composite;
01266 sp->noInherit = bsp->noInherit;
01267 sp->noWrite = bsp->noWrite;
01268 sp->initializeOnly = bsp->initializeOnly;
01269 sp->reactive = bsp->reactive;
01270 sp->publicVisibility = bsp->publicVisibility;
01271 sp->createReadAccessor = bsp->createReadAccessor;
01272 sp->createWriteAccessor = bsp->createWriteAccessor;
01273 sp->cls = DefclassPointer(bsp->cls);
01274 sp->slotName = SlotNamePointer(bsp->slotName);
01275 sp->overrideMessage = SymbolPointer(bsp->overrideMessage);
01276 IncrementSymbolCount(sp->overrideMessage);
01277 if (bsp->defaultValue != -1L)
01278 {
01279 if (sp->dynamicDefault)
01280 sp->defaultValue = (void *) ExpressionPointer(bsp->defaultValue);
01281 else
01282 {
01283 sp->defaultValue = (void *) get_struct(theEnv,dataObject);
01284 EvaluateAndStoreInDataObject(theEnv,(int) sp->multiple,ExpressionPointer(bsp->defaultValue),
01285 (DATA_OBJECT *) sp->defaultValue,TRUE);
01286 ValueInstall(theEnv,(DATA_OBJECT *) sp->defaultValue);
01287 }
01288 }
01289 else
01290 sp->defaultValue = NULL;
01291 sp->constraint = ConstraintPointer(bsp->constraint);
01292 sp->sharedCount = 0;
01293 sp->sharedValue.value = NULL;
01294 sp->bsaveIndex = 0L;
01295 if (sp->shared)
01296 {
01297 sp->sharedValue.desc = sp;
01298 sp->sharedValue.value = NULL;
01299 }
01300 }
01301
01302 static void UpdateSlotName(
01303 void *theEnv,
01304 void *buf,
01305 long obji)
01306 {
01307 SLOT_NAME *snp;
01308 BSAVE_SLOT_NAME *bsnp;
01309
01310 bsnp = (BSAVE_SLOT_NAME *) buf;
01311 snp = (SLOT_NAME *) &ObjectBinaryData(theEnv)->SlotNameArray[obji];
01312 snp->id = bsnp->id;
01313 snp->name = SymbolPointer(bsnp->name);
01314 IncrementSymbolCount(snp->name);
01315 snp->putHandlerName = SymbolPointer(bsnp->putHandlerName);
01316 IncrementSymbolCount(snp->putHandlerName);
01317 snp->hashTableIndex = bsnp->hashTableIndex;
01318 snp->nxt = DefclassData(theEnv)->SlotNameTable[snp->hashTableIndex];
01319 DefclassData(theEnv)->SlotNameTable[snp->hashTableIndex] = snp;
01320 }
01321
01322 static void UpdateTemplateSlot(
01323 void *theEnv,
01324 void *buf,
01325 long obji)
01326 {
01327 ObjectBinaryData(theEnv)->TmpslotArray[obji] = SlotPointer(* (long *) buf);
01328 }
01329
01330 static void UpdateHandler(
01331 void *theEnv,
01332 void *buf,
01333 long obji)
01334 {
01335 HANDLER *hnd;
01336 BSAVE_HANDLER *bhnd;
01337
01338 hnd = (HANDLER *) &ObjectBinaryData(theEnv)->HandlerArray[obji];
01339 bhnd = (BSAVE_HANDLER *) buf;
01340 hnd->system = bhnd->system;
01341 hnd->type = bhnd->type;
01342
01343 hnd->minParams = bhnd->minParams;
01344 hnd->maxParams = bhnd->maxParams;
01345 hnd->localVarCount = bhnd->localVarCount;
01346 hnd->cls = DefclassPointer(bhnd->cls);
01347 hnd->name = SymbolPointer(bhnd->name);
01348 IncrementSymbolCount(hnd->name);
01349 hnd->actions = ExpressionPointer(bhnd->actions);
01350 hnd->ppForm = NULL;
01351 hnd->busy = 0;
01352 hnd->mark = 0;
01353 hnd->usrData = NULL;
01354 #if DEBUGGING_FUNCTIONS
01355 hnd->trace = MessageHandlerData(theEnv)->WatchHandlers;
01356 #endif
01357 }
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368 static void ClearBloadObjects(
01369 void *theEnv)
01370 {
01371 register long i;
01372 size_t space;
01373
01374 space = (sizeof(DEFCLASS_MODULE) * ObjectBinaryData(theEnv)->ModuleCount);
01375 if (space == 0L)
01376 return;
01377 genfree(theEnv,(void *) ObjectBinaryData(theEnv)->ModuleArray,space);
01378 ObjectBinaryData(theEnv)->ModuleArray = NULL;
01379 ObjectBinaryData(theEnv)->ModuleCount = 0L;
01380
01381 if (ObjectBinaryData(theEnv)->ClassCount != 0L)
01382 {
01383 rm(theEnv,(void *) DefclassData(theEnv)->ClassIDMap,(sizeof(DEFCLASS *) * DefclassData(theEnv)->AvailClassID));
01384 DefclassData(theEnv)->ClassIDMap = NULL;
01385 DefclassData(theEnv)->MaxClassID = 0;
01386 DefclassData(theEnv)->AvailClassID = 0;
01387 for (i = 0L ; i < ObjectBinaryData(theEnv)->ClassCount ; i++)
01388 {
01389 UnmarkConstructHeader(theEnv,&ObjectBinaryData(theEnv)->DefclassArray[i].header);
01390 #if DEFMODULE_CONSTRUCT
01391 DecrementBitMapCount(theEnv,ObjectBinaryData(theEnv)->DefclassArray[i].scopeMap);
01392 #endif
01393 RemoveClassFromTable(theEnv,(DEFCLASS *) &ObjectBinaryData(theEnv)->DefclassArray[i]);
01394 }
01395 for (i = 0L ; i < ObjectBinaryData(theEnv)->SlotCount ; i++)
01396 {
01397 DecrementSymbolCount(theEnv,ObjectBinaryData(theEnv)->SlotArray[i].overrideMessage);
01398 if ((ObjectBinaryData(theEnv)->SlotArray[i].defaultValue != NULL) && (ObjectBinaryData(theEnv)->SlotArray[i].dynamicDefault == 0))
01399 {
01400 ValueDeinstall(theEnv,(DATA_OBJECT *) ObjectBinaryData(theEnv)->SlotArray[i].defaultValue);
01401 rtn_struct(theEnv,dataObject,ObjectBinaryData(theEnv)->SlotArray[i].defaultValue);
01402 }
01403 }
01404 for (i = 0L ; i < ObjectBinaryData(theEnv)->SlotNameCount ; i++)
01405 {
01406 DefclassData(theEnv)->SlotNameTable[ObjectBinaryData(theEnv)->SlotNameArray[i].hashTableIndex] = NULL;
01407 DecrementSymbolCount(theEnv,ObjectBinaryData(theEnv)->SlotNameArray[i].name);
01408 DecrementSymbolCount(theEnv,ObjectBinaryData(theEnv)->SlotNameArray[i].putHandlerName);
01409 }
01410
01411 space = (sizeof(DEFCLASS) * ObjectBinaryData(theEnv)->ClassCount);
01412 if (space != 0L)
01413 {
01414 genfree(theEnv,(void *) ObjectBinaryData(theEnv)->DefclassArray,space);
01415 ObjectBinaryData(theEnv)->DefclassArray = NULL;
01416 ObjectBinaryData(theEnv)->ClassCount = 0L;
01417 }
01418
01419 space = (sizeof(DEFCLASS *) * ObjectBinaryData(theEnv)->LinkCount);
01420 if (space != 0L)
01421 {
01422 genfree(theEnv,(void *) ObjectBinaryData(theEnv)->LinkArray,space);
01423 ObjectBinaryData(theEnv)->LinkArray = NULL;
01424 ObjectBinaryData(theEnv)->LinkCount = 0L;
01425 }
01426
01427 space = (sizeof(SLOT_DESC) * ObjectBinaryData(theEnv)->SlotCount);
01428 if (space != 0L)
01429 {
01430 genfree(theEnv,(void *) ObjectBinaryData(theEnv)->SlotArray,space);
01431 ObjectBinaryData(theEnv)->SlotArray = NULL;
01432 ObjectBinaryData(theEnv)->SlotCount = 0L;
01433 }
01434
01435 space = (sizeof(SLOT_NAME) * ObjectBinaryData(theEnv)->SlotNameCount);
01436 if (space != 0L)
01437 {
01438 genfree(theEnv,(void *) ObjectBinaryData(theEnv)->SlotNameArray,space);
01439 ObjectBinaryData(theEnv)->SlotNameArray = NULL;
01440 ObjectBinaryData(theEnv)->SlotNameCount = 0L;
01441 }
01442
01443 space = (sizeof(SLOT_DESC *) * ObjectBinaryData(theEnv)->TemplateSlotCount);
01444 if (space != 0L)
01445 {
01446 genfree(theEnv,(void *) ObjectBinaryData(theEnv)->TmpslotArray,space);
01447 ObjectBinaryData(theEnv)->TmpslotArray = NULL;
01448 ObjectBinaryData(theEnv)->TemplateSlotCount = 0L;
01449 }
01450
01451 space = (sizeof(unsigned) * ObjectBinaryData(theEnv)->SlotNameMapCount);
01452 if (space != 0L)
01453 {
01454 genfree(theEnv,(void *) ObjectBinaryData(theEnv)->MapslotArray,space);
01455 ObjectBinaryData(theEnv)->MapslotArray = NULL;
01456 ObjectBinaryData(theEnv)->SlotNameMapCount = 0L;
01457 }
01458 }
01459
01460 if (ObjectBinaryData(theEnv)->HandlerCount != 0L)
01461 {
01462 for (i = 0L ; i < ObjectBinaryData(theEnv)->HandlerCount ; i++)
01463 DecrementSymbolCount(theEnv,ObjectBinaryData(theEnv)->HandlerArray[i].name);
01464
01465 space = (sizeof(HANDLER) * ObjectBinaryData(theEnv)->HandlerCount);
01466 if (space != 0L)
01467 {
01468 genfree(theEnv,(void *) ObjectBinaryData(theEnv)->HandlerArray,space);
01469 ObjectBinaryData(theEnv)->HandlerArray = NULL;
01470 space = (sizeof(unsigned) * ObjectBinaryData(theEnv)->HandlerCount);
01471 genfree(theEnv,(void *) ObjectBinaryData(theEnv)->MaphandlerArray,space);
01472 ObjectBinaryData(theEnv)->MaphandlerArray = NULL;
01473 ObjectBinaryData(theEnv)->HandlerCount = 0L;
01474 }
01475 }
01476 }
01477
01478 #endif
01479