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
00031 #include "setup.h"
00032
00033 #if OBJECT_SYSTEM && (! BLOAD_ONLY) && (! RUN_TIME)
00034
00035 #include <string.h>
00036
00037 #include "classcom.h"
00038 #include "classfun.h"
00039 #include "cstrnchk.h"
00040 #include "cstrnpsr.h"
00041 #include "cstrnutl.h"
00042 #include "default.h"
00043 #include "envrnmnt.h"
00044 #include "insfun.h"
00045 #include "memalloc.h"
00046 #include "prntutil.h"
00047 #include "router.h"
00048 #include "scanner.h"
00049
00050 #define _CLSLTPSR_SOURCE_
00051 #include "clsltpsr.h"
00052
00053
00054
00055
00056
00057
00058 #define DEFAULT_FACET "default"
00059 #define DYNAMIC_FACET "default-dynamic"
00060 #define VARIABLE_VAR "VARIABLE"
00061
00062 #define STORAGE_FACET "storage"
00063 #define SLOT_SHARE_RLN "shared"
00064 #define SLOT_LOCAL_RLN "local"
00065
00066 #define ACCESS_FACET "access"
00067 #define SLOT_RDONLY_RLN "read-only"
00068 #define SLOT_RDWRT_RLN "read-write"
00069 #define SLOT_INIT_RLN "initialize-only"
00070
00071 #define PROPAGATION_FACET "propagation"
00072 #define SLOT_NO_INH_RLN "no-inherit"
00073 #define SLOT_INH_RLN "inherit"
00074
00075 #define SOURCE_FACET "source"
00076 #define SLOT_COMPOSITE_RLN "composite"
00077 #define SLOT_EXCLUSIVE_RLN "exclusive"
00078
00079 #define MATCH_FACET MATCH_RLN
00080 #define SLOT_REACTIVE_RLN REACTIVE_RLN
00081 #define SLOT_NONREACTIVE_RLN NONREACTIVE_RLN
00082
00083 #define VISIBILITY_FACET "visibility"
00084 #define SLOT_PUBLIC_RLN "public"
00085 #define SLOT_PRIVATE_RLN "private"
00086
00087 #define CREATE_ACCESSOR_FACET "create-accessor"
00088 #define SLOT_READ_RLN "read"
00089 #define SLOT_WRITE_RLN "write"
00090 #define SLOT_NONE_RLN "NONE"
00091
00092 #define OVERRIDE_MSG_FACET "override-message"
00093 #define SLOT_DEFAULT_RLN "DEFAULT"
00094
00095 #define STORAGE_BIT 0
00096 #define FIELD_BIT 1
00097 #define ACCESS_BIT 2
00098 #define PROPAGATION_BIT 3
00099 #define SOURCE_BIT 4
00100 #define MATCH_BIT 5
00101 #define DEFAULT_BIT 6
00102 #define DEFAULT_DYNAMIC_BIT 7
00103 #define VISIBILITY_BIT 8
00104 #define CREATE_ACCESSOR_BIT 9
00105 #define OVERRIDE_MSG_BIT 10
00106
00107
00108
00109
00110
00111
00112
00113 static SLOT_DESC *NewSlot(void *,SYMBOL_HN *);
00114 static TEMP_SLOT_LINK *InsertSlot(void *,TEMP_SLOT_LINK *,SLOT_DESC *);
00115 static int ParseSimpleFacet(void *,char *,char*,char *,int,char *,char *,char *,char *,SYMBOL_HN **);
00116 static intBool ParseDefaultFacet(void *,char *,char *,SLOT_DESC *);
00117 static void BuildCompositeFacets(void *,SLOT_DESC *,PACKED_CLASS_LINKS *,char *,
00118 CONSTRAINT_PARSE_RECORD *);
00119 static intBool CheckForFacetConflicts(void *,SLOT_DESC *,CONSTRAINT_PARSE_RECORD *);
00120 static intBool EvaluateSlotDefaultValue(void *,SLOT_DESC *,char *);
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147 globle TEMP_SLOT_LINK *ParseSlot(
00148 void *theEnv,
00149 char *readSource,
00150 TEMP_SLOT_LINK *slist,
00151 PACKED_CLASS_LINKS *preclist,
00152 int multiSlot,
00153 int fieldSpecified)
00154 {
00155 SLOT_DESC *slot;
00156 CONSTRAINT_PARSE_RECORD parsedConstraint;
00157 char specbits[2];
00158 int rtnCode;
00159 SYMBOL_HN *newOverrideMsg;
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 SavePPBuffer(theEnv," ");
00177 specbits[0] = specbits[1] = '\0';
00178 GetToken(theEnv,readSource,&DefclassData(theEnv)->ObjectParseToken);
00179 if (GetType(DefclassData(theEnv)->ObjectParseToken) != SYMBOL)
00180 {
00181 DeleteSlots(theEnv,slist);
00182 SyntaxErrorMessage(theEnv,"defclass slot");
00183 return(NULL);
00184 }
00185 if ((DefclassData(theEnv)->ObjectParseToken.value == (void *) DefclassData(theEnv)->ISA_SYMBOL) ||
00186 (DefclassData(theEnv)->ObjectParseToken.value == (void *) DefclassData(theEnv)->NAME_SYMBOL))
00187 {
00188 DeleteSlots(theEnv,slist);
00189 SyntaxErrorMessage(theEnv,"defclass slot");
00190 return(NULL);
00191 }
00192 slot = NewSlot(theEnv,(SYMBOL_HN *) GetValue(DefclassData(theEnv)->ObjectParseToken));
00193 slist = InsertSlot(theEnv,slist,slot);
00194 if (slist == NULL)
00195 return(NULL);
00196 if (multiSlot)
00197 slot->multiple = TRUE;
00198 if (fieldSpecified)
00199 SetBitMap(specbits,FIELD_BIT);
00200 GetToken(theEnv,readSource,&DefclassData(theEnv)->ObjectParseToken);
00201 IncrementIndentDepth(theEnv,3);
00202 InitializeConstraintParseRecord(&parsedConstraint);
00203 while (GetType(DefclassData(theEnv)->ObjectParseToken) == LPAREN)
00204 {
00205 PPBackup(theEnv);
00206 PPCRAndIndent(theEnv);
00207 SavePPBuffer(theEnv,"(");
00208 GetToken(theEnv,readSource,&DefclassData(theEnv)->ObjectParseToken);
00209 if (GetType(DefclassData(theEnv)->ObjectParseToken) != SYMBOL)
00210 {
00211 SyntaxErrorMessage(theEnv,"defclass slot");
00212 goto ParseSlotError;
00213 }
00214 else if (strcmp(DOToString(DefclassData(theEnv)->ObjectParseToken),DEFAULT_FACET) == 0)
00215 {
00216 if (ParseDefaultFacet(theEnv,readSource,specbits,slot) == FALSE)
00217 goto ParseSlotError;
00218 }
00219 else if (strcmp(DOToString(DefclassData(theEnv)->ObjectParseToken),DYNAMIC_FACET) == 0)
00220 {
00221 SetBitMap(specbits,DEFAULT_DYNAMIC_BIT);
00222 if (ParseDefaultFacet(theEnv,readSource,specbits,slot) == FALSE)
00223 goto ParseSlotError;
00224 }
00225 else if (strcmp(DOToString(DefclassData(theEnv)->ObjectParseToken),ACCESS_FACET) == 0)
00226 {
00227 rtnCode = ParseSimpleFacet(theEnv,readSource,specbits,ACCESS_FACET,ACCESS_BIT,
00228 SLOT_RDWRT_RLN,SLOT_RDONLY_RLN,SLOT_INIT_RLN,
00229 NULL,NULL);
00230 if (rtnCode == -1)
00231 goto ParseSlotError;
00232 else if (rtnCode == 1)
00233 slot->noWrite = 1;
00234 else if (rtnCode == 2)
00235 slot->initializeOnly = 1;
00236 }
00237 else if (strcmp(DOToString(DefclassData(theEnv)->ObjectParseToken),STORAGE_FACET) == 0)
00238 {
00239 rtnCode = ParseSimpleFacet(theEnv,readSource,specbits,STORAGE_FACET,STORAGE_BIT,
00240 SLOT_LOCAL_RLN,SLOT_SHARE_RLN,NULL,NULL,NULL);
00241 if (rtnCode == -1)
00242 goto ParseSlotError;
00243 slot->shared = rtnCode;
00244 }
00245 else if (strcmp(DOToString(DefclassData(theEnv)->ObjectParseToken),PROPAGATION_FACET) == 0)
00246 {
00247 rtnCode = ParseSimpleFacet(theEnv,readSource,specbits,PROPAGATION_FACET,PROPAGATION_BIT,
00248 SLOT_INH_RLN,SLOT_NO_INH_RLN,NULL,NULL,NULL);
00249 if (rtnCode == -1)
00250 goto ParseSlotError;
00251 slot->noInherit = rtnCode;
00252 }
00253 else if (strcmp(DOToString(DefclassData(theEnv)->ObjectParseToken),SOURCE_FACET) == 0)
00254 {
00255 rtnCode = ParseSimpleFacet(theEnv,readSource,specbits,SOURCE_FACET,SOURCE_BIT,
00256 SLOT_EXCLUSIVE_RLN,SLOT_COMPOSITE_RLN,NULL,NULL,NULL);
00257 if (rtnCode == -1)
00258 goto ParseSlotError;
00259 slot->composite = rtnCode;
00260 }
00261 #if DEFRULE_CONSTRUCT
00262 else if (strcmp(DOToString(DefclassData(theEnv)->ObjectParseToken),MATCH_FACET) == 0)
00263 {
00264 rtnCode = ParseSimpleFacet(theEnv,readSource,specbits,MATCH_FACET,MATCH_BIT,
00265 SLOT_NONREACTIVE_RLN,SLOT_REACTIVE_RLN,NULL,NULL,NULL);
00266 if (rtnCode == -1)
00267 goto ParseSlotError;
00268 slot->reactive = rtnCode;
00269 }
00270 #endif
00271 else if (strcmp(DOToString(DefclassData(theEnv)->ObjectParseToken),VISIBILITY_FACET) == 0)
00272 {
00273 rtnCode = ParseSimpleFacet(theEnv,readSource,specbits,VISIBILITY_FACET,VISIBILITY_BIT,
00274 SLOT_PRIVATE_RLN,SLOT_PUBLIC_RLN,NULL,NULL,NULL);
00275 if (rtnCode == -1)
00276 goto ParseSlotError;
00277 slot->publicVisibility = rtnCode;
00278 }
00279 else if (strcmp(DOToString(DefclassData(theEnv)->ObjectParseToken),CREATE_ACCESSOR_FACET) == 0)
00280 {
00281 rtnCode = ParseSimpleFacet(theEnv,readSource,specbits,CREATE_ACCESSOR_FACET,
00282 CREATE_ACCESSOR_BIT,
00283 SLOT_READ_RLN,SLOT_WRITE_RLN,SLOT_RDWRT_RLN,
00284 SLOT_NONE_RLN,NULL);
00285 if (rtnCode == -1)
00286 goto ParseSlotError;
00287 if ((rtnCode == 0) || (rtnCode == 2))
00288 slot->createReadAccessor = TRUE;
00289 if ((rtnCode == 1) || (rtnCode == 2))
00290 slot->createWriteAccessor = TRUE;
00291 }
00292 else if (strcmp(DOToString(DefclassData(theEnv)->ObjectParseToken),OVERRIDE_MSG_FACET) == 0)
00293 {
00294 rtnCode = ParseSimpleFacet(theEnv,readSource,specbits,OVERRIDE_MSG_FACET,OVERRIDE_MSG_BIT,
00295 NULL,NULL,NULL,SLOT_DEFAULT_RLN,&newOverrideMsg);
00296 if (rtnCode == -1)
00297 goto ParseSlotError;
00298 if (rtnCode == 4)
00299 {
00300 DecrementSymbolCount(theEnv,slot->overrideMessage);
00301 slot->overrideMessage = newOverrideMsg;
00302 IncrementSymbolCount(slot->overrideMessage);
00303 }
00304 slot->overrideMessageSpecified = TRUE;
00305 }
00306 else if (StandardConstraint(DOToString(DefclassData(theEnv)->ObjectParseToken)))
00307 {
00308 if (ParseStandardConstraint(theEnv,readSource,DOToString(DefclassData(theEnv)->ObjectParseToken),
00309 slot->constraint,&parsedConstraint,TRUE) == FALSE)
00310 goto ParseSlotError;
00311 }
00312 else
00313 {
00314 SyntaxErrorMessage(theEnv,"defclass slot");
00315 goto ParseSlotError;
00316 }
00317 GetToken(theEnv,readSource,&DefclassData(theEnv)->ObjectParseToken);
00318 }
00319 if (GetType(DefclassData(theEnv)->ObjectParseToken) != RPAREN)
00320 {
00321 SyntaxErrorMessage(theEnv,"defclass slot");
00322 goto ParseSlotError;
00323 }
00324
00325 if (DefclassData(theEnv)->ClassDefaultsMode == CONVENIENCE_MODE)
00326 {
00327 if (! TestBitMap(specbits,CREATE_ACCESSOR_BIT))
00328 {
00329 slot->createReadAccessor = TRUE;
00330
00331 if (! slot->noWrite)
00332 { slot->createWriteAccessor = TRUE; }
00333 }
00334 }
00335
00336 if (slot->composite)
00337 BuildCompositeFacets(theEnv,slot,preclist,specbits,&parsedConstraint);
00338 if (CheckForFacetConflicts(theEnv,slot,&parsedConstraint) == FALSE)
00339 goto ParseSlotError;
00340 if (CheckConstraintParseConflicts(theEnv,slot->constraint) == FALSE)
00341 goto ParseSlotError;
00342 if (EvaluateSlotDefaultValue(theEnv,slot,specbits) == FALSE)
00343 goto ParseSlotError;
00344 if ((slot->dynamicDefault == 0) && (slot->noWrite == 1) &&
00345 (slot->initializeOnly == 0))
00346 slot->shared = 1;
00347 slot->constraint = AddConstraint(theEnv,slot->constraint);
00348 DecrementIndentDepth(theEnv,3);
00349 return(slist);
00350
00351 ParseSlotError:
00352 DecrementIndentDepth(theEnv,3);
00353 DeleteSlots(theEnv,slist);
00354 return(NULL);
00355 }
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366 globle void DeleteSlots(
00367 void *theEnv,
00368 TEMP_SLOT_LINK *slots)
00369 {
00370 TEMP_SLOT_LINK *stmp;
00371
00372 while (slots != NULL)
00373 {
00374 stmp = slots;
00375 slots = slots->nxt;
00376 DeleteSlotName(theEnv,stmp->desc->slotName);
00377 DecrementSymbolCount(theEnv,stmp->desc->overrideMessage);
00378 RemoveConstraint(theEnv,stmp->desc->constraint);
00379 if (stmp->desc->dynamicDefault == 1)
00380 {
00381 ExpressionDeinstall(theEnv,(EXPRESSION *) stmp->desc->defaultValue);
00382 ReturnPackedExpression(theEnv,(EXPRESSION *) stmp->desc->defaultValue);
00383 }
00384 else if (stmp->desc->defaultValue != NULL)
00385 {
00386 ValueDeinstall(theEnv,(DATA_OBJECT *) stmp->desc->defaultValue);
00387 rtn_struct(theEnv,dataObject,stmp->desc->defaultValue);
00388 }
00389 rtn_struct(theEnv,slotDescriptor,stmp->desc);
00390 rtn_struct(theEnv,tempSlotLink,stmp);
00391 }
00392 }
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409 static SLOT_DESC *NewSlot(
00410 void *theEnv,
00411 SYMBOL_HN *name)
00412 {
00413 SLOT_DESC *slot;
00414
00415 slot = get_struct(theEnv,slotDescriptor);
00416 slot->dynamicDefault = 1;
00417 slot->defaultSpecified = 0;
00418 slot->noDefault = 0;
00419 #if DEFRULE_CONSTRUCT
00420 slot->reactive = 1;
00421 #endif
00422 slot->noInherit = 0;
00423 slot->noWrite = 0;
00424 slot->initializeOnly = 0;
00425 slot->shared = 0;
00426 slot->multiple = 0;
00427 slot->composite = 0;
00428 slot->sharedCount = 0;
00429 slot->publicVisibility = 0;
00430 slot->createReadAccessor = FALSE;
00431 slot->createWriteAccessor = FALSE;
00432 slot->overrideMessageSpecified = 0;
00433 slot->cls = NULL;
00434 slot->defaultValue = NULL;
00435 slot->constraint = GetConstraintRecord(theEnv);
00436 slot->slotName = AddSlotName(theEnv,name,0,FALSE);
00437 slot->overrideMessage = slot->slotName->putHandlerName;
00438 IncrementSymbolCount(slot->overrideMessage);
00439 return(slot);
00440 }
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453 static TEMP_SLOT_LINK *InsertSlot(
00454 void *theEnv,
00455 TEMP_SLOT_LINK *slist,
00456 SLOT_DESC *slot)
00457 {
00458 TEMP_SLOT_LINK *stmp,*sprv,*tmp;
00459
00460 tmp = get_struct(theEnv,tempSlotLink);
00461 tmp->desc = slot;
00462 tmp->nxt = NULL;
00463 if (slist == NULL)
00464 slist = tmp;
00465 else
00466 {
00467 stmp = slist;
00468 sprv = NULL;
00469 while (stmp != NULL)
00470 {
00471 if (stmp->desc->slotName == slot->slotName)
00472 {
00473 tmp->nxt = slist;
00474 DeleteSlots(theEnv,tmp);
00475 PrintErrorID(theEnv,"CLSLTPSR",1,FALSE);
00476 EnvPrintRouter(theEnv,WERROR,"Duplicate slots not allowed.\n");
00477 return(NULL);
00478 }
00479 sprv = stmp;
00480 stmp = stmp->nxt;
00481 }
00482 sprv->nxt = tmp;
00483 }
00484 return(slist);
00485 }
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520 static int ParseSimpleFacet(
00521 void *theEnv,
00522 char *readSource,
00523 char *specbits,
00524 char *facetName,
00525 int testBit,
00526 char *clearRelation,
00527 char *setRelation,
00528 char *alternateRelation,
00529 char *varRelation,
00530 SYMBOL_HN **facetSymbolicValue)
00531 {
00532 int rtnCode;
00533
00534 if (TestBitMap(specbits,testBit))
00535 {
00536 PrintErrorID(theEnv,"CLSLTPSR",2,FALSE);
00537 EnvPrintRouter(theEnv,WERROR,facetName);
00538 EnvPrintRouter(theEnv,WERROR," facet already specified.\n");
00539 return(-1);
00540 }
00541 SetBitMap(specbits,testBit);
00542 SavePPBuffer(theEnv," ");
00543 GetToken(theEnv,readSource,&DefclassData(theEnv)->ObjectParseToken);
00544
00545
00546
00547
00548 if (DefclassData(theEnv)->ObjectParseToken.type == SF_VARIABLE)
00549 {
00550 if ((varRelation == NULL) ? FALSE :
00551 (strcmp(DOToString(DefclassData(theEnv)->ObjectParseToken),varRelation) == 0))
00552 rtnCode = 3;
00553 else
00554 goto ParseSimpleFacetError;
00555 }
00556 else
00557 {
00558 if (DefclassData(theEnv)->ObjectParseToken.type != SYMBOL)
00559 goto ParseSimpleFacetError;
00560
00561
00562
00563
00564
00565 if (facetSymbolicValue == NULL)
00566 {
00567 if (strcmp(DOToString(DefclassData(theEnv)->ObjectParseToken),clearRelation) == 0)
00568 rtnCode = 0;
00569 else if (strcmp(DOToString(DefclassData(theEnv)->ObjectParseToken),setRelation) == 0)
00570 rtnCode = 1;
00571 else if ((alternateRelation == NULL) ? FALSE :
00572 (strcmp(DOToString(DefclassData(theEnv)->ObjectParseToken),alternateRelation) == 0))
00573 rtnCode = 2;
00574 else
00575 goto ParseSimpleFacetError;
00576 }
00577 else
00578 {
00579 rtnCode = 4;
00580 *facetSymbolicValue = (SYMBOL_HN *) DefclassData(theEnv)->ObjectParseToken.value;
00581 }
00582 }
00583 GetToken(theEnv,readSource,&DefclassData(theEnv)->ObjectParseToken);
00584 if (DefclassData(theEnv)->ObjectParseToken.type != RPAREN)
00585 goto ParseSimpleFacetError;
00586 return(rtnCode);
00587
00588 ParseSimpleFacetError:
00589 SyntaxErrorMessage(theEnv,"slot facet");
00590 return(-1);
00591 }
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605 static intBool ParseDefaultFacet(
00606 void *theEnv,
00607 char *readSource,
00608 char *specbits,
00609 SLOT_DESC *slot)
00610 {
00611 EXPRESSION *tmp;
00612 int error,noneSpecified,deriveSpecified;
00613
00614 if (TestBitMap(specbits,DEFAULT_BIT))
00615 {
00616 PrintErrorID(theEnv,"CLSLTPSR",2,FALSE);
00617 EnvPrintRouter(theEnv,WERROR,"default facet already specified.\n");
00618 return(FALSE);
00619 }
00620 SetBitMap(specbits,DEFAULT_BIT);
00621 error = FALSE;
00622 tmp = ParseDefault(theEnv,readSource,1,(int) TestBitMap(specbits,DEFAULT_DYNAMIC_BIT),
00623 0,&noneSpecified,&deriveSpecified,&error);
00624 if (error == TRUE)
00625 return(FALSE);
00626 if (noneSpecified || deriveSpecified)
00627 {
00628 if (noneSpecified)
00629 {
00630 slot->noDefault = 1;
00631 slot->defaultSpecified = 1;
00632 }
00633 else
00634 ClearBitMap(specbits,DEFAULT_BIT);
00635 }
00636 else
00637 {
00638 slot->defaultValue = (void *) PackExpression(theEnv,tmp);
00639 ReturnExpression(theEnv,tmp);
00640 ExpressionInstall(theEnv,(EXPRESSION *) slot->defaultValue);
00641 slot->defaultSpecified = 1;
00642 }
00643 return(TRUE);
00644 }
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672 static void BuildCompositeFacets(
00673 void *theEnv,
00674 SLOT_DESC *sd,
00675 PACKED_CLASS_LINKS *preclist,
00676 char *specbits,
00677 CONSTRAINT_PARSE_RECORD *parsedConstraint)
00678 {
00679 SLOT_DESC *compslot = NULL;
00680 long i;
00681
00682 for (i = 1 ; i < preclist->classCount ; i++)
00683 {
00684 compslot = FindClassSlot(preclist->classArray[i],sd->slotName->name);
00685 if ((compslot != NULL) ? (compslot->noInherit == 0) : FALSE)
00686 break;
00687 }
00688 if (compslot != NULL)
00689 {
00690 if ((sd->defaultSpecified == 0) && (compslot->defaultSpecified == 1))
00691 {
00692 sd->dynamicDefault = compslot->dynamicDefault;
00693 sd->noDefault = compslot->noDefault;
00694 sd->defaultSpecified = 1;
00695 if (compslot->defaultValue != NULL)
00696 {
00697 if (sd->dynamicDefault)
00698 {
00699 sd->defaultValue = (void *) PackExpression(theEnv,(EXPRESSION *) compslot->defaultValue);
00700 ExpressionInstall(theEnv,(EXPRESSION *) sd->defaultValue);
00701 }
00702 else
00703 {
00704 sd->defaultValue = (void *) get_struct(theEnv,dataObject);
00705 GenCopyMemory(DATA_OBJECT,1,sd->defaultValue,compslot->defaultValue);
00706 ValueInstall(theEnv,(DATA_OBJECT *) sd->defaultValue);
00707 }
00708 }
00709 }
00710 if (TestBitMap(specbits,FIELD_BIT) == 0)
00711 sd->multiple = compslot->multiple;
00712 if (TestBitMap(specbits,STORAGE_BIT) == 0)
00713 sd->shared = compslot->shared;
00714 if (TestBitMap(specbits,ACCESS_BIT) == 0)
00715 {
00716 sd->noWrite = compslot->noWrite;
00717 sd->initializeOnly = compslot->initializeOnly;
00718 }
00719 #if DEFRULE_CONSTRUCT
00720 if (TestBitMap(specbits,MATCH_BIT) == 0)
00721 sd->reactive = compslot->reactive;
00722 #endif
00723 if (TestBitMap(specbits,VISIBILITY_BIT) == 0)
00724 sd->publicVisibility = compslot->publicVisibility;
00725 if (TestBitMap(specbits,CREATE_ACCESSOR_BIT) == 0)
00726 {
00727 sd->createReadAccessor = compslot->createReadAccessor;
00728 sd->createWriteAccessor = compslot->createWriteAccessor;
00729 }
00730 if ((TestBitMap(specbits,OVERRIDE_MSG_BIT) == 0) &&
00731 compslot->overrideMessageSpecified)
00732 {
00733 DecrementSymbolCount(theEnv,sd->overrideMessage);
00734 sd->overrideMessage = compslot->overrideMessage;
00735 IncrementSymbolCount(sd->overrideMessage);
00736 sd->overrideMessageSpecified = TRUE;
00737 }
00738 OverlayConstraint(theEnv,parsedConstraint,sd->constraint,compslot->constraint);
00739 }
00740 }
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756 static intBool CheckForFacetConflicts(
00757 void *theEnv,
00758 SLOT_DESC *sd,
00759 CONSTRAINT_PARSE_RECORD *parsedConstraint)
00760 {
00761 if (sd->multiple == 0)
00762 {
00763 if (parsedConstraint->cardinality)
00764 {
00765 PrintErrorID(theEnv,"CLSLTPSR",3,TRUE);
00766 EnvPrintRouter(theEnv,WERROR,"Cardinality facet can only be used with multifield slots\n");
00767 return(FALSE);
00768 }
00769 else
00770 {
00771 ReturnExpression(theEnv,sd->constraint->minFields);
00772 ReturnExpression(theEnv,sd->constraint->maxFields);
00773 sd->constraint->minFields = GenConstant(theEnv,INTEGER,EnvAddLong(theEnv,1LL));
00774 sd->constraint->maxFields = GenConstant(theEnv,INTEGER,EnvAddLong(theEnv,1LL));
00775 }
00776 }
00777 if (sd->noDefault && sd->noWrite)
00778 {
00779 PrintErrorID(theEnv,"CLSLTPSR",4,TRUE);
00780 EnvPrintRouter(theEnv,WERROR,"read-only slots must have a default value\n");
00781 return(FALSE);
00782 }
00783 if (sd->noWrite && (sd->createWriteAccessor || sd->overrideMessageSpecified))
00784 {
00785 PrintErrorID(theEnv,"CLSLTPSR",5,TRUE);
00786 EnvPrintRouter(theEnv,WERROR,"read-only slots cannot have a write accessor\n");
00787 return(FALSE);
00788 }
00789 if (sd->noInherit && sd->publicVisibility)
00790 {
00791 PrintErrorID(theEnv,"CLSLTPSR",6,TRUE);
00792 EnvPrintRouter(theEnv,WERROR,"no-inherit slots cannot also be public\n");
00793 return(FALSE);
00794 }
00795 return(TRUE);
00796 }
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811 static intBool EvaluateSlotDefaultValue(
00812 void *theEnv,
00813 SLOT_DESC *sd,
00814 char *specbits)
00815 {
00816 DATA_OBJECT temp;
00817 int oldce,olddcc,vCode;
00818
00819
00820
00821
00822
00823
00824
00825 if (TestBitMap(specbits,DEFAULT_DYNAMIC_BIT) == 0)
00826 sd->dynamicDefault = 0;
00827
00828 if (sd->noDefault)
00829 return(TRUE);
00830
00831 if (sd->dynamicDefault == 0)
00832 {
00833 if (TestBitMap(specbits,DEFAULT_BIT))
00834 {
00835 oldce = ExecutingConstruct(theEnv);
00836 SetExecutingConstruct(theEnv,TRUE);
00837 olddcc = EnvSetDynamicConstraintChecking(theEnv,EnvGetStaticConstraintChecking(theEnv));
00838 vCode = EvaluateAndStoreInDataObject(theEnv,(int) sd->multiple,
00839 (EXPRESSION *) sd->defaultValue,&temp,TRUE);
00840 if (vCode != FALSE)
00841 vCode = ValidSlotValue(theEnv,&temp,sd,NULL,"slot default value");
00842 EnvSetDynamicConstraintChecking(theEnv,olddcc);
00843 SetExecutingConstruct(theEnv,oldce);
00844 if (vCode)
00845 {
00846 ExpressionDeinstall(theEnv,(EXPRESSION *) sd->defaultValue);
00847 ReturnPackedExpression(theEnv,(EXPRESSION *) sd->defaultValue);
00848 sd->defaultValue = (void *) get_struct(theEnv,dataObject);
00849 GenCopyMemory(DATA_OBJECT,1,sd->defaultValue,&temp);
00850 ValueInstall(theEnv,(DATA_OBJECT *) sd->defaultValue);
00851 }
00852 else
00853 {
00854 sd->dynamicDefault = 1;
00855 return(FALSE);
00856 }
00857 }
00858 else if (sd->defaultSpecified == 0)
00859 {
00860 sd->defaultValue = (void *) get_struct(theEnv,dataObject);
00861 DeriveDefaultFromConstraints(theEnv,sd->constraint,
00862 (DATA_OBJECT *) sd->defaultValue,(int) sd->multiple,TRUE);
00863 ValueInstall(theEnv,(DATA_OBJECT *) sd->defaultValue);
00864 }
00865 }
00866 else if (EnvGetStaticConstraintChecking(theEnv))
00867 {
00868 vCode = ConstraintCheckExpressionChain(theEnv,(EXPRESSION *) sd->defaultValue,sd->constraint);
00869 if (vCode != NO_VIOLATION)
00870 {
00871 PrintErrorID(theEnv,"CSTRNCHK",1,FALSE);
00872 EnvPrintRouter(theEnv,WERROR,"Expression for ");
00873 PrintSlot(theEnv,WERROR,sd,NULL,"dynamic default value");
00874 ConstraintViolationErrorMessage(theEnv,NULL,NULL,0,0,NULL,0,
00875 vCode,sd->constraint,FALSE);
00876 return(FALSE);
00877 }
00878 }
00879 return(TRUE);
00880 }
00881
00882 #endif
00883