/************************************************************* 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; }
/************************************************************* 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++; } }