/*******************************************************/ /* "C" Language Integrated Production System */ /* */ /* CLIPS Version 6.40 10/18/16 */ /* */ /* ENVRNMNT HEADER FILE */ /*******************************************************/ /*************************************************************/ /* Purpose: Routines for supporting multiple environments. */ /* */ /* Principal Programmer(s): */ /* Gary D. Riley */ /* */ /* Revision History: */ /* */ /* 6.24: Added code to CreateEnvironment to free */ /* already allocated data if one of the malloc */ /* calls fail. */ /* */ /* Modified AllocateEnvironmentData to print a */ /* message if it was unable to allocate memory. */ /* */ /* Renamed BOOLEAN macro type to intBool. */ /* */ /* Added CreateRuntimeEnvironment function. */ /* */ /* Added support for context information when an */ /* environment is created (i.e a pointer from the */ /* CLIPS environment to its parent environment). */ /* */ /* 6.30: Added support for passing context information */ /* to user defined functions and callback */ /* functions. */ /* */ /* Support for hashing EXTERNAL_ADDRESS_TYPE data */ /* type. */ /* */ /* Added const qualifiers to remove C++ */ /* deprecation warnings. */ /* */ /* 6.40: Refactored code to reduce header dependencies */ /* in sysdep.c. */ /* */ /* Removed LOCALE definition. */ /* */ /* Pragma once and other inclusion changes. */ /* */ /* Added support for booleans with . */ /* */ /* Removed use of void pointers for specific */ /* data structures. */ /* */ /* ALLOW_ENVIRONMENT_GLOBALS no longer supported. */ /* */ /* Eval support for run time and bload only. */ /* */ /*************************************************************/ #ifndef _H_envrnmnt #pragma once #define _H_envrnmnt #include #include typedef struct environmentData Environment; typedef void EnvironmentCleanupFunction(Environment *); #include "entities.h" #define USER_ENVIRONMENT_DATA 70 #define MAXIMUM_ENVIRONMENT_POSITIONS 100 struct environmentCleanupFunction { const char *name; void (*func)(Environment *); int priority; struct environmentCleanupFunction *next; }; struct environmentData { unsigned int initialized : 1; void *context; CLIPSLexeme *TrueSymbol; CLIPSLexeme *FalseSymbol; CLIPSVoid *VoidConstant; void **theData; void (**cleanupFunctions)(Environment *); struct environmentCleanupFunction *listOfCleanupEnvironmentFunctions; struct environmentData *next; }; #define VoidConstant(theEnv) (theEnv->VoidConstant) #define FalseSymbol(theEnv) (theEnv->FalseSymbol) #define TrueSymbol(theEnv) (theEnv->TrueSymbol) #define GetEnvironmentData(theEnv,position) (((struct environmentData *) theEnv)->theData[position]) #define SetEnvironmentData(theEnv,position,value) (((struct environmentData *) theEnv)->theData[position] = value) bool AllocateEnvironmentData(Environment *,unsigned,size_t,EnvironmentCleanupFunction *); bool AddEnvironmentCleanupFunction(Environment *,const char *,EnvironmentCleanupFunction *,int); void *GetEnvironmentContext(Environment *); void *SetEnvironmentContext(Environment *,void *); #endif /* _H_envrnmnt */