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 #include "setup.h"
00027
00028 #if DEFGENERIC_CONSTRUCT && (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE)
00029
00030 #include "constant.h"
00031 #include "envrnmnt.h"
00032 #include "memalloc.h"
00033 #include "bload.h"
00034 #include "bsave.h"
00035
00036 #include "cstrcbin.h"
00037
00038 #if OBJECT_SYSTEM
00039 #include "objbin.h"
00040 #endif
00041
00042 #include "genrccom.h"
00043 #include "modulbin.h"
00044
00045 #define _GENRCBIN_SOURCE_
00046 #include "genrcbin.h"
00047
00048 #include "router.h"
00049
00050
00051
00052
00053
00054
00055
00056 #define MethodPointer(i) (((i) == -1L) ? NULL : (DEFMETHOD *) &DefgenericBinaryData(theEnv)->MethodArray[i])
00057 #define RestrictionPointer(i) (((i) == -1L) ? NULL : (RESTRICTION *) &DefgenericBinaryData(theEnv)->RestrictionArray[i])
00058 #define TypePointer(i) (((i) == -1L) ? NULL : (void **) &DefgenericBinaryData(theEnv)->TypeArray[i])
00059
00060 typedef struct bsaveRestriction
00061 {
00062 long types,query;
00063 short tcnt;
00064 } BSAVE_RESTRICTION;
00065
00066 typedef struct bsaveMethod
00067 {
00068 short index;
00069 short restrictionCount,
00070 minRestrictions,maxRestrictions,
00071 localVarCount;
00072 int system;
00073 long restrictions,actions;
00074 } BSAVE_METHOD;
00075
00076 typedef struct bsaveGenericFunc
00077 {
00078 struct bsaveConstructHeader header;
00079 long methods;
00080 short mcnt;
00081 } BSAVE_GENERIC;
00082
00083 typedef struct bsaveGenericModule
00084 {
00085 struct bsaveDefmoduleItemHeader header;
00086 } BSAVE_DEFGENERIC_MODULE;
00087
00088
00089
00090
00091
00092
00093
00094 #if BLOAD_AND_BSAVE
00095
00096 static void BsaveGenericsFind(void *);
00097 static void MarkDefgenericItems(void *,struct constructHeader *,void *);
00098 static void BsaveGenericsExpressions(void *,FILE *);
00099 static void BsaveMethodExpressions(void *,struct constructHeader *,void *);
00100 static void BsaveRestrictionExpressions(void *,struct constructHeader *,void *);
00101 static void BsaveGenerics(void *,FILE *);
00102 static void BsaveDefgenericHeader(void *,struct constructHeader *,void *);
00103 static void BsaveMethods(void *,struct constructHeader *,void *);
00104 static void BsaveMethodRestrictions(void *,struct constructHeader *,void *);
00105 static void BsaveRestrictionTypes(void *,struct constructHeader *,void *);
00106 static void BsaveStorageGenerics(void *,FILE *);
00107
00108 #endif
00109
00110 static void BloadStorageGenerics(void *);
00111 static void BloadGenerics(void *);
00112 static void UpdateGenericModule(void *,void *,long);
00113 static void UpdateGeneric(void *,void *,long);
00114 static void UpdateMethod(void *,void *,long);
00115 static void UpdateRestriction(void *,void *,long);
00116 static void UpdateType(void *,void *,long);
00117 static void ClearBloadGenerics(void *);
00118 static void DeallocateDefgenericBinaryData(void *);
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 globle void SetupGenericsBload(
00137 void *theEnv)
00138 {
00139 AllocateEnvironmentData(theEnv,GENRCBIN_DATA,sizeof(struct defgenericBinaryData),DeallocateDefgenericBinaryData);
00140 #if BLOAD_AND_BSAVE
00141 AddBinaryItem(theEnv,"generic functions",0,BsaveGenericsFind,BsaveGenericsExpressions,
00142 BsaveStorageGenerics,BsaveGenerics,
00143 BloadStorageGenerics,BloadGenerics,
00144 ClearBloadGenerics);
00145 #endif
00146 #if BLOAD || BLOAD_ONLY
00147 AddBinaryItem(theEnv,"generic functions",0,NULL,NULL,NULL,NULL,
00148 BloadStorageGenerics,BloadGenerics,
00149 ClearBloadGenerics);
00150 #endif
00151 }
00152
00153
00154
00155
00156
00157 static void DeallocateDefgenericBinaryData(
00158 void *theEnv)
00159 {
00160 #if (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE) && (! RUN_TIME)
00161 size_t space;
00162
00163 space = DefgenericBinaryData(theEnv)->GenericCount * sizeof(struct defgeneric);
00164 if (space != 0) genfree(theEnv,(void *) DefgenericBinaryData(theEnv)->DefgenericArray,space);
00165
00166 space = DefgenericBinaryData(theEnv)->MethodCount * sizeof(struct method);
00167 if (space != 0) genfree(theEnv,(void *) DefgenericBinaryData(theEnv)->MethodArray,space);
00168
00169 space = DefgenericBinaryData(theEnv)->RestrictionCount * sizeof(struct restriction);
00170 if (space != 0) genfree(theEnv,(void *) DefgenericBinaryData(theEnv)->RestrictionArray,space);
00171
00172 space = DefgenericBinaryData(theEnv)->TypeCount * sizeof(void *);
00173 if (space != 0) genfree(theEnv,(void *) DefgenericBinaryData(theEnv)->TypeArray,space);
00174
00175 space = DefgenericBinaryData(theEnv)->ModuleCount * sizeof(struct defgenericModule);
00176 if (space != 0) genfree(theEnv,(void *) DefgenericBinaryData(theEnv)->ModuleArray,space);
00177 #endif
00178 }
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189 globle void *BloadDefgenericModuleReference(
00190 void *theEnv,
00191 int theIndex)
00192 {
00193 return ((void *) &DefgenericBinaryData(theEnv)->ModuleArray[theIndex]);
00194 }
00195
00196
00197
00198
00199
00200
00201
00202 #if BLOAD_AND_BSAVE
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221 static void BsaveGenericsFind(
00222 void *theEnv)
00223 {
00224 SaveBloadCount(theEnv,DefgenericBinaryData(theEnv)->ModuleCount);
00225 SaveBloadCount(theEnv,DefgenericBinaryData(theEnv)->GenericCount);
00226 SaveBloadCount(theEnv,DefgenericBinaryData(theEnv)->MethodCount);
00227 SaveBloadCount(theEnv,DefgenericBinaryData(theEnv)->RestrictionCount);
00228 SaveBloadCount(theEnv,DefgenericBinaryData(theEnv)->TypeCount);
00229
00230 DefgenericBinaryData(theEnv)->GenericCount = 0L;
00231 DefgenericBinaryData(theEnv)->MethodCount = 0L;
00232 DefgenericBinaryData(theEnv)->RestrictionCount = 0L;
00233 DefgenericBinaryData(theEnv)->TypeCount = 0L;
00234
00235 DefgenericBinaryData(theEnv)->ModuleCount =
00236 DoForAllConstructs(theEnv,MarkDefgenericItems,DefgenericData(theEnv)->DefgenericModuleIndex,
00237 FALSE,NULL);
00238 }
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250 #if WIN_BTC
00251 #pragma argsused
00252 #endif
00253 static void MarkDefgenericItems(
00254 void *theEnv,
00255 struct constructHeader *theDefgeneric,
00256 void *userBuffer)
00257 {
00258 #if MAC_MCW || WIN_MCW || MAC_XCD
00259 #pragma unused(userBuffer)
00260 #endif
00261 DEFGENERIC *gfunc = (DEFGENERIC *) theDefgeneric;
00262 long i,j;
00263 DEFMETHOD *meth;
00264 RESTRICTION *rptr;
00265
00266 MarkConstructHeaderNeededItems(&gfunc->header,DefgenericBinaryData(theEnv)->GenericCount++);
00267 DefgenericBinaryData(theEnv)->MethodCount += (long) gfunc->mcnt;
00268 for (i = 0 ; i < gfunc->mcnt ; i++)
00269 {
00270 meth = &gfunc->methods[i];
00271 ExpressionData(theEnv)->ExpressionCount += ExpressionSize(meth->actions);
00272 MarkNeededItems(theEnv,meth->actions);
00273 DefgenericBinaryData(theEnv)->RestrictionCount += meth->restrictionCount;
00274 for (j = 0 ; j < meth->restrictionCount ; j++)
00275 {
00276 rptr = &meth->restrictions[j];
00277 ExpressionData(theEnv)->ExpressionCount += ExpressionSize(rptr->query);
00278 MarkNeededItems(theEnv,rptr->query);
00279 DefgenericBinaryData(theEnv)->TypeCount += rptr->tcnt;
00280 }
00281 }
00282 }
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293 static void BsaveGenericsExpressions(
00294 void *theEnv,
00295 FILE *fp)
00296 {
00297
00298
00299
00300
00301 DoForAllConstructs(theEnv,BsaveMethodExpressions,DefgenericData(theEnv)->DefgenericModuleIndex,
00302 FALSE,(void *) fp);
00303
00304 DoForAllConstructs(theEnv,BsaveRestrictionExpressions,DefgenericData(theEnv)->DefgenericModuleIndex,
00305 FALSE,(void *) fp);
00306 }
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318 static void BsaveMethodExpressions(
00319 void *theEnv,
00320 struct constructHeader *theDefgeneric,
00321 void *userBuffer)
00322 {
00323 DEFGENERIC *gfunc = (DEFGENERIC *) theDefgeneric;
00324 long i;
00325
00326 for (i = 0 ; i < gfunc->mcnt ; i++)
00327 BsaveExpression(theEnv,gfunc->methods[i].actions,(FILE *) userBuffer);
00328 }
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342 static void BsaveRestrictionExpressions(
00343 void *theEnv,
00344 struct constructHeader *theDefgeneric,
00345 void *userBuffer)
00346 {
00347 DEFGENERIC *gfunc = (DEFGENERIC *) theDefgeneric;
00348 long i,j;
00349 DEFMETHOD *meth;
00350
00351 for (i = 0 ; i < gfunc->mcnt ; i++)
00352 {
00353 meth = &gfunc->methods[i];
00354 for (j = 0 ; j < meth->restrictionCount ; j++)
00355 BsaveExpression(theEnv,meth->restrictions[j].query,(FILE *) userBuffer);
00356 }
00357 }
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369 static void BsaveStorageGenerics(
00370 void *theEnv,
00371 FILE *fp)
00372 {
00373 size_t space;
00374
00375 space = sizeof(long) * 5;
00376 GenWrite((void *) &space,sizeof(size_t),fp);
00377 GenWrite((void *) &DefgenericBinaryData(theEnv)->ModuleCount,sizeof(long),fp);
00378 GenWrite((void *) &DefgenericBinaryData(theEnv)->GenericCount,sizeof(long),fp);
00379 GenWrite((void *) &DefgenericBinaryData(theEnv)->MethodCount,sizeof(long),fp);
00380 GenWrite((void *) &DefgenericBinaryData(theEnv)->RestrictionCount,sizeof(long),fp);
00381 GenWrite((void *) &DefgenericBinaryData(theEnv)->TypeCount,sizeof(long),fp);
00382 }
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398 static void BsaveGenerics(
00399 void *theEnv,
00400 FILE *fp)
00401 {
00402 struct defmodule *theModule;
00403 DEFGENERIC_MODULE *theModuleItem;
00404 size_t space;
00405 BSAVE_DEFGENERIC_MODULE dummy_generic_module;
00406
00407
00408
00409
00410 space = ((unsigned long) DefgenericBinaryData(theEnv)->ModuleCount * sizeof(BSAVE_DEFGENERIC_MODULE)) +
00411 ((unsigned long) DefgenericBinaryData(theEnv)->GenericCount * sizeof(BSAVE_GENERIC)) +
00412 ((unsigned long) DefgenericBinaryData(theEnv)->MethodCount * sizeof(BSAVE_METHOD)) +
00413 ((unsigned long) DefgenericBinaryData(theEnv)->RestrictionCount * sizeof(BSAVE_RESTRICTION)) +
00414 ((unsigned long) DefgenericBinaryData(theEnv)->TypeCount * sizeof(unsigned long));
00415
00416
00417
00418
00419
00420 GenWrite((void *) &space,sizeof(size_t),fp);
00421
00422
00423
00424
00425 DefgenericBinaryData(theEnv)->GenericCount = 0L;
00426 theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL);
00427 while (theModule != NULL)
00428 {
00429 theModuleItem = (DEFGENERIC_MODULE *)
00430 GetModuleItem(theEnv,theModule,FindModuleItem(theEnv,"defgeneric")->moduleIndex);
00431 AssignBsaveDefmdlItemHdrVals(&dummy_generic_module.header,
00432 &theModuleItem->header);
00433 GenWrite((void *) &dummy_generic_module,
00434 sizeof(BSAVE_DEFGENERIC_MODULE),fp);
00435 theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,(void *) theModule);
00436 }
00437
00438
00439
00440
00441
00442 DefgenericBinaryData(theEnv)->MethodCount = 0L;
00443 DoForAllConstructs(theEnv,BsaveDefgenericHeader,DefgenericData(theEnv)->DefgenericModuleIndex,
00444 FALSE,(void *) fp);
00445
00446
00447
00448
00449 DefgenericBinaryData(theEnv)->RestrictionCount = 0L;
00450 DoForAllConstructs(theEnv,BsaveMethods,DefgenericData(theEnv)->DefgenericModuleIndex,
00451 FALSE,(void *) fp);
00452
00453
00454
00455
00456 DefgenericBinaryData(theEnv)->TypeCount = 0L;
00457 DoForAllConstructs(theEnv,BsaveMethodRestrictions,DefgenericData(theEnv)->DefgenericModuleIndex,
00458 FALSE,(void *) fp);
00459
00460
00461
00462
00463 DoForAllConstructs(theEnv,BsaveRestrictionTypes,DefgenericData(theEnv)->DefgenericModuleIndex,
00464 FALSE,(void *) fp);
00465
00466 RestoreBloadCount(theEnv,&DefgenericBinaryData(theEnv)->ModuleCount);
00467 RestoreBloadCount(theEnv,&DefgenericBinaryData(theEnv)->GenericCount);
00468 RestoreBloadCount(theEnv,&DefgenericBinaryData(theEnv)->MethodCount);
00469 RestoreBloadCount(theEnv,&DefgenericBinaryData(theEnv)->RestrictionCount);
00470 RestoreBloadCount(theEnv,&DefgenericBinaryData(theEnv)->TypeCount);
00471 }
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482 static void BsaveDefgenericHeader(
00483 void *theEnv,
00484 struct constructHeader *theDefgeneric,
00485 void *userBuffer)
00486 {
00487 DEFGENERIC *gfunc = (DEFGENERIC *) theDefgeneric;
00488 BSAVE_GENERIC dummy_generic;
00489
00490 AssignBsaveConstructHeaderVals(&dummy_generic.header,&gfunc->header);
00491 dummy_generic.mcnt = gfunc->mcnt;
00492 if (gfunc->methods != NULL)
00493 {
00494 dummy_generic.methods = DefgenericBinaryData(theEnv)->MethodCount;
00495 DefgenericBinaryData(theEnv)->MethodCount += (long) gfunc->mcnt;
00496 }
00497 else
00498 dummy_generic.methods = -1L;
00499 GenWrite((void *) &dummy_generic,(unsigned long) sizeof(BSAVE_GENERIC),(FILE *) userBuffer);
00500 }
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511 static void BsaveMethods(
00512 void *theEnv,
00513 struct constructHeader *theDefgeneric,
00514 void *userBuffer)
00515 {
00516 DEFGENERIC *gfunc = (DEFGENERIC *) theDefgeneric;
00517 DEFMETHOD *meth;
00518 BSAVE_METHOD dummy_method;
00519 long i;
00520
00521 for (i = 0 ; i < gfunc->mcnt ; i++)
00522 {
00523 meth = &gfunc->methods[i];
00524 dummy_method.index = meth->index;
00525 dummy_method.restrictionCount = meth->restrictionCount;
00526 dummy_method.minRestrictions = meth->minRestrictions;
00527 dummy_method.maxRestrictions = meth->maxRestrictions;
00528 dummy_method.localVarCount = meth->localVarCount;
00529 dummy_method.system = meth->system;
00530 if (meth->restrictions != NULL)
00531 {
00532 dummy_method.restrictions = DefgenericBinaryData(theEnv)->RestrictionCount;
00533 DefgenericBinaryData(theEnv)->RestrictionCount += meth->restrictionCount;
00534 }
00535 else
00536 dummy_method.restrictions = -1L;
00537 if (meth->actions != NULL)
00538 {
00539 dummy_method.actions = ExpressionData(theEnv)->ExpressionCount;
00540 ExpressionData(theEnv)->ExpressionCount += ExpressionSize(meth->actions);
00541 }
00542 else
00543 dummy_method.actions = -1L;
00544 GenWrite((void *) &dummy_method,sizeof(BSAVE_METHOD),(FILE *) userBuffer);
00545 }
00546 }
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557 static void BsaveMethodRestrictions(
00558 void *theEnv,
00559 struct constructHeader *theDefgeneric,
00560 void *userBuffer)
00561 {
00562 DEFGENERIC *gfunc = (DEFGENERIC *) theDefgeneric;
00563 BSAVE_RESTRICTION dummy_restriction;
00564 RESTRICTION *rptr;
00565 short i,j;
00566
00567 for (i = 0 ; i < gfunc->mcnt ; i++)
00568 {
00569 for (j = 0 ; j < gfunc->methods[i].restrictionCount ; j++)
00570 {
00571 rptr = &gfunc->methods[i].restrictions[j];
00572 dummy_restriction.tcnt = rptr->tcnt;
00573 if (rptr->types != NULL)
00574 {
00575 dummy_restriction.types = DefgenericBinaryData(theEnv)->TypeCount;
00576 DefgenericBinaryData(theEnv)->TypeCount += rptr->tcnt;
00577 }
00578 else
00579 dummy_restriction.types = -1L;
00580 if (rptr->query != NULL)
00581 {
00582 dummy_restriction.query = ExpressionData(theEnv)->ExpressionCount;
00583 ExpressionData(theEnv)->ExpressionCount += ExpressionSize(rptr->query);
00584 }
00585 else
00586 dummy_restriction.query = -1L;
00587 GenWrite((void *) &dummy_restriction,
00588 sizeof(BSAVE_RESTRICTION),(FILE *) userBuffer);
00589 }
00590 }
00591 }
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602 #if WIN_BTC
00603 #pragma argsused
00604 #endif
00605 static void BsaveRestrictionTypes(
00606 void *theEnv,
00607 struct constructHeader *theDefgeneric,
00608 void *userBuffer)
00609 {
00610 DEFGENERIC *gfunc = (DEFGENERIC *) theDefgeneric;
00611 long dummy_type;
00612 RESTRICTION *rptr;
00613 short i,j,k;
00614 #if MAC_MCW || WIN_MCW || MAC_XCD
00615 #pragma unused(theEnv)
00616 #endif
00617
00618 for (i = 0 ; i < gfunc->mcnt ; i++)
00619 {
00620 for (j = 0 ; j < gfunc->methods[i].restrictionCount ; j++)
00621 {
00622 rptr = &gfunc->methods[i].restrictions[j];
00623 for (k = 0 ; k < rptr->tcnt ; k++)
00624 {
00625 #if OBJECT_SYSTEM
00626 dummy_type = DefclassIndex(rptr->types[k]);
00627 #else
00628 dummy_type = (long) ((INTEGER_HN *) rptr->types[k])->contents;
00629 #endif
00630 GenWrite(&dummy_type,sizeof(long),(FILE *) userBuffer);
00631 }
00632 }
00633 }
00634 }
00635
00636 #endif
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648 static void BloadStorageGenerics(
00649 void *theEnv)
00650 {
00651 size_t space;
00652 long counts[5];
00653
00654 GenReadBinary(theEnv,(void *) &space,sizeof(size_t));
00655 if (space == 0L)
00656 return;
00657 GenReadBinary(theEnv,(void *) counts,space);
00658 DefgenericBinaryData(theEnv)->ModuleCount = counts[0];
00659 DefgenericBinaryData(theEnv)->GenericCount = counts[1];
00660 DefgenericBinaryData(theEnv)->MethodCount = counts[2];
00661 DefgenericBinaryData(theEnv)->RestrictionCount = counts[3];
00662 DefgenericBinaryData(theEnv)->TypeCount = counts[4];
00663 if (DefgenericBinaryData(theEnv)->ModuleCount != 0L)
00664 {
00665 space = (sizeof(DEFGENERIC_MODULE) * DefgenericBinaryData(theEnv)->ModuleCount);
00666 DefgenericBinaryData(theEnv)->ModuleArray = (DEFGENERIC_MODULE *) genalloc(theEnv,space);
00667 }
00668 else
00669 return;
00670 if (DefgenericBinaryData(theEnv)->GenericCount != 0L)
00671 {
00672 space = (sizeof(DEFGENERIC) * DefgenericBinaryData(theEnv)->GenericCount);
00673 DefgenericBinaryData(theEnv)->DefgenericArray = (DEFGENERIC *) genalloc(theEnv,space);
00674 }
00675 else
00676 return;
00677 if (DefgenericBinaryData(theEnv)->MethodCount != 0L)
00678 {
00679 space = (sizeof(DEFMETHOD) * DefgenericBinaryData(theEnv)->MethodCount);
00680 DefgenericBinaryData(theEnv)->MethodArray = (DEFMETHOD *) genalloc(theEnv,space);
00681 }
00682 else
00683 return;
00684 if (DefgenericBinaryData(theEnv)->RestrictionCount != 0L)
00685 {
00686 space = (sizeof(RESTRICTION) * DefgenericBinaryData(theEnv)->RestrictionCount);
00687 DefgenericBinaryData(theEnv)->RestrictionArray = (RESTRICTION *) genalloc(theEnv,space);
00688 }
00689 else
00690 return;
00691 if (DefgenericBinaryData(theEnv)->TypeCount != 0L)
00692 {
00693 space = (sizeof(void *) * DefgenericBinaryData(theEnv)->TypeCount);
00694 DefgenericBinaryData(theEnv)->TypeArray = (void * *) genalloc(theEnv,space);
00695 }
00696 }
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714 static void BloadGenerics(
00715 void *theEnv)
00716 {
00717 size_t space;
00718
00719 GenReadBinary(theEnv,(void *) &space,sizeof(size_t));
00720 if (DefgenericBinaryData(theEnv)->ModuleCount == 0L)
00721 return;
00722 BloadandRefresh(theEnv,DefgenericBinaryData(theEnv)->ModuleCount,sizeof(BSAVE_DEFGENERIC_MODULE),UpdateGenericModule);
00723 if (DefgenericBinaryData(theEnv)->GenericCount == 0L)
00724 return;
00725 BloadandRefresh(theEnv,DefgenericBinaryData(theEnv)->GenericCount,sizeof(BSAVE_GENERIC),UpdateGeneric);
00726 BloadandRefresh(theEnv,DefgenericBinaryData(theEnv)->MethodCount,sizeof(BSAVE_METHOD),UpdateMethod);
00727 BloadandRefresh(theEnv,DefgenericBinaryData(theEnv)->RestrictionCount,sizeof(BSAVE_RESTRICTION),UpdateRestriction);
00728 BloadandRefresh(theEnv,DefgenericBinaryData(theEnv)->TypeCount,sizeof(long),UpdateType);
00729 }
00730
00731
00732
00733
00734 static void UpdateGenericModule(
00735 void *theEnv,
00736 void *buf,
00737 long obji)
00738 {
00739 BSAVE_DEFGENERIC_MODULE *bdptr;
00740
00741 bdptr = (BSAVE_DEFGENERIC_MODULE *) buf;
00742 UpdateDefmoduleItemHeader(theEnv,&bdptr->header,&DefgenericBinaryData(theEnv)->ModuleArray[obji].header,
00743 (int) sizeof(DEFGENERIC),(void *) DefgenericBinaryData(theEnv)->DefgenericArray);
00744 }
00745
00746 static void UpdateGeneric(
00747 void *theEnv,
00748 void *buf,
00749 long obji)
00750 {
00751 BSAVE_GENERIC *bgp;
00752 DEFGENERIC *gp;
00753
00754 bgp = (BSAVE_GENERIC *) buf;
00755 gp = (DEFGENERIC *) &DefgenericBinaryData(theEnv)->DefgenericArray[obji];
00756
00757 UpdateConstructHeader(theEnv,&bgp->header,&gp->header,
00758 (int) sizeof(DEFGENERIC_MODULE),(void *) DefgenericBinaryData(theEnv)->ModuleArray,
00759 (int) sizeof(DEFGENERIC),(void *) DefgenericBinaryData(theEnv)->DefgenericArray);
00760 DefgenericBinaryData(theEnv)->DefgenericArray[obji].busy = 0;
00761 #if DEBUGGING_FUNCTIONS
00762 DefgenericBinaryData(theEnv)->DefgenericArray[obji].trace = DefgenericData(theEnv)->WatchGenerics;
00763 #endif
00764 DefgenericBinaryData(theEnv)->DefgenericArray[obji].methods = MethodPointer(bgp->methods);
00765 DefgenericBinaryData(theEnv)->DefgenericArray[obji].mcnt = bgp->mcnt;
00766 DefgenericBinaryData(theEnv)->DefgenericArray[obji].new_index = 0;
00767 }
00768
00769 static void UpdateMethod(
00770 void *theEnv,
00771 void *buf,
00772 long obji)
00773 {
00774 BSAVE_METHOD *bmth;
00775
00776 bmth = (BSAVE_METHOD *) buf;
00777 DefgenericBinaryData(theEnv)->MethodArray[obji].index = bmth->index;
00778 DefgenericBinaryData(theEnv)->MethodArray[obji].busy = 0;
00779 #if DEBUGGING_FUNCTIONS
00780 DefgenericBinaryData(theEnv)->MethodArray[obji].trace = DefgenericData(theEnv)->WatchMethods;
00781 #endif
00782 DefgenericBinaryData(theEnv)->MethodArray[obji].restrictionCount = bmth->restrictionCount;
00783 DefgenericBinaryData(theEnv)->MethodArray[obji].minRestrictions = bmth->minRestrictions;
00784 DefgenericBinaryData(theEnv)->MethodArray[obji].maxRestrictions = bmth->maxRestrictions;
00785 DefgenericBinaryData(theEnv)->MethodArray[obji].localVarCount = bmth->localVarCount;
00786 DefgenericBinaryData(theEnv)->MethodArray[obji].system = bmth->system;
00787 DefgenericBinaryData(theEnv)->MethodArray[obji].restrictions = RestrictionPointer(bmth->restrictions);
00788 DefgenericBinaryData(theEnv)->MethodArray[obji].actions = ExpressionPointer(bmth->actions);
00789 DefgenericBinaryData(theEnv)->MethodArray[obji].ppForm = NULL;
00790 DefgenericBinaryData(theEnv)->MethodArray[obji].usrData = NULL;
00791 }
00792
00793 static void UpdateRestriction(
00794 void *theEnv,
00795 void *buf,
00796 long obji)
00797 {
00798 BSAVE_RESTRICTION *brp;
00799
00800 brp = (BSAVE_RESTRICTION *) buf;
00801 DefgenericBinaryData(theEnv)->RestrictionArray[obji].tcnt = brp->tcnt;
00802 DefgenericBinaryData(theEnv)->RestrictionArray[obji].types = TypePointer(brp->types);
00803 DefgenericBinaryData(theEnv)->RestrictionArray[obji].query = ExpressionPointer(brp->query);
00804 }
00805
00806 static void UpdateType(
00807 void *theEnv,
00808 void *buf,
00809 long obji)
00810 {
00811 #if OBJECT_SYSTEM
00812 DefgenericBinaryData(theEnv)->TypeArray[obji] = (void *) DefclassPointer(* (long *) buf);
00813 #else
00814 if ((* (long *) buf) > (long) INSTANCE_TYPE_CODE)
00815 {
00816 PrintWarningID(theEnv,"GENRCBIN",1,FALSE);
00817 EnvPrintRouter(theEnv,WWARNING,"COOL not installed! User-defined class\n");
00818 EnvPrintRouter(theEnv,WWARNING," in method restriction substituted with OBJECT.\n");
00819 DefgenericBinaryData(theEnv)->TypeArray[obji] = (void *) EnvAddLong(theEnv,(long long) OBJECT_TYPE_CODE);
00820 }
00821 else
00822 DefgenericBinaryData(theEnv)->TypeArray[obji] = (void *) EnvAddLong(theEnv,* (long *) buf);
00823 IncrementIntegerCount((INTEGER_HN *) DefgenericBinaryData(theEnv)->TypeArray[obji]);
00824 #endif
00825 }
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837 static void ClearBloadGenerics(
00838 void *theEnv)
00839 {
00840 register long i;
00841 size_t space;
00842
00843 space = (sizeof(DEFGENERIC_MODULE) * DefgenericBinaryData(theEnv)->ModuleCount);
00844 if (space == 0L)
00845 return;
00846 genfree(theEnv,(void *) DefgenericBinaryData(theEnv)->ModuleArray,space);
00847 DefgenericBinaryData(theEnv)->ModuleArray = NULL;
00848 DefgenericBinaryData(theEnv)->ModuleCount = 0L;
00849
00850 for (i = 0 ; i < DefgenericBinaryData(theEnv)->GenericCount ; i++)
00851 UnmarkConstructHeader(theEnv,&DefgenericBinaryData(theEnv)->DefgenericArray[i].header);
00852
00853 space = (sizeof(DEFGENERIC) * DefgenericBinaryData(theEnv)->GenericCount);
00854 if (space == 0L)
00855 return;
00856 genfree(theEnv,(void *) DefgenericBinaryData(theEnv)->DefgenericArray,space);
00857 DefgenericBinaryData(theEnv)->DefgenericArray = NULL;
00858 DefgenericBinaryData(theEnv)->GenericCount = 0L;
00859
00860 space = (sizeof(DEFMETHOD) * DefgenericBinaryData(theEnv)->MethodCount);
00861 if (space == 0L)
00862 return;
00863 genfree(theEnv,(void *) DefgenericBinaryData(theEnv)->MethodArray,space);
00864 DefgenericBinaryData(theEnv)->MethodArray = NULL;
00865 DefgenericBinaryData(theEnv)->MethodCount = 0L;
00866
00867 space = (sizeof(RESTRICTION) * DefgenericBinaryData(theEnv)->RestrictionCount);
00868 if (space == 0L)
00869 return;
00870 genfree(theEnv,(void *) DefgenericBinaryData(theEnv)->RestrictionArray,space);
00871 DefgenericBinaryData(theEnv)->RestrictionArray = NULL;
00872 DefgenericBinaryData(theEnv)->RestrictionCount = 0L;
00873
00874 #if ! OBJECT_SYSTEM
00875 for (i = 0 ; i < DefgenericBinaryData(theEnv)->TypeCount ; i++)
00876 DecrementIntegerCount(theEnv,(INTEGER_HN *) DefgenericBinaryData(theEnv)->TypeArray[i]);
00877 #endif
00878 space = (sizeof(void *) * DefgenericBinaryData(theEnv)->TypeCount);
00879 if (space == 0L)
00880 return;
00881 genfree(theEnv,(void *) DefgenericBinaryData(theEnv)->TypeArray,space);
00882 DefgenericBinaryData(theEnv)->TypeArray = NULL;
00883 DefgenericBinaryData(theEnv)->TypeCount = 0L;
00884 }
00885
00886 #endif
00887