📄 constrct.c
字号:
void *theEnv, char *name, void (*functionPtr)(void *), int priority) { ConstructData(theEnv)->ListOfResetFunctions = AddFunctionToCallList(theEnv,name,priority, functionPtr, ConstructData(theEnv)->ListOfResetFunctions,TRUE); return(TRUE); }/**********************************************//* EnvRemoveResetFunction: Removes a function *//* from the ListOfResetFunctions. *//**********************************************/globle intBool EnvRemoveResetFunction( void *theEnv, char *name) { int found; ConstructData(theEnv)->ListOfResetFunctions = RemoveFunctionFromCallList(theEnv,name,ConstructData(theEnv)->ListOfResetFunctions,&found); if (found) return(TRUE); return(FALSE); } /*****************************************************//* EnvClear: C access routine for the clear command. *//*****************************************************/globle void EnvClear( void *theEnv) { struct callFunctionItem *theFunction; /*==========================================*/ /* Activate the watch router which captures */ /* trace output so that it is not displayed */ /* during a clear. */ /*==========================================*/#if DEBUGGING_FUNCTIONS EnvActivateRouter(theEnv,WTRACE);#endif /*===================================*/ /* Determine if a clear is possible. */ /*===================================*/ ConstructData(theEnv)->ClearReadyInProgress = TRUE; if (ClearReady(theEnv) == FALSE) { PrintErrorID(theEnv,"CONSTRCT",1,FALSE); EnvPrintRouter(theEnv,WERROR,"Some constructs are still in use. Clear cannot continue.\n");#if DEBUGGING_FUNCTIONS EnvDeactivateRouter(theEnv,WTRACE);#endif ConstructData(theEnv)->ClearReadyInProgress = FALSE; return; } ConstructData(theEnv)->ClearReadyInProgress = FALSE; /*===========================*/ /* Call all clear functions. */ /*===========================*/ ConstructData(theEnv)->ClearInProgress = TRUE; for (theFunction = ConstructData(theEnv)->ListOfClearFunctions; theFunction != NULL; theFunction = theFunction->next) { if (theFunction->environmentAware) { (*theFunction->func)(theEnv); } else { (* (void (*)(void)) theFunction->func)(); } } /*=============================*/ /* Deactivate the watch router */ /* for capturing output. */ /*=============================*/#if DEBUGGING_FUNCTIONS EnvDeactivateRouter(theEnv,WTRACE);#endif /*===========================================*/ /* Perform periodic cleanup if the clear was */ /* issued from an embedded controller. */ /*===========================================*/ if ((EvaluationData(theEnv)->CurrentEvaluationDepth == 0) && (! CommandLineData(theEnv)->EvaluatingTopLevelCommand) && (EvaluationData(theEnv)->CurrentExpression == NULL)) { PeriodicCleanup(theEnv,TRUE,FALSE); } /*===========================*/ /* Clear has been completed. */ /*===========================*/ ConstructData(theEnv)->ClearInProgress = FALSE; if ((DefruleData(theEnv)->RightPrimeJoins != NULL) || (DefruleData(theEnv)->LeftPrimeJoins != NULL)) { SystemError(theEnv,"CONSTRCT",1); } /*============================*/ /* Perform reset after clear. */ /*============================*/ EnvReset(theEnv); }/*********************************************************//* ClearReady: Returns TRUE if a clear can be performed, *//* otherwise FALSE. Note that this is destructively *//* determined (e.g. facts will be deleted as part of *//* the determination). *//*********************************************************/globle intBool ClearReady( void *theEnv) { struct callFunctionItem *theFunction; int (*tempFunction)(void *); for (theFunction = ConstructData(theEnv)->ListOfClearReadyFunctions; theFunction != NULL; theFunction = theFunction->next) { tempFunction = (int (*)(void *)) theFunction->func; if ((*tempFunction)(theEnv) == FALSE) { return(FALSE); } } return(TRUE); }/******************************************//* AddClearReadyFunction: Adds a function *//* to ListOfClearReadyFunctions. *//******************************************/globle intBool AddClearReadyFunction( void *theEnv, char *name, int (*functionPtr)(void *), int priority) { ConstructData(theEnv)->ListOfClearReadyFunctions = AddFunctionToCallList(theEnv,name,priority, (void (*)(void *)) functionPtr, ConstructData(theEnv)->ListOfClearReadyFunctions,TRUE); return(1); }/************************************************//* RemoveClearReadyFunction: Removes a function *//* from the ListOfClearReadyFunctions. *//************************************************/globle intBool RemoveClearReadyFunction( void *theEnv, char *name) { int found; ConstructData(theEnv)->ListOfClearReadyFunctions = RemoveFunctionFromCallList(theEnv,name,ConstructData(theEnv)->ListOfClearReadyFunctions,&found); if (found) return(TRUE); return(FALSE); }#if (! ENVIRONMENT_API_ONLY) && ALLOW_ENVIRONMENT_GLOBALS/*************************************//* AddClearFunction: Adds a function *//* to ListOfClearFunctions. *//*************************************/globle intBool AddClearFunction( char *name, void (*functionPtr)(void), int priority) { void *theEnv; theEnv = GetCurrentEnvironment(); ConstructData(theEnv)->ListOfClearFunctions = AddFunctionToCallList(theEnv,name,priority, (void (*)(void *)) functionPtr, ConstructData(theEnv)->ListOfClearFunctions,FALSE); return(1); }#endif /****************************************//* EnvAddClearFunction: Adds a function *//* to ListOfClearFunctions. *//****************************************/globle intBool EnvAddClearFunction( void *theEnv, char *name, void (*functionPtr)(void *), int priority) { ConstructData(theEnv)->ListOfClearFunctions = AddFunctionToCallList(theEnv,name,priority, (void (*)(void *)) functionPtr, ConstructData(theEnv)->ListOfClearFunctions,TRUE); return(1); }/**********************************************//* EnvRemoveClearFunction: Removes a function *//* from the ListOfClearFunctions. *//**********************************************/globle intBool EnvRemoveClearFunction( void *theEnv, char *name) { int found; ConstructData(theEnv)->ListOfClearFunctions = RemoveFunctionFromCallList(theEnv,name,ConstructData(theEnv)->ListOfClearFunctions,&found); if (found) return(TRUE); return(FALSE); }/***********************************************//* ExecutingConstruct: Returns TRUE if a *//* construct is currently being executed, *//* otherwise FALSE. *//***********************************************/globle int ExecutingConstruct( void *theEnv) { return(ConstructData(theEnv)->Executing); }/********************************************//* SetExecutingConstruct: Sets the value of *//* the executing variable indicating that *//* actions such as reset, clear, etc *//* should not be performed. *//********************************************/globle void SetExecutingConstruct( void *theEnv, int value) { ConstructData(theEnv)->Executing = value; }/************************************************************//* OldGetConstructList: Returns a list of all the construct *//* names in a multifield value. It doesn't check the *//* number of arguments. It assumes that the restriction *//* string in DefineFunction2 call was "00". *//************************************************************/globle void OldGetConstructList( void *theEnv, DATA_OBJECT_PTR returnValue, void *(*nextFunction)(void *,void *), char *(*nameFunction)(void *,void *)) { void *theConstruct; unsigned long count = 0; struct multifield *theList; /*====================================*/ /* Determine the number of constructs */ /* of the specified type. */ /*====================================*/ for (theConstruct = (*nextFunction)(theEnv,NULL); theConstruct != NULL; theConstruct = (*nextFunction)(theEnv,theConstruct)) { count++; } /*===========================*/ /* Create a multifield large */ /* enough to store the list. */ /*===========================*/ SetpType(returnValue,MULTIFIELD); SetpDOBegin(returnValue,1); SetpDOEnd(returnValue,(long) count); theList = (struct multifield *) EnvCreateMultifield(theEnv,count); SetpValue(returnValue,(void *) theList); /*====================================*/ /* Store the names in the multifield. */ /*====================================*/ for (theConstruct = (*nextFunction)(theEnv,NULL), count = 1; theConstruct != NULL; theConstruct = (*nextFunction)(theEnv,theConstruct), count++) { if (EvaluationData(theEnv)->HaltExecution == TRUE) { EnvSetMultifieldErrorValue(theEnv,returnValue); return; } SetMFType(theList,count,SYMBOL); SetMFValue(theList,count,EnvAddSymbol(theEnv,(*nameFunction)(theEnv,theConstruct))); } }/*******************************************************//* DeinstallConstructHeader: Decrements the busy count *//* of a construct name and frees its pretty print *//* representation string (both of which are stored *//* in the generic construct header). *//*******************************************************/globle void DeinstallConstructHeader( void *theEnv, struct constructHeader *theHeader) { DecrementSymbolCount(theEnv,theHeader->name); if (theHeader->ppForm != NULL) { rm(theEnv,theHeader->ppForm, sizeof(char) * (strlen(theHeader->ppForm) + 1)); theHeader->ppForm = NULL; } if (theHeader->usrData != NULL) { ClearUserDataList(theEnv,theHeader->usrData); theHeader->usrData = NULL; } }/**************************************************//* DestroyConstructHeader: Frees the pretty print *//* representation string and user data (both of *//* which are stored in the generic construct *//* header). *//**************************************************/globle void DestroyConstructHeader( void *theEnv, struct constructHeader *theHeader) { if (theHeader->ppForm != NULL) { rm(theEnv,theHeader->ppForm, sizeof(char) * (strlen(theHeader->ppForm) + 1)); theHeader->ppForm = NULL; } if (theHeader->usrData != NULL) { ClearUserDataList(theEnv,theHeader->usrData); theHeader->usrData = NULL; } }/*****************************************************//* AddConstruct: Adds a construct and its associated *//* parsing function to the ListOfConstructs. *//*****************************************************/globle struct construct *AddConstruct( void *theEnv, char *name, char *pluralName, int (*parseFunction)(void *,char *), void *(*findFunction)(void *,char *), SYMBOL_HN *(*getConstructNameFunction)(struct constructHeader *), char *(*getPPFormFunction)(void *,struct constructHeader *), struct defmoduleItemHeader *(*getModuleItemFunction)(struct constructHeader *), void *(*getNextItemFunction)(void *,void *), void (*setNextItemFunction)(struct constructHeader *,struct constructHeader *), intBool (*isConstructDeletableFunction)(void *,void *), int (*deleteFunction)(void *,void *), void (*freeFunction)(void *,void *)) { struct construct *newPtr; /*=============================*/ /* Allocate and initialize the */ /* construct data structure. */ /*=============================*/ newPtr = get_struct(theEnv,construct); newPtr->constructName = name; newPtr->pluralName = pluralName; newPtr->parseFunction = parseFunction; newPtr->findFunction = findFunction; newPtr->getConstructNameFunction = getConstructNameFunction; newPtr->getPPFormFunction = getPPFormFunction; newPtr->getModuleItemFunction = getModuleItemFunction; newPtr->getNextItemFunction = getNextItemFunction; newPtr->setNextItemFunction = setNextItemFunction; newPtr->isConstructDeletableFunction = isConstructDeletableFunction; newPtr->deleteFunction = deleteFunction; newPtr->freeFunction = freeFunction; /*===============================*/ /* Add the construct to the list */ /* of constructs and return it. */ /*===============================*/ newPtr->next = ConstructData(theEnv)->ListOfConstructs; ConstructData(theEnv)->ListOfConstructs = newPtr; return(newPtr); }/************************************//* AddSaveFunction: Adds a function *//* to the ListOfSaveFunctions. *//************************************/globle intBool AddSaveFunction( void *theEnv, char *name, void (*functionPtr)(void *,void *,char *), int priority) {#if (MAC_MCW || IBM_MCW) && (RUN_TIME || BLOAD_ONLY)#pragma unused(name)#pragma unused(functionPtr)#pragma unused(priority)#endif#if (! RUN_TIME) && (! BLOAD_ONLY) ConstructData(theEnv)->ListOfSaveFunctions = AddFunctionToCallList(theEnv,name,priority, (void (*)(void *)) functionPtr, ConstructData(theEnv)->ListOfSaveFunctions,TRUE);#else#if MAC_MCW || IBM_MCW || MAC_XCD#pragma unused(theEnv)#endif#endif return(1); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -