static void BsaveExpressions( void *theEnv, FILE *fp) { struct deffacts *theDeffacts; struct defmodule *theModule; /*===========================*/ /* Loop through each module. */ /*===========================*/ for (theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL); theModule != NULL; theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,theModule)) { /*======================================================*/ /* Set the current module to the module being examined. */ /*======================================================*/ EnvSetCurrentModule(theEnv,(void *) theModule); /*==================================================*/ /* Loop through each deffacts in the current module */ /* and save the assertion list expression. */ /*==================================================*/ for (theDeffacts = (struct deffacts *) EnvGetNextDeffacts(theEnv,NULL); theDeffacts != NULL; theDeffacts = (struct deffacts *) EnvGetNextDeffacts(theEnv,theDeffacts)) { BsaveExpression(theEnv,theDeffacts->assertList,fp); } } }
DefaultFacts::pointer DefaultFacts::next( ) { void * nxt; if ( !m_cobj ) return DefaultFacts::pointer(); nxt = EnvGetNextDeffacts( m_environment.cobj(), m_cobj ); if ( nxt ) return DefaultFacts::create( m_environment, nxt ); else return DefaultFacts::pointer(); }
/******************************************************************************* Name: UpdateWindowsMenu Description: Sets manager menu items to sensitive or unsensitive Arguments: None Returns: None *******************************************************************************/ static void UpdateWindowsMenu() { void *theEnv = GetCurrentEnvironment(); /* ==================================================== */ /* Refresh the manager window if nessessary */ /* ==================================================== */ if(list_change || list1_change ) RefreshMngrList(); /* =================================================================== */ /* Set the sensitive state to defrule manager item in the browse menu */ /* =================================================================== */ if(EnvGetNextDefrule(theEnv,NULL)) { XtSetArg(TheArgs[0], XtNsensitive, True); XtSetValues(defrule_manager, TheArgs, 1); } else { XtSetArg(TheArgs[0], XtNsensitive, False); XtSetValues(defrule_manager, TheArgs, 1); } /* ===================================-================================ */ /* Set the sensitive state to deffacts manager item in the browse menu */ /* ==================================================================== */ if(EnvGetNextDeffacts(theEnv,NULL)) { XtSetArg(TheArgs[0], XtNsensitive, True); XtSetValues(deffact_manager, TheArgs, 1); } else { XtSetArg(TheArgs[0], XtNsensitive, False); XtSetValues(deffact_manager, TheArgs, 1); } /* ======================================================================= */ /* Set the sensitive state to deftemplate manager item in the browse menu */ /* ======================================================================= */ if(EnvGetNextDeftemplate(theEnv,NULL)) { XtSetArg(TheArgs[0], XtNsensitive, True); XtSetValues(deftemplate_manager, TheArgs, 1); } else { XtSetArg(TheArgs[0], XtNsensitive, False); XtSetValues(deftemplate_manager, TheArgs, 1); } /* ======================================================================= */ /* Set the sensitive state to deffunction manager item in the browse menu */ /* ======================================================================= */ if(EnvGetNextDeffunction(theEnv,NULL)) { XtSetArg(TheArgs[0], XtNsensitive, True); XtSetValues(deffunction_manager, TheArgs, 1); } else { XtSetArg(TheArgs[0], XtNsensitive, False); XtSetValues(deffunction_manager, TheArgs, 1); } /* ===================================================================== */ /* Set the sensitive state to defglobal manager item in the browse menu */ /* ===================================================================== */ if(EnvGetNextDefglobal(theEnv,NULL)) { XtSetArg(TheArgs[0], XtNsensitive, True); XtSetValues(defglobal_manager,TheArgs,1); } else { XtSetArg(TheArgs[0], XtNsensitive, False); XtSetValues(defglobal_manager,TheArgs,1); } /* ====================================================================== */ /* Set the sensitive state to defgeneric manager item in the browse menu */ /* ====================================================================== */ if(EnvGetNextDefgeneric(theEnv,NULL)) { XtSetArg(TheArgs[0], XtNsensitive, True); XtSetValues(defgeneric_manager, TheArgs, 1); } else { XtSetArg(TheArgs[0], XtNsensitive, False); XtSetValues(defgeneric_manager, TheArgs, 1); } /* ======================================================================== */ /* Set the sensitive state to definstances manager item in the browse menu */ /* ======================================================================== */ if(EnvGetNextDefinstances(theEnv,NULL)) { XtSetArg(TheArgs[0], XtNsensitive, True); XtSetValues(definstances_manager, TheArgs, 1); } else { XtSetArg(TheArgs[0], XtNsensitive, False); XtSetValues(definstances_manager, TheArgs, 1); } /* ==================================================================== */ /* Set the sensitive state to defclass manager item in the browse menu */ /* ==================================================================== */ if(EnvGetNextDefclass(theEnv,NULL)) { XtSetArg(TheArgs[0], XtNsensitive, True); XtSetValues(defclass_manager, TheArgs, 1); } else { XtSetArg(TheArgs[0], XtNsensitive, False); XtSetValues(defclass_manager, TheArgs, 1); } /* =================================================================== */ /* Set the sensitive state to agenda manager item in the browse menu */ /* =================================================================== */ if(EnvGetNextActivation(theEnv,NULL)) { XtSetArg(TheArgs[0], XtNsensitive, True); XtSetValues(agenda_manager, TheArgs, 1); } else { XtSetArg(TheArgs[0], XtNsensitive, False); XtSetValues(agenda_manager, TheArgs, 1); } }
static void BsaveBinaryItem( void *theEnv, FILE *fp) { size_t space; struct deffacts *theDeffacts; struct bsaveDeffacts newDeffacts; struct defmodule *theModule; struct bsaveDeffactsModule tempDeffactsModule; struct deffactsModule *theModuleItem; /*=========================================================*/ /* Write out the amount of space taken up by the deffacts */ /* and deffactsModule data structures in the binary image. */ /*=========================================================*/ space = DeffactsBinaryData(theEnv)->NumberOfDeffacts * sizeof(struct bsaveDeffacts) + (DeffactsBinaryData(theEnv)->NumberOfDeffactsModules * sizeof(struct bsaveDeffactsModule)); GenWrite(&space,sizeof(size_t),fp); /*================================================*/ /* Write out each deffacts module data structure. */ /*================================================*/ DeffactsBinaryData(theEnv)->NumberOfDeffacts = 0; for (theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL); theModule != NULL; theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,theModule)) { EnvSetCurrentModule(theEnv,(void *) theModule); theModuleItem = (struct deffactsModule *) GetModuleItem(theEnv,NULL,DeffactsData(theEnv)->DeffactsModuleIndex); AssignBsaveDefmdlItemHdrVals(&tempDeffactsModule.header,&theModuleItem->header); GenWrite(&tempDeffactsModule,(unsigned long) sizeof(struct bsaveDeffactsModule),fp); } /*==========================*/ /* Write out each deffacts. */ /*==========================*/ for (theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL); theModule != NULL; theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,theModule)) { EnvSetCurrentModule(theEnv,(void *) theModule); for (theDeffacts = (struct deffacts *) EnvGetNextDeffacts(theEnv,NULL); theDeffacts != NULL; theDeffacts = (struct deffacts *) EnvGetNextDeffacts(theEnv,theDeffacts)) { AssignBsaveConstructHeaderVals(&newDeffacts.header,&theDeffacts->header); if (theDeffacts->assertList != NULL) { newDeffacts.assertList = ExpressionData(theEnv)->ExpressionCount; ExpressionData(theEnv)->ExpressionCount += ExpressionSize(theDeffacts->assertList); } else { newDeffacts.assertList = -1L; } GenWrite(&newDeffacts,(unsigned long) sizeof(struct bsaveDeffacts),fp); } } /*=============================================================*/ /* If a binary image was already loaded when the bsave command */ /* was issued, then restore the counts indicating the number */ /* of deffacts and deffacts modules in the binary image (these */ /* were overwritten by the binary save). */ /*=============================================================*/ RestoreBloadCount(theEnv,&DeffactsBinaryData(theEnv)->NumberOfDeffactsModules); RestoreBloadCount(theEnv,&DeffactsBinaryData(theEnv)->NumberOfDeffacts); }
static void BsaveFind( void *theEnv) { struct deffacts *theDeffacts; struct defmodule *theModule; /*=======================================================*/ /* If a binary image is already loaded, then temporarily */ /* save the count values since these will be overwritten */ /* in the process of saving the binary image. */ /*=======================================================*/ SaveBloadCount(theEnv,DeffactsBinaryData(theEnv)->NumberOfDeffactsModules); SaveBloadCount(theEnv,DeffactsBinaryData(theEnv)->NumberOfDeffacts); /*========================================*/ /* Set the count of deffacts and deffacts */ /* module data structures to zero. */ /*========================================*/ DeffactsBinaryData(theEnv)->NumberOfDeffacts = 0; DeffactsBinaryData(theEnv)->NumberOfDeffactsModules = 0; /*===========================*/ /* Loop through each module. */ /*===========================*/ for (theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL); theModule != NULL; theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,theModule)) { /*===============================================*/ /* Set the current module to the module being */ /* examined and increment the number of deffacts */ /* modules encountered. */ /*===============================================*/ EnvSetCurrentModule(theEnv,(void *) theModule); DeffactsBinaryData(theEnv)->NumberOfDeffactsModules++; /*===================================================*/ /* Loop through each deffacts in the current module. */ /*===================================================*/ for (theDeffacts = (struct deffacts *) EnvGetNextDeffacts(theEnv,NULL); theDeffacts != NULL; theDeffacts = (struct deffacts *) EnvGetNextDeffacts(theEnv,theDeffacts)) { /*======================================================*/ /* Initialize the construct header for the binary save. */ /*======================================================*/ MarkConstructHeaderNeededItems(&theDeffacts->header,DeffactsBinaryData(theEnv)->NumberOfDeffacts++); /*============================================================*/ /* Count the number of expressions contained in the deffacts' */ /* assertion list and mark any atomic values contained there */ /* as in use. */ /*============================================================*/ ExpressionData(theEnv)->ExpressionCount += ExpressionSize(theDeffacts->assertList); MarkNeededItems(theEnv,theDeffacts->assertList); } } }
static int ConstructToCode( void *theEnv, char *fileName, char *pathName, char *fileNameBuffer, int fileID, FILE *headerFP, int imageID, int maxIndices) { int fileCount = 1; struct defmodule *theModule; struct deffacts *theDeffacts; int moduleCount = 0, moduleArrayCount = 0, moduleArrayVersion = 1; int deffactsArrayCount = 0, deffactsArrayVersion = 1; FILE *moduleFile = NULL, *deffactsFile = NULL; /*===============================================*/ /* Include the appropriate deffacts header file. */ /*===============================================*/ fprintf(headerFP,"#include \"dffctdef.h\"\n"); /*=================================================================*/ /* Loop through all the modules and all the deffacts writing their */ /* C code representation to the file as they are traversed. */ /*=================================================================*/ for (theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL); theModule != NULL; theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,theModule)) { EnvSetCurrentModule(theEnv,(void *) theModule); moduleFile = OpenFileIfNeeded(theEnv,moduleFile,fileName,pathName, fileNameBuffer,fileID,imageID,&fileCount, moduleArrayVersion,headerFP, (char*)"struct deffactsModule", ModulePrefix(DeffactsData(theEnv)->DeffactsCodeItem), FALSE,NULL); if (moduleFile == NULL) { CloseDeffactsFiles(theEnv,moduleFile,deffactsFile,maxIndices); return(0); } DeffactsModuleToCode(theEnv,moduleFile,theModule,imageID,maxIndices,moduleCount); moduleFile = CloseFileIfNeeded(theEnv,moduleFile,&moduleArrayCount,&moduleArrayVersion, maxIndices,NULL,NULL); /*===================================================*/ /* Loop through each of the deffacts in this module. */ /*===================================================*/ for (theDeffacts = (struct deffacts *) EnvGetNextDeffacts(theEnv,NULL); theDeffacts != NULL; theDeffacts = (struct deffacts *) EnvGetNextDeffacts(theEnv,theDeffacts)) { deffactsFile = OpenFileIfNeeded(theEnv,deffactsFile,fileName,pathName, fileNameBuffer,fileID,imageID, &fileCount, deffactsArrayVersion,headerFP, (char*)"struct deffacts", ConstructPrefix(DeffactsData(theEnv)->DeffactsCodeItem), FALSE,NULL); if (deffactsFile == NULL) { CloseDeffactsFiles(theEnv,moduleFile,deffactsFile,maxIndices); return(0); } DeffactsToCode(theEnv,deffactsFile,theDeffacts,imageID,maxIndices,moduleCount); deffactsArrayCount++; deffactsFile = CloseFileIfNeeded(theEnv,deffactsFile,&deffactsArrayCount, &deffactsArrayVersion,maxIndices,NULL,NULL); } moduleCount++; moduleArrayCount++; } CloseDeffactsFiles(theEnv,moduleFile,deffactsFile,maxIndices); return(1); }