本文整理匯總了C++中EnvAddSymbol函數的典型用法代碼示例。如果您正苦於以下問題:C++ EnvAddSymbol函數的具體用法?C++ EnvAddSymbol怎麽用?C++ EnvAddSymbol使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了EnvAddSymbol函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: StringToFieldFunction
globle void StringToFieldFunction(
void *theEnv,
DATA_OBJECT *returnValue)
{
DATA_OBJECT theArg;
/*========================================================*/
/* Function string-to-field expects exactly one argument. */
/*========================================================*/
if (EnvArgCountCheck(theEnv,"string-to-field",EXACTLY,1) == -1)
{
returnValue->type = STRING;
returnValue->value = (void *) EnvAddSymbol(theEnv,"*** ERROR ***");
return;
}
/*==================================================*/
/* The argument should be of type symbol or string. */
/*==================================================*/
if (EnvArgTypeCheck(theEnv,"string-to-field",1,SYMBOL_OR_STRING,&theArg) == FALSE)
{
returnValue->type = STRING;
returnValue->value = (void *) EnvAddSymbol(theEnv,"*** ERROR ***");
return;
}
/*================================*/
/* Convert the string to an atom. */
/*================================*/
StringToField(theEnv,DOToString(theArg),returnValue);
}
示例2: EnvRtnUnknown
globle char *GetLogicalName(
void *theEnv,
int whichArgument,
char *defaultLogicalName)
{
char *logicalName;
DATA_OBJECT result;
EnvRtnUnknown(theEnv,whichArgument,&result);
if ((GetType(result) == SYMBOL) ||
(GetType(result) == STRING) ||
(GetType(result) == INSTANCE_NAME))
{
logicalName = ValueToString(result.value);
if ((strcmp(logicalName,"t") == 0) || (strcmp(logicalName,"T") == 0))
{ logicalName = defaultLogicalName; }
}
else if (GetType(result) == FLOAT)
{
logicalName = ValueToString(EnvAddSymbol(theEnv,FloatToString(theEnv,DOToDouble(result))));
}
else if (GetType(result) == INTEGER)
{
logicalName = ValueToString(EnvAddSymbol(theEnv,LongIntegerToString(theEnv,DOToLong(result))));
}
else
{ logicalName = NULL; }
return(logicalName);
}
示例3: GetMouseAction
void* GetMouseAction(void* theEnv) {
unsigned state;
AdventureEngine::AdventureEngineEngine* engine = PullOutEngine(theEnv);
Common::EventManager* _eventMan = engine->getEventManager();
Common::Point pos = _eventMan->getMousePos();
state = _eventMan->getButtonState();
if(state == engine->previousMouseCommand()) {
state = 0;
} else {
engine->setPreviousMouseCommand(state);
}
switch(state)
{
case 0:
return EnvAddSymbol(theEnv, (char*)"no-click");
case 1:
return EnvAddSymbol(theEnv, (char*)"mouse1");
case 2:
return EnvAddSymbol(theEnv, (char*)"mouse2");
case 3:
return EnvAddSymbol(theEnv, (char*)"mouse3");
default:
return EnvAddSymbol(theEnv, (char*)"unknown");
}
}
示例4: SetErrorCaptureValues
static void SetErrorCaptureValues(
void *theEnv,
DATA_OBJECT_PTR returnValue)
{
struct multifield *theMultifield;
theMultifield = (struct multifield *) EnvCreateMultifield(theEnv,2L);
if (ParseFunctionData(theEnv)->ErrorString != NULL)
{
SetMFType(theMultifield,1,STRING);
SetMFValue(theMultifield,1,EnvAddSymbol(theEnv,ParseFunctionData(theEnv)->ErrorString));
}
else
{
SetMFType(theMultifield,1,SYMBOL);
SetMFValue(theMultifield,1,EnvFalseSymbol(theEnv));
}
if (ParseFunctionData(theEnv)->WarningString != NULL)
{
SetMFType(theMultifield,2,STRING);
SetMFValue(theMultifield,2,EnvAddSymbol(theEnv,ParseFunctionData(theEnv)->WarningString));
}
else
{
SetMFType(theMultifield,2,SYMBOL);
SetMFValue(theMultifield,2,EnvFalseSymbol(theEnv));
}
SetpType(returnValue,MULTIFIELD);
SetpDOBegin(returnValue,1);
SetpDOEnd(returnValue,2);
SetpValue(returnValue,(void *) theMultifield);
}
示例5: gensprintf
globle const char *FloatToString(
void *theEnv,
double number)
{
char floatString[40];
int i;
char x;
void *thePtr;
gensprintf(floatString,"%.15g",number);
for (i = 0; (x = floatString[i]) != '\0'; i++)
{
if ((x == '.') || (x == 'e'))
{
thePtr = EnvAddSymbol(theEnv,floatString);
return(ValueToString(thePtr));
}
}
genstrcat(floatString,".0");
thePtr = EnvAddSymbol(theEnv,floatString);
return(ValueToString(thePtr));
}
示例6: SalienceEvaluationName
globle void *SetSalienceEvaluationCommand(
void *theEnv)
{
DATA_OBJECT argPtr;
char *argument, *oldValue;
/*==================================================*/
/* Get the current setting for salience evaluation. */
/*==================================================*/
oldValue = SalienceEvaluationName(EnvGetSalienceEvaluation(theEnv));
/*=========================================*/
/* This function expects a single argument */
/* which must be a symbol. */
/*=========================================*/
if (EnvArgCountCheck(theEnv,(char*)"set-salience-evaluation",EXACTLY,1) == -1)
{
return((SYMBOL_HN *) EnvAddSymbol(theEnv,oldValue));
}
if (EnvArgTypeCheck(theEnv,(char*)"set-salience-evaluation",1,SYMBOL,&argPtr) == FALSE)
{
return((SYMBOL_HN *) EnvAddSymbol(theEnv,oldValue));
}
/*=============================================================*/
/* The allowed symbols to pass as an argument to this function */
/* are when-defined, when-activated, and every-cycle. */
/*=============================================================*/
argument = DOToString(argPtr);
if (strcmp(argument,(char*)"when-defined") == 0)
{
EnvSetSalienceEvaluation(theEnv,WHEN_DEFINED);
}
else if (strcmp(argument,(char*)"when-activated") == 0)
{
EnvSetSalienceEvaluation(theEnv,WHEN_ACTIVATED);
}
else if (strcmp(argument,(char*)"every-cycle") == 0)
{
EnvSetSalienceEvaluation(theEnv,EVERY_CYCLE);
}
else
{
ExpectedTypeError1(theEnv,(char*)"set-salience-evaluation",1,
(char*)"symbol with value when-defined, when-activated, or every-cycle");
return((SYMBOL_HN *) EnvAddSymbol(theEnv,oldValue));
}
/*=================================================*/
/* Return the old setting for salience evaluation. */
/*=================================================*/
return((SYMBOL_HN *) EnvAddSymbol(theEnv,oldValue));
}
示例7: LowcaseFunction
globle void LowcaseFunction(
void *theEnv,
DATA_OBJECT_PTR returnValue)
{
DATA_OBJECT theArg;
unsigned i;
size_t slen;
char *osptr, *nsptr;
/*================================================*/
/* Function lowcase expects exactly one argument. */
/*================================================*/
if (EnvArgCountCheck(theEnv,"lowcase",EXACTLY,1) == -1)
{
SetpType(returnValue,STRING);
SetpValue(returnValue,(void *) EnvAddSymbol(theEnv,""));
return;
}
/*==================================================*/
/* The argument should be of type symbol or string. */
/*==================================================*/
if (EnvArgTypeCheck(theEnv,"lowcase",1,SYMBOL_OR_STRING,&theArg) == FALSE)
{
SetpType(returnValue,STRING);
SetpValue(returnValue,(void *) EnvAddSymbol(theEnv,""));
return;
}
/*======================================================*/
/* Allocate temporary memory and then copy the original */
/* string or symbol to that memory, while lowercasing */
/* upper case alphabetic characters. */
/*======================================================*/
osptr = DOToString(theArg);
slen = strlen(osptr) + 1;
nsptr = (char *) gm2(theEnv,slen);
for (i = 0 ; i < slen ; i++)
{
if (isupper(osptr[i]))
{ nsptr[i] = (char) tolower(osptr[i]); }
else
{ nsptr[i] = osptr[i]; }
}
/*========================================*/
/* Return the lowercased string and clean */
/* up the temporary memory used. */
/*========================================*/
SetpType(returnValue,GetType(theArg));
SetpValue(returnValue,(void *) EnvAddSymbol(theEnv,nsptr));
rm(theEnv,nsptr,slen);
}
示例8: AgendaData
globle void *SetStrategyCommand(
void *theEnv)
{
DATA_OBJECT argPtr;
char *argument;
int oldStrategy;
oldStrategy = AgendaData(theEnv)->Strategy;
/*=====================================================*/
/* Check for the correct number and type of arguments. */
/*=====================================================*/
if (EnvArgCountCheck(theEnv,"set-strategy",EXACTLY,1) == -1)
{ return((SYMBOL_HN *) EnvAddSymbol(theEnv,GetStrategyName(EnvGetStrategy(theEnv)))); }
if (EnvArgTypeCheck(theEnv,"set-strategy",1,SYMBOL,&argPtr) == FALSE)
{ return((SYMBOL_HN *) EnvAddSymbol(theEnv,GetStrategyName(EnvGetStrategy(theEnv)))); }
argument = DOToString(argPtr);
/*=============================================*/
/* Set the strategy to the specified strategy. */
/*=============================================*/
if (strcmp(argument,"depth") == 0)
{ EnvSetStrategy(theEnv,DEPTH_STRATEGY); }
else if (strcmp(argument,"breadth") == 0)
{ EnvSetStrategy(theEnv,BREADTH_STRATEGY); }
else if (strcmp(argument,"lex") == 0)
{ EnvSetStrategy(theEnv,LEX_STRATEGY); }
else if (strcmp(argument,"mea") == 0)
{ EnvSetStrategy(theEnv,MEA_STRATEGY); }
else if (strcmp(argument,"complexity") == 0)
{ EnvSetStrategy(theEnv,COMPLEXITY_STRATEGY); }
else if (strcmp(argument,"simplicity") == 0)
{ EnvSetStrategy(theEnv,SIMPLICITY_STRATEGY); }
else if (strcmp(argument,"random") == 0)
{ EnvSetStrategy(theEnv,RANDOM_STRATEGY); }
else
{
ExpectedTypeError1(theEnv,"set-strategy",1,
"symbol with value depth, breadth, lex, mea, complexity, simplicity, or random");
return((SYMBOL_HN *) EnvAddSymbol(theEnv,GetStrategyName(EnvGetStrategy(theEnv))));
}
/*=======================================*/
/* Return the old value of the strategy. */
/*=======================================*/
return((SYMBOL_HN *) EnvAddSymbol(theEnv,GetStrategyName(oldStrategy)));
}
示例9: SetupObjectSystem
/**********************************************************
NAME : SetupObjectSystem
DESCRIPTION : Initializes all COOL constructs, functions,
and data structures
INPUTS : None
RETURNS : Nothing useful
SIDE EFFECTS : COOL initialized
NOTES : Order of setup calls is important
**********************************************************/
globle void SetupObjectSystem(
void *theEnv)
{
ENTITY_RECORD defclassEntityRecord = { (char*)"DEFCLASS_PTR", DEFCLASS_PTR,1,0,0,
NULL,NULL,NULL,NULL,NULL,
DecrementDefclassBusyCount,
IncrementDefclassBusyCount,
NULL,NULL,NULL,NULL,NULL
};
AllocateEnvironmentData(theEnv,DEFCLASS_DATA,sizeof(struct defclassData),NULL);
AddEnvironmentCleanupFunction(theEnv,(char*)"defclasses",DeallocateDefclassData,-500);
memcpy(&DefclassData(theEnv)->DefclassEntityRecord,&defclassEntityRecord,sizeof(struct entityRecord));
#if ! RUN_TIME
DefclassData(theEnv)->ClassDefaultsMode = CONVENIENCE_MODE;
DefclassData(theEnv)->ISA_SYMBOL = (SYMBOL_HN *) EnvAddSymbol(theEnv,SUPERCLASS_RLN);
IncrementSymbolCount(DefclassData(theEnv)->ISA_SYMBOL);
DefclassData(theEnv)->NAME_SYMBOL = (SYMBOL_HN *) EnvAddSymbol(theEnv,NAME_RLN);
IncrementSymbolCount(DefclassData(theEnv)->NAME_SYMBOL);
#if DEFRULE_CONSTRUCT
DefclassData(theEnv)->INITIAL_OBJECT_SYMBOL = (SYMBOL_HN *) EnvAddSymbol(theEnv,INITIAL_OBJECT_NAME);
IncrementSymbolCount(DefclassData(theEnv)->INITIAL_OBJECT_SYMBOL);
#endif
#endif
SetupDefclasses(theEnv);
SetupInstances(theEnv);
SetupMessageHandlers(theEnv);
#if DEFINSTANCES_CONSTRUCT
SetupDefinstances(theEnv);
#endif
#if INSTANCE_SET_QUERIES
SetupQuery(theEnv);
#endif
#if BLOAD_AND_BSAVE || BLOAD || BLOAD_ONLY
SetupObjectsBload(theEnv);
#endif
#if CONSTRUCT_COMPILER && (! RUN_TIME)
SetupObjectsCompiler(theEnv);
#endif
#if DEFRULE_CONSTRUCT
SetupObjectPatternStuff(theEnv);
#endif
}
示例10: address
/************************************************************
NAME : WildDeleteHandler
DESCRIPTION : Deletes a handler from a class
INPUTS : 1) Class address (Can be NULL)
2) Message Handler Name (Can be NULL)
3) Type name ("primary", etc.)
RETURNS : 1 if successful, 0 otherwise
SIDE EFFECTS : Handler deleted if possible
NOTES : None
************************************************************/
static int WildDeleteHandler(
void *theEnv,
DEFCLASS *cls,
SYMBOL_HN *msym,
const char *tname)
{
int mtype;
if (msym == NULL)
msym = (SYMBOL_HN *) EnvAddSymbol(theEnv,"*");
if (tname != NULL)
{
mtype = (int) HandlerType(theEnv,"undefmessage-handler",tname);
if (mtype == MERROR)
return(0);
}
else
mtype = -1;
if (cls == NULL)
{
int success = 1;
for (cls = (DEFCLASS *) EnvGetNextDefclass(theEnv,NULL) ;
cls != NULL ;
cls = (DEFCLASS *) EnvGetNextDefclass(theEnv,(void *) cls))
if (DeleteHandler(theEnv,cls,msym,mtype,FALSE) == 0)
success = 0;
return(success);
}
return(DeleteHandler(theEnv,cls,msym,mtype,TRUE));
}
示例11: EnvArgCountCheck
globle void *GetClassDefaultsModeCommand(
void *theEnv)
{
EnvArgCountCheck(theEnv,"get-class-defaults-mode",EXACTLY,0);
return((SYMBOL_HN *) EnvAddSymbol(theEnv,GetClassDefaultsModeName(EnvGetClassDefaultsMode(theEnv))));
}
示例12: ExpandStringWithChar
globle char *StringPrintForm(
void *theEnv,
char *str)
{
int i = 0, pos = 0;
unsigned max = 0;
char *theString = NULL;
void *thePtr;
theString = ExpandStringWithChar(theEnv,'"',theString,&pos,&max,max+80);
while (str[i] != EOS)
{
if ((str[i] == '"') || (str[i] == '\\'))
{
theString = ExpandStringWithChar(theEnv,'\\',theString,&pos,&max,max+80);
theString = ExpandStringWithChar(theEnv,str[i],theString,&pos,&max,max+80);
}
else
{ theString = ExpandStringWithChar(theEnv,str[i],theString,&pos,&max,max+80); }
i++;
}
theString = ExpandStringWithChar(theEnv,'"',theString,&pos,&max,max+80);
thePtr = EnvAddSymbol(theEnv,theString);
rm(theEnv,theString,max);
return(ValueToString(thePtr));
}
示例13: sprintf
globle void *GensymStar(
void *theEnv)
{
char genstring[15];
/*=======================================================*/
/* Create a symbol using the current gensym index as the */
/* postfix. If the symbol is already present in the */
/* symbol table, then continue generating symbols until */
/* a unique symbol is found. */
/*=======================================================*/
do
{
sprintf(genstring,"gen%ld",MiscFunctionData(theEnv)->GensymNumber);
MiscFunctionData(theEnv)->GensymNumber++;
}
while (FindSymbolHN(theEnv,genstring) != NULL);
/*====================*/
/* Return the symbol. */
/*====================*/
return(EnvAddSymbol(theEnv,genstring));
}
示例14: EnvArgCountCheck
globle void *GensymFunction(
void *theEnv)
{
char genstring[15];
/*===========================================*/
/* The gensym function accepts no arguments. */
/*===========================================*/
EnvArgCountCheck(theEnv,"gensym",EXACTLY,0);
/*================================================*/
/* Create a symbol using the current gensym index */
/* as the postfix. */
/*================================================*/
sprintf(genstring,"gen%ld",MiscFunctionData(theEnv)->GensymNumber);
MiscFunctionData(theEnv)->GensymNumber++;
/*====================*/
/* Return the symbol. */
/*====================*/
return(EnvAddSymbol(theEnv,genstring));
}
示例15: EnvSlotDefaultValue
/*********************************************************
NAME : SlotDefaultValue
DESCRIPTION : Determines the default value for
the specified slot of the specified class
INPUTS : 1) The class
2) The slot name
RETURNS : TRUE if slot default value is set,
FALSE otherwise
SIDE EFFECTS : Slot default value evaluated - dynamic
defaults will cause any side effects
NOTES : None
*********************************************************/
globle intBool EnvSlotDefaultValue(
void *theEnv,
void *theDefclass,
char *slotName,
DATA_OBJECT_PTR theValue)
{
SLOT_DESC *sd;
SetpType(theValue,SYMBOL);
SetpValue(theValue,EnvFalseSymbol(theEnv));
if ((sd = LookupSlot(theEnv,(DEFCLASS *) theDefclass,slotName,TRUE)) == NULL)
return(FALSE);
if (sd->noDefault)
{
SetpType(theValue,SYMBOL);
SetpValue(theValue,EnvAddSymbol(theEnv,"?NONE"));
return(TRUE);
}
if (sd->dynamicDefault)
return(EvaluateAndStoreInDataObject(theEnv,(int) sd->multiple,
(EXPRESSION *) sd->defaultValue,
theValue,TRUE));
GenCopyMemory(DATA_OBJECT,1,theValue,sd->defaultValue);
return(TRUE);
}