diff options
Diffstat (limited to 'src/moduldef.c')
-rw-r--r-- | src/moduldef.c | 116 |
1 files changed, 82 insertions, 34 deletions
diff --git a/src/moduldef.c b/src/moduldef.c index 5e2ecf5..e0848fd 100644 --- a/src/moduldef.c +++ b/src/moduldef.c @@ -1,7 +1,7 @@ /*******************************************************/ /* "C" Language Integrated Production System */ /* */ - /* CLIPS Version 6.24 06/05/06 */ + /* CLIPS Version 6.30 08/22/14 */ /* */ /* DEFMODULE MODULE */ /*******************************************************/ @@ -15,9 +15,10 @@ /* Gary D. Riley */ /* */ /* Contributing Programmer(s): */ -/* Brian L. Donnell */ +/* Brian L. Dantes */ /* */ /* Revision History: */ +/* */ /* 6.23: Correction for FalseSymbol/TrueSymbol. DR0859 */ /* */ /* Corrected compilation errors for files */ @@ -25,6 +26,17 @@ /* */ /* 6.24: Renamed BOOLEAN macro type to intBool. */ /* */ +/* 6.30: Changed integer type/precision. */ +/* */ +/* Removed conditional code for unsupported */ +/* compilers/operating systems (IBM_MCW, */ +/* MAC_MCW, and IBM_TBC). */ +/* */ +/* Added const qualifiers to remove C++ */ +/* deprecation warnings. */ +/* */ +/* Converted API macros to function calls. */ +/* */ /*************************************************************/ #define _MODULDEF_SOURCE_ @@ -90,28 +102,28 @@ static void DeallocateDefmoduleData( #endif #if (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE) && (! RUN_TIME) int i; - unsigned long space; + size_t space; #endif #if (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE) && (! RUN_TIME) for (i = 0; i < DefmoduleData(theEnv)->BNumberOfDefmodules; i++) { if (DefmoduleData(theEnv)->DefmoduleArray[i].itemsArray != NULL) - { + { rm(theEnv,DefmoduleData(theEnv)->DefmoduleArray[i].itemsArray, sizeof(void *) * GetNumberOfModuleItems(theEnv)); } } space = DefmoduleData(theEnv)->BNumberOfDefmodules * sizeof(struct defmodule); - if (space != 0) + if (space != 0) { - genlongfree(theEnv,(void *) DefmoduleData(theEnv)->DefmoduleArray,space); + genfree(theEnv,(void *) DefmoduleData(theEnv)->DefmoduleArray,space); DefmoduleData(theEnv)->ListOfDefmodules = NULL; } space = DefmoduleData(theEnv)->NumberOfPortItems * sizeof(struct portItem); - if (space != 0) genlongfree(theEnv,(void *) DefmoduleData(theEnv)->PortItemArray,space); + if (space != 0) genfree(theEnv,(void *) DefmoduleData(theEnv)->PortItemArray,space); #endif #if (! RUN_TIME) && (! BLOAD_ONLY) @@ -147,13 +159,13 @@ static void DeallocateDefmoduleData( rtn_struct(theEnv,moduleItem,tmpMIPtr); tmpMIPtr = nextMIPtr; } - + #if (! RUN_TIME) && (! BLOAD_ONLY) DeallocateCallList(theEnv,DefmoduleData(theEnv)->AfterModuleDefinedFunctions); #endif DeallocateCallList(theEnv,DefmoduleData(theEnv)->AfterModuleChangeFunctions); } - + /**************************************************************/ /* InitializeDefmodules: Initializes the defmodule construct. */ /**************************************************************/ @@ -188,12 +200,12 @@ globle void InitializeDefmodules( /******************************************************/ globle int RegisterModuleItem( void *theEnv, - char *theItem, + const char *theItem, void *(*allocateFunction)(void *), void (*freeFunction)(void *,void *), void *(*bloadModuleReference)(void *,int), void (*constructsToCModuleReference)(void *,FILE *,int,int,int), - void *(*findFunction)(void *,char *)) + void *(*findFunction)(void *,const char *)) { struct moduleItem *newModuleItem; @@ -245,7 +257,7 @@ globle int GetNumberOfModuleItems( /********************************************************/ globle struct moduleItem *FindModuleItem( void *theEnv, - char *theName) + const char *theName) { struct moduleItem *theModuleItem; @@ -272,9 +284,9 @@ globle void *EnvGetCurrentModule( /**************************************************************/ globle void *EnvSetCurrentModule( void *theEnv, - void *xNewValue) + void *vNewValue) { - struct defmodule *newValue = (struct defmodule *) xNewValue; + struct defmodule *newValue = (struct defmodule *) vNewValue; struct callFunctionItem *changeFunctions; void *rv; @@ -495,36 +507,30 @@ globle void *EnvGetNextDefmodule( /* EnvGetDefmoduleName: Returns the name */ /* of the specified defmodule. */ /*****************************************/ -#if IBM_TBC -#pragma argsused -#endif -globle char *EnvGetDefmoduleName( +globle const char *EnvGetDefmoduleName( void *theEnv, void *defmodulePtr) - { -#if MAC_MCW || IBM_MCW || MAC_XCD + { +#if MAC_XCD #pragma unused(theEnv) #endif - return(ValueToString(((struct defmodule *) defmodulePtr)->name)); + return(ValueToString(((struct defmodule *) defmodulePtr)->name)); } /***************************************************/ /* EnvGetDefmodulePPForm: Returns the pretty print */ /* representation of the specified defmodule. */ /***************************************************/ -#if IBM_TBC -#pragma argsused -#endif -globle char *EnvGetDefmodulePPForm( +globle const char *EnvGetDefmodulePPForm( void *theEnv, void *defmodulePtr) - { -#if MAC_MCW || IBM_MCW || MAC_XCD + { +#if MAC_XCD #pragma unused(theEnv) #endif - return(((struct defmodule *) defmodulePtr)->ppForm); + return(((struct defmodule *) defmodulePtr)->ppForm); } #if (! RUN_TIME) @@ -567,7 +573,7 @@ static void ReturnDefmodule( /*=====================================================*/ if (theDefmodule == NULL) return; - + if (! environmentClear) { EnvSetCurrentModule(theEnv,(void *) theDefmodule); } @@ -644,13 +650,13 @@ static void ReturnDefmodule( rm(theEnv,theDefmodule->ppForm, (int) sizeof(char) * (strlen(theDefmodule->ppForm) + 1)); } - + /*=======================*/ /* Return the user data. */ /*=======================*/ ClearUserDataList(theEnv,theDefmodule->usrData); - + /*======================================*/ /* Return the defmodule data structure. */ /*======================================*/ @@ -666,7 +672,7 @@ static void ReturnDefmodule( /**********************************************************************/ globle void *EnvFindDefmodule( void *theEnv, - char *defmoduleName) + const char *defmoduleName) { struct defmodule *defmodulePtr; SYMBOL_HN *findValue; @@ -711,7 +717,7 @@ globle void *SetCurrentModuleCommand( void *theEnv) { DATA_OBJECT argPtr; - char *argument; + const char *argument; struct defmodule *theModule; SYMBOL_HN *defaultReturn; @@ -760,7 +766,7 @@ globle void *SetCurrentModuleCommand( /*************************************************/ globle void AddAfterModuleChangeFunction( void *theEnv, - char *name, + const char *name, void (*func)(void *), int priority) { @@ -779,4 +785,46 @@ globle void IllegalModuleSpecifierMessage( EnvPrintRouter(theEnv,WERROR,"Illegal use of the module specifier.\n"); } +/*#####################################*/ +/* ALLOW_ENVIRONMENT_GLOBALS Functions */ +/*#####################################*/ + +#if ALLOW_ENVIRONMENT_GLOBALS + +globle void *FindDefmodule( + const char *defmoduleName) + { + return EnvFindDefmodule(GetCurrentEnvironment(),defmoduleName); + } + +globle void *GetCurrentModule() + { + return EnvGetCurrentModule(GetCurrentEnvironment()); + } + +globle const char *GetDefmoduleName( + void *defmodulePtr) + { + return EnvGetDefmoduleName(GetCurrentEnvironment(),defmodulePtr); + } + +globle const char *GetDefmodulePPForm( + void *defmodulePtr) + { + return EnvGetDefmodulePPForm(GetCurrentEnvironment(),defmodulePtr); + } + +globle void *GetNextDefmodule( + void *defmodulePtr) + { + return EnvGetNextDefmodule(GetCurrentEnvironment(),defmodulePtr); + } + +globle void *SetCurrentModule( + void *vNewValue) + { + return EnvSetCurrentModule(GetCurrentEnvironment(),vNewValue); + } + +#endif /* ALLOW_ENVIRONMENT_GLOBALS */ |