/*************************************************** NAME : UpdateDefclassesScope DESCRIPTION : This function updates the scope bitmaps for existing classes when a new module is defined INPUTS : None RETURNS : Nothing SIDE EFFECTS : Class scope bitmaps are updated NOTES : None ***************************************************/ static void UpdateDefclassesScope( void *theEnv) { register unsigned i; DEFCLASS *theDefclass; int newModuleID,count; char *newScopeMap; unsigned newScopeMapSize; char *className; struct defmodule *matchModule; newModuleID = (int) ((struct defmodule *) EnvGetCurrentModule(theEnv))->bsaveID; newScopeMapSize = (sizeof(char) * ((GetNumberOfDefmodules(theEnv) / BITS_PER_BYTE) + 1)); newScopeMap = (char *) gm2(theEnv,newScopeMapSize); for (i = 0 ; i < CLASS_TABLE_HASH_SIZE ; i++) for (theDefclass = DefclassData(theEnv)->ClassTable[i] ; theDefclass != NULL ; theDefclass = theDefclass->nxtHash) { matchModule = theDefclass->header.whichModule->theModule; className = ValueToString(theDefclass->header.name); ClearBitString((void *) newScopeMap,newScopeMapSize); GenCopyMemory(char,theDefclass->scopeMap->size, newScopeMap,ValueToBitMap(theDefclass->scopeMap)); DecrementBitMapCount(theEnv,theDefclass->scopeMap); if (theDefclass->system) SetBitMap(newScopeMap,newModuleID); else if (FindImportedConstruct(theEnv,(char*)"defclass",matchModule, className,&count,TRUE,NULL) != NULL) SetBitMap(newScopeMap,newModuleID); theDefclass->scopeMap = (BITMAP_HN *) EnvAddBitMap(theEnv,(void *) newScopeMap,newScopeMapSize); IncrementBitMapCount(theDefclass->scopeMap); } rm(theEnv,(void *) newScopeMap,newScopeMapSize); }
int CIso8583<_Ty>::CloneValue(const int iIndex, const _Myt *iso) { if (iso == NULL || this == iso) { // 如果源对象和本对象相同则返回失败 return 0; } if (m_pIFF == NULL || m_pIFF->GetField(iIndex) == NULL) { return 0; } if (iIndex < 0 || iIndex >= m_pIFF->GetMF()->iFieldCnt) { return 0; } char bFieldData[FIELD_MAXLEN] = {0}; int iFieldDataLen = 0; iFieldDataLen = const_cast<_Myt*>(iso)->GetValueByStr(iIndex, bFieldData, sizeof(bFieldData)); int iRet = m_pIFF->GetField(iIndex)->SetValueByStr(bFieldData); if (iRet && !SetBitMap(iIndex)) { return 0; } return iRet; }
globle void *CreateDeftemplateScopeMap( void *theEnv, struct deftemplate *theDeftemplate) { unsigned scopeMapSize; char *scopeMap; char *templateName; struct defmodule *matchModule, *theModule; int moduleID,count; void *theBitMap; templateName = ValueToString(theDeftemplate->header.name); matchModule = theDeftemplate->header.whichModule->theModule; scopeMapSize = (sizeof(char) * ((GetNumberOfDefmodules(theEnv) / BITS_PER_BYTE) + 1)); scopeMap = (char *) gm2(theEnv,scopeMapSize); ClearBitString((void *) scopeMap,scopeMapSize); SaveCurrentModule(theEnv); for (theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL) ; theModule != NULL ; theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,(void *) theModule)) { EnvSetCurrentModule(theEnv,(void *) theModule); moduleID = (int) theModule->bsaveID; if (FindImportedConstruct(theEnv,"deftemplate",matchModule, templateName,&count,TRUE,NULL) != NULL) SetBitMap(scopeMap,moduleID); } RestoreCurrentModule(theEnv); theBitMap = EnvAddBitMap(theEnv,scopeMap,scopeMapSize); IncrementBitMapCount(theBitMap); rm(theEnv,(void *) scopeMap,scopeMapSize); return(theBitMap); }
int CIso8583<_Ty>::RemoveField(const int iIndex) { if(iIndex == 0 || iIndex == 1) {//第0域与第1域不能删除 return 0; } if(!BitExist(iIndex)) { return 1 ;//域不存在,返回成功 } m_pIFF->GetField(iIndex)->RemoveField(); return SetBitMap(iIndex, 0); }
/********************************************************* NAME : AddSystemClass DESCRIPTION : Performs all necessary allocations for adding a system class INPUTS : 1) The name-string of the system class 2) The address of the parent class (NULL if none) RETURNS : The address of the new system class SIDE EFFECTS : Allocations performed NOTES : Assumes system-class name is unique Also assumes SINGLE INHERITANCE for system classes to simplify precedence list determination Adds classes to has table but NOT to class list (this is responsibility of caller) *********************************************************/ static DEFCLASS *AddSystemClass( void *theEnv, char *name, DEFCLASS *parent) { DEFCLASS *sys; long i; char defaultScopeMap[1]; sys = NewClass(theEnv,(SYMBOL_HN *) EnvAddSymbol(theEnv,name)); sys->abstract = 1; #if DEFRULE_CONSTRUCT sys->reactive = 0; #endif IncrementSymbolCount(sys->header.name); sys->installed = 1; sys->system = 1; sys->hashTableIndex = HashClass(sys->header.name); AddClassLink(theEnv,&sys->allSuperclasses,sys,-1); if (parent != NULL) { AddClassLink(theEnv,&sys->directSuperclasses,parent,-1); AddClassLink(theEnv,&parent->directSubclasses,sys,-1); AddClassLink(theEnv,&sys->allSuperclasses,parent,-1); for (i = 1 ; i < parent->allSuperclasses.classCount ; i++) AddClassLink(theEnv,&sys->allSuperclasses,parent->allSuperclasses.classArray[i],-1); } sys->nxtHash = DefclassData(theEnv)->ClassTable[sys->hashTableIndex]; DefclassData(theEnv)->ClassTable[sys->hashTableIndex] = sys; /* ========================================= Add default scope maps for a system class There is only one module (MAIN) so far - which has an id of 0 ========================================= */ ClearBitString((void *) defaultScopeMap,(int) sizeof(char)); SetBitMap(defaultScopeMap,0); #if DEFMODULE_CONSTRUCT sys->scopeMap = (BITMAP_HN *) EnvAddBitMap(theEnv,(void *) defaultScopeMap,(int) sizeof(char)); IncrementBitMapCount(sys->scopeMap); #endif return(sys); }
int CIso8583<_Ty>::SetValueByHex(const int iIndex, const unsigned char *pHexData, int iDataLen, int iValidLen) { if(m_pIFF == NULL || m_pIFF->GetField(iIndex) == NULL) { trace_log(ERR, "The parameters m_pIFF is empty."); return 0; } if(iIndex < 0 || iIndex >= m_pIFF->GetMF()->iFieldCnt) { trace_log(ERR, "iIndex overflow."); return 0; } int iRet = m_pIFF->GetField(iIndex)->SetValueByHex(pHexData, iDataLen, iValidLen); if(iRet && !SetBitMap(iIndex)) { return 0; } return iRet; }
/************************************************************* NAME : ParseDefaultFacet DESCRIPTION : Parses the facet for a slot INPUTS : 1) The input logical name 2) The bitmap indicating which facets have already been parsed 3) The slot descriptor to set RETURNS : True if all OK, false otherwise SIDE EFFECTS : Slot set and parsed facet bitmap set NOTES : Syntax: (default ?NONE|<expression>*) (default-dynamic <expression>*) *************************************************************/ static bool ParseDefaultFacet( Environment *theEnv, const char *readSource, char *specbits, SlotDescriptor *slot) { Expression *tmp; bool error, noneSpecified, deriveSpecified; if (TestBitMap(specbits,DEFAULT_BIT)) { PrintErrorID(theEnv,"CLSLTPSR",2,false); WriteString(theEnv,STDERR,"The 'default' facet for slot '"); WriteString(theEnv,STDERR,slot->slotName->name->contents); WriteString(theEnv,STDERR,"' is already specified.\n"); return false; } SetBitMap(specbits,DEFAULT_BIT); error = false; tmp = ParseDefault(theEnv,readSource,true,TestBitMap(specbits,DEFAULT_DYNAMIC_BIT), false,&noneSpecified,&deriveSpecified,&error); if (error == true) return false; if (noneSpecified || deriveSpecified) { if (noneSpecified) { slot->noDefault = 1; slot->defaultSpecified = 1; } else ClearBitMap(specbits,DEFAULT_BIT); } else { slot->defaultValue = PackExpression(theEnv,tmp); ReturnExpression(theEnv,tmp); ExpressionInstall(theEnv,(Expression *) slot->defaultValue); slot->defaultSpecified = 1; } return true; }
int CIso8583<_Ty>::SetValueByStr(const int iIndex, const char *pStrData) { if(m_pIFF == NULL || m_pIFF->GetField(iIndex) == NULL) { trace_log(ERR, "Field%d of The parameters m_pIFF is empty.",iIndex); return 0; } if(iIndex < 0 || iIndex >= m_pIFF->GetMF()->iFieldCnt) { trace_log(ERR, "iIndex overflow."); return 0; } int iRet = m_pIFF->GetField(iIndex)->SetValueByStr(pStrData); if(iRet && !SetBitMap(iIndex)) { trace_log(ERR, "set bitmap err."); return 0; } return iRet; }
/************************************************************* NAME : ParseDefaultFacet DESCRIPTION : Parses the facet for a slot INPUTS : 1) The input logical name 2) The bitmap indicating which facets have already been parsed 3) The slot descriptor to set RETURNS : TRUE if all OK, FALSE otherwise SIDE EFFECTS : Slot set and parsed facet bitmap set NOTES : Syntax: (default ?NONE|<expression>*) (default-dynamic <expression>*) *************************************************************/ static intBool ParseDefaultFacet( void *theEnv, EXEC_STATUS, char *readSource, char *specbits, SLOT_DESC *slot) { EXPRESSION *tmp; int error,noneSpecified,deriveSpecified; if (TestBitMap(specbits,DEFAULT_BIT)) { PrintErrorID(theEnv,execStatus,"CLSLTPSR",2,FALSE); EnvPrintRouter(theEnv,execStatus,WERROR,"default facet already specified.\n"); return(FALSE); } SetBitMap(specbits,DEFAULT_BIT); error = FALSE; tmp = ParseDefault(theEnv,execStatus,readSource,1,(int) TestBitMap(specbits,DEFAULT_DYNAMIC_BIT), 0,&noneSpecified,&deriveSpecified,&error); if (error == TRUE) return(FALSE); if (noneSpecified || deriveSpecified) { if (noneSpecified) { slot->noDefault = 1; slot->defaultSpecified = 1; } else ClearBitMap(specbits,DEFAULT_BIT); } else { slot->defaultValue = (void *) PackExpression(theEnv,execStatus,tmp); ReturnExpression(theEnv,execStatus,tmp); ExpressionInstall(theEnv,execStatus,(EXPRESSION *) slot->defaultValue); slot->defaultSpecified = 1; } return(TRUE); }
globle void EnvSlotTypes( void *theEnv, void *clsptr, const char *sname, DATA_OBJECT *result) { register unsigned i,j; register SLOT_DESC *sp; char typemap[2]; unsigned msize; if ((sp = SlotInfoSlot(theEnv,result,(DEFCLASS *) clsptr,sname,"slot-types")) == NULL) return; if ((sp->constraint != NULL) ? sp->constraint->anyAllowed : TRUE) { typemap[0] = typemap[1] = (char) 0xFF; ClearBitMap(typemap,MULTIFIELD); msize = 8; } else { typemap[0] = typemap[1] = (char) 0x00; msize = 0; if (sp->constraint->symbolsAllowed) { msize++; SetBitMap(typemap,SYMBOL); } if (sp->constraint->stringsAllowed) { msize++; SetBitMap(typemap,STRING); } if (sp->constraint->floatsAllowed) { msize++; SetBitMap(typemap,FLOAT); } if (sp->constraint->integersAllowed) { msize++; SetBitMap(typemap,INTEGER); } if (sp->constraint->instanceNamesAllowed) { msize++; SetBitMap(typemap,INSTANCE_NAME); } if (sp->constraint->instanceAddressesAllowed) { msize++; SetBitMap(typemap,INSTANCE_ADDRESS); } if (sp->constraint->externalAddressesAllowed) { msize++; SetBitMap(typemap,EXTERNAL_ADDRESS); } if (sp->constraint->factAddressesAllowed) { msize++; SetBitMap(typemap,FACT_ADDRESS); } } SetpDOEnd(result,msize); result->value = EnvCreateMultifield(theEnv,msize); i = 1; j = 0; while (i <= msize) { if (TestBitMap(typemap,j)) { SetMFType(result->value,i,SYMBOL); SetMFValue(result->value,i, (void *) GetDefclassNamePointer((void *) DefclassData(theEnv)->PrimitiveClassMap[j])); i++; } j++; } }
/**************************************************************** NAME : ParseSimpleFacet DESCRIPTION : Parses the following facets for a slot: access, source, propagation, storage, pattern-match, visibility and override-message INPUTS : 1) The input logical name 2) The bitmap indicating which facets have already been parsed 3) The name of the facet 4) The bit to test/set in arg #2 for this facet 5) The facet value string which indicates the facet should be false 6) The facet value string which indicates the facet should be TRUE 7) An alternate value string for use when the first two don't match (can be NULL) 7) An alternate value string for use when the first three don't match (can be NULL) (will be an SF_VARIABLE type) 9) A buffer to hold the facet value symbol (can be NULL - only set if args #5 and #6 are both NULL) RETURNS : -1 on errors 0 if first value string matched 1 if second value string matched 2 if alternate value string matched 3 if variable value string matched 4 if facet value buffer was set SIDE EFFECTS : Messages printed on errors Bitmap marked indicating facet was parsed Facet value symbol buffer set, if appropriate NOTES : None *****************************************************************/ static int ParseSimpleFacet( void *theEnv, EXEC_STATUS, char *readSource, char *specbits, char *facetName, int testBit, char *clearRelation, char *setRelation, char *alternateRelation, char *varRelation, SYMBOL_HN **facetSymbolicValue) { int rtnCode; if (TestBitMap(specbits,testBit)) { PrintErrorID(theEnv,execStatus,"CLSLTPSR",2,FALSE); EnvPrintRouter(theEnv,execStatus,WERROR,facetName); EnvPrintRouter(theEnv,execStatus,WERROR," facet already specified.\n"); return(-1); } SetBitMap(specbits,testBit); SavePPBuffer(theEnv,execStatus," "); GetToken(theEnv,execStatus,readSource,&DefclassData(theEnv,execStatus)->ObjectParseToken); /* =============================== Check for the variable relation =============================== */ if (DefclassData(theEnv,execStatus)->ObjectParseToken.type == SF_VARIABLE) { if ((varRelation == NULL) ? FALSE : (strcmp(DOToString(DefclassData(theEnv,execStatus)->ObjectParseToken),varRelation) == 0)) rtnCode = 3; else goto ParseSimpleFacetError; } else { if (DefclassData(theEnv,execStatus)->ObjectParseToken.type != SYMBOL) goto ParseSimpleFacetError; /* =================================================== If the facet value buffer is non-NULL simply get the value and do not check any relations =================================================== */ if (facetSymbolicValue == NULL) { if (strcmp(DOToString(DefclassData(theEnv,execStatus)->ObjectParseToken),clearRelation) == 0) rtnCode = 0; else if (strcmp(DOToString(DefclassData(theEnv,execStatus)->ObjectParseToken),setRelation) == 0) rtnCode = 1; else if ((alternateRelation == NULL) ? FALSE : (strcmp(DOToString(DefclassData(theEnv,execStatus)->ObjectParseToken),alternateRelation) == 0)) rtnCode = 2; else goto ParseSimpleFacetError; } else { rtnCode = 4; *facetSymbolicValue = (SYMBOL_HN *) DefclassData(theEnv,execStatus)->ObjectParseToken.value; } } GetToken(theEnv,execStatus,readSource,&DefclassData(theEnv,execStatus)->ObjectParseToken); if (DefclassData(theEnv,execStatus)->ObjectParseToken.type != RPAREN) goto ParseSimpleFacetError; return(rtnCode); ParseSimpleFacetError: SyntaxErrorMessage(theEnv,execStatus,"slot facet"); return(-1); }
/************************************************************ NAME : ParseSlot DESCRIPTION : Parses slot definitions for a defclass statement INPUTS : 1) The logical name of the input source 2) The current slot list 3) The class precedence list for the class to which this slot is being attached (used to find facets for composite slots) 4) A flag indicating if this is a multifield slot or not 5) A flag indicating if the type of slot (single or multi) was explicitly specified or not RETURNS : The address of the list of slots, NULL if there was an error SIDE EFFECTS : The slot list is allocated NOTES : Assumes "(slot" has already been parsed. ************************************************************/ globle TEMP_SLOT_LINK *ParseSlot( void *theEnv, EXEC_STATUS, char *readSource, TEMP_SLOT_LINK *slist, PACKED_CLASS_LINKS *preclist, int multiSlot, int fieldSpecified) { SLOT_DESC *slot; CONSTRAINT_PARSE_RECORD parsedConstraint; char specbits[2]; int rtnCode; SYMBOL_HN *newOverrideMsg; /* =============================================================== Bits in specbits are when slot qualifiers are specified so that duplicate or conflicting qualifiers can be detected. Shared/local bit-0 Single/multiple bit-1 Read-only/Read-write/Initialize-Only bit-2 Inherit/No-inherit bit-3 Composite/Exclusive bit-4 Reactive/Nonreactive bit-5 Default bit-6 Default-dynamic bit-7 Visibility bit-8 Override-message bit-9 =============================================================== */ SavePPBuffer(theEnv,execStatus," "); specbits[0] = specbits[1] = '\0'; GetToken(theEnv,execStatus,readSource,&DefclassData(theEnv,execStatus)->ObjectParseToken); if (GetType(DefclassData(theEnv,execStatus)->ObjectParseToken) != SYMBOL) { DeleteSlots(theEnv,execStatus,slist); SyntaxErrorMessage(theEnv,execStatus,"defclass slot"); return(NULL); } if ((DefclassData(theEnv,execStatus)->ObjectParseToken.value == (void *) DefclassData(theEnv,execStatus)->ISA_SYMBOL) || (DefclassData(theEnv,execStatus)->ObjectParseToken.value == (void *) DefclassData(theEnv,execStatus)->NAME_SYMBOL)) { DeleteSlots(theEnv,execStatus,slist); SyntaxErrorMessage(theEnv,execStatus,"defclass slot"); return(NULL); } slot = NewSlot(theEnv,execStatus,(SYMBOL_HN *) GetValue(DefclassData(theEnv,execStatus)->ObjectParseToken)); slist = InsertSlot(theEnv,execStatus,slist,slot); if (slist == NULL) return(NULL); if (multiSlot) slot->multiple = TRUE; if (fieldSpecified) SetBitMap(specbits,FIELD_BIT); GetToken(theEnv,execStatus,readSource,&DefclassData(theEnv,execStatus)->ObjectParseToken); IncrementIndentDepth(theEnv,execStatus,3); InitializeConstraintParseRecord(&parsedConstraint); while (GetType(DefclassData(theEnv,execStatus)->ObjectParseToken) == LPAREN) { PPBackup(theEnv,execStatus); PPCRAndIndent(theEnv,execStatus); SavePPBuffer(theEnv,execStatus,"("); GetToken(theEnv,execStatus,readSource,&DefclassData(theEnv,execStatus)->ObjectParseToken); if (GetType(DefclassData(theEnv,execStatus)->ObjectParseToken) != SYMBOL) { SyntaxErrorMessage(theEnv,execStatus,"defclass slot"); goto ParseSlotError; } else if (strcmp(DOToString(DefclassData(theEnv,execStatus)->ObjectParseToken),DEFAULT_FACET) == 0) { if (ParseDefaultFacet(theEnv,execStatus,readSource,specbits,slot) == FALSE) goto ParseSlotError; } else if (strcmp(DOToString(DefclassData(theEnv,execStatus)->ObjectParseToken),DYNAMIC_FACET) == 0) { SetBitMap(specbits,DEFAULT_DYNAMIC_BIT); if (ParseDefaultFacet(theEnv,execStatus,readSource,specbits,slot) == FALSE) goto ParseSlotError; } else if (strcmp(DOToString(DefclassData(theEnv,execStatus)->ObjectParseToken),ACCESS_FACET) == 0) { rtnCode = ParseSimpleFacet(theEnv,execStatus,readSource,specbits,ACCESS_FACET,ACCESS_BIT, SLOT_RDWRT_RLN,SLOT_RDONLY_RLN,SLOT_INIT_RLN, NULL,NULL); if (rtnCode == -1) goto ParseSlotError; else if (rtnCode == 1) slot->noWrite = 1; else if (rtnCode == 2) slot->initializeOnly = 1; } else if (strcmp(DOToString(DefclassData(theEnv,execStatus)->ObjectParseToken),STORAGE_FACET) == 0) { rtnCode = ParseSimpleFacet(theEnv,execStatus,readSource,specbits,STORAGE_FACET,STORAGE_BIT, SLOT_LOCAL_RLN,SLOT_SHARE_RLN,NULL,NULL,NULL); if (rtnCode == -1) goto ParseSlotError; slot->shared = rtnCode; } else if (strcmp(DOToString(DefclassData(theEnv,execStatus)->ObjectParseToken),PROPAGATION_FACET) == 0) { rtnCode = ParseSimpleFacet(theEnv,execStatus,readSource,specbits,PROPAGATION_FACET,PROPAGATION_BIT, SLOT_INH_RLN,SLOT_NO_INH_RLN,NULL,NULL,NULL); if (rtnCode == -1) goto ParseSlotError; slot->noInherit = rtnCode; } else if (strcmp(DOToString(DefclassData(theEnv,execStatus)->ObjectParseToken),SOURCE_FACET) == 0) { rtnCode = ParseSimpleFacet(theEnv,execStatus,readSource,specbits,SOURCE_FACET,SOURCE_BIT, SLOT_EXCLUSIVE_RLN,SLOT_COMPOSITE_RLN,NULL,NULL,NULL); if (rtnCode == -1) goto ParseSlotError; slot->composite = rtnCode; } #if DEFRULE_CONSTRUCT else if (strcmp(DOToString(DefclassData(theEnv,execStatus)->ObjectParseToken),MATCH_FACET) == 0) { rtnCode = ParseSimpleFacet(theEnv,execStatus,readSource,specbits,MATCH_FACET,MATCH_BIT, SLOT_NONREACTIVE_RLN,SLOT_REACTIVE_RLN,NULL,NULL,NULL); if (rtnCode == -1) goto ParseSlotError; slot->reactive = rtnCode; } #endif else if (strcmp(DOToString(DefclassData(theEnv,execStatus)->ObjectParseToken),VISIBILITY_FACET) == 0) { rtnCode = ParseSimpleFacet(theEnv,execStatus,readSource,specbits,VISIBILITY_FACET,VISIBILITY_BIT, SLOT_PRIVATE_RLN,SLOT_PUBLIC_RLN,NULL,NULL,NULL); if (rtnCode == -1) goto ParseSlotError; slot->publicVisibility = rtnCode; } else if (strcmp(DOToString(DefclassData(theEnv,execStatus)->ObjectParseToken),CREATE_ACCESSOR_FACET) == 0) { rtnCode = ParseSimpleFacet(theEnv,execStatus,readSource,specbits,CREATE_ACCESSOR_FACET, CREATE_ACCESSOR_BIT, SLOT_READ_RLN,SLOT_WRITE_RLN,SLOT_RDWRT_RLN, SLOT_NONE_RLN,NULL); if (rtnCode == -1) goto ParseSlotError; if ((rtnCode == 0) || (rtnCode == 2)) slot->createReadAccessor = TRUE; if ((rtnCode == 1) || (rtnCode == 2)) slot->createWriteAccessor = TRUE; } else if (strcmp(DOToString(DefclassData(theEnv,execStatus)->ObjectParseToken),OVERRIDE_MSG_FACET) == 0) { rtnCode = ParseSimpleFacet(theEnv,execStatus,readSource,specbits,OVERRIDE_MSG_FACET,OVERRIDE_MSG_BIT, NULL,NULL,NULL,SLOT_DEFAULT_RLN,&newOverrideMsg); if (rtnCode == -1) goto ParseSlotError; if (rtnCode == 4) { DecrementSymbolCount(theEnv,execStatus,slot->overrideMessage); slot->overrideMessage = newOverrideMsg; IncrementSymbolCount(slot->overrideMessage); } slot->overrideMessageSpecified = TRUE; } else if (StandardConstraint(DOToString(DefclassData(theEnv,execStatus)->ObjectParseToken))) { if (ParseStandardConstraint(theEnv,execStatus,readSource,DOToString(DefclassData(theEnv,execStatus)->ObjectParseToken), slot->constraint,&parsedConstraint,TRUE) == FALSE) goto ParseSlotError; } else { SyntaxErrorMessage(theEnv,execStatus,"defclass slot"); goto ParseSlotError; } GetToken(theEnv,execStatus,readSource,&DefclassData(theEnv,execStatus)->ObjectParseToken); } if (GetType(DefclassData(theEnv,execStatus)->ObjectParseToken) != RPAREN) { SyntaxErrorMessage(theEnv,execStatus,"defclass slot"); goto ParseSlotError; } if (DefclassData(theEnv,execStatus)->ClassDefaultsMode == CONVENIENCE_MODE) { if (! TestBitMap(specbits,CREATE_ACCESSOR_BIT)) { slot->createReadAccessor = TRUE; if (! slot->noWrite) { slot->createWriteAccessor = TRUE; } } } if (slot->composite) BuildCompositeFacets(theEnv,execStatus,slot,preclist,specbits,&parsedConstraint); if (CheckForFacetConflicts(theEnv,execStatus,slot,&parsedConstraint) == FALSE) goto ParseSlotError; if (CheckConstraintParseConflicts(theEnv,execStatus,slot->constraint) == FALSE) goto ParseSlotError; if (EvaluateSlotDefaultValue(theEnv,execStatus,slot,specbits) == FALSE) goto ParseSlotError; if ((slot->dynamicDefault == 0) && (slot->noWrite == 1) && (slot->initializeOnly == 0)) slot->shared = 1; slot->constraint = AddConstraint(theEnv,execStatus,slot->constraint); DecrementIndentDepth(theEnv,execStatus,3); return(slist); ParseSlotError: DecrementIndentDepth(theEnv,execStatus,3); DeleteSlots(theEnv,execStatus,slist); return(NULL); }
/**************************************************************** NAME : ParseSimpleFacet DESCRIPTION : Parses the following facets for a slot: access, source, propagation, storage, pattern-match, visibility and override-message INPUTS : 1) The input logical name 2) The bitmap indicating which facets have already been parsed 3) The name of the facet 4) The bit to test/set in arg #2 for this facet 5) The facet value string which indicates the facet should be false 6) The facet value string which indicates the facet should be true 7) An alternate value string for use when the first two don't match (can be NULL) 7) An alternate value string for use when the first three don't match (can be NULL) (will be an SF_VARIABLE type) 9) A buffer to hold the facet value symbol (can be NULL - only set if args #5 and #6 are both NULL) RETURNS : -1 on errors 0 if first value string matched 1 if second value string matched 2 if alternate value string matched 3 if variable value string matched 4 if facet value buffer was set SIDE EFFECTS : Messages printed on errors Bitmap marked indicating facet was parsed Facet value symbol buffer set, if appropriate NOTES : None *****************************************************************/ static int ParseSimpleFacet( Environment *theEnv, const char *readSource, SlotDescriptor *slot, char *specbits, const char *facetName, int testBit, const char *clearRelation, const char *setRelation, const char *alternateRelation, const char *varRelation, CLIPSLexeme **facetSymbolicValue) { int rtnCode; if (TestBitMap(specbits,testBit)) { PrintErrorID(theEnv,"CLSLTPSR",2,false); WriteString(theEnv,STDERR,"The '"); WriteString(theEnv,STDERR,facetName); WriteString(theEnv,STDERR,"' facet for slot '"); WriteString(theEnv,STDERR,slot->slotName->name->contents); WriteString(theEnv,STDERR,"' is already specified.\n"); return -1; } SetBitMap(specbits,testBit); SavePPBuffer(theEnv," "); GetToken(theEnv,readSource,&DefclassData(theEnv)->ObjectParseToken); /* =============================== Check for the variable relation =============================== */ if (DefclassData(theEnv)->ObjectParseToken.tknType == SF_VARIABLE_TOKEN) { if ((varRelation == NULL) ? false : (strcmp(DefclassData(theEnv)->ObjectParseToken.lexemeValue->contents,varRelation) == 0)) rtnCode = 3; else goto ParseSimpleFacetError; } else { if (DefclassData(theEnv)->ObjectParseToken.tknType != SYMBOL_TOKEN) goto ParseSimpleFacetError; /* =================================================== If the facet value buffer is non-NULL simply get the value and do not check any relations =================================================== */ if (facetSymbolicValue == NULL) { if (strcmp(DefclassData(theEnv)->ObjectParseToken.lexemeValue->contents,clearRelation) == 0) rtnCode = 0; else if (strcmp(DefclassData(theEnv)->ObjectParseToken.lexemeValue->contents,setRelation) == 0) rtnCode = 1; else if ((alternateRelation == NULL) ? false : (strcmp(DefclassData(theEnv)->ObjectParseToken.lexemeValue->contents,alternateRelation) == 0)) rtnCode = 2; else goto ParseSimpleFacetError; } else { rtnCode = 4; *facetSymbolicValue = DefclassData(theEnv)->ObjectParseToken.lexemeValue; } } GetToken(theEnv,readSource,&DefclassData(theEnv)->ObjectParseToken); if (DefclassData(theEnv)->ObjectParseToken.tknType != RIGHT_PARENTHESIS_TOKEN) goto ParseSimpleFacetError; return(rtnCode); ParseSimpleFacetError: SyntaxErrorMessage(theEnv,"slot facet"); return(-1); }