static void BsaveFind( void *theEnv, EXEC_STATUS) { struct defglobal *defglobalPtr; 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,execStatus,DefglobalBinaryData(theEnv,execStatus)->NumberOfDefglobalModules); SaveBloadCount(theEnv,execStatus,DefglobalBinaryData(theEnv,execStatus)->NumberOfDefglobals); /*============================================*/ /* Set the count of defglobals and defglobals */ /* module data structures to zero. */ /*============================================*/ DefglobalBinaryData(theEnv,execStatus)->NumberOfDefglobals = 0; DefglobalBinaryData(theEnv,execStatus)->NumberOfDefglobalModules = 0; for (theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,execStatus,NULL); theModule != NULL; theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,execStatus,theModule)) { /*================================================*/ /* Set the current module to the module being */ /* examined and increment the number of defglobal */ /* modules encountered. */ /*================================================*/ EnvSetCurrentModule(theEnv,execStatus,(void *) theModule); DefglobalBinaryData(theEnv,execStatus)->NumberOfDefglobalModules++; /*====================================================*/ /* Loop through each defglobal in the current module. */ /*====================================================*/ for (defglobalPtr = (struct defglobal *) EnvGetNextDefglobal(theEnv,execStatus,NULL); defglobalPtr != NULL; defglobalPtr = (struct defglobal *) EnvGetNextDefglobal(theEnv,execStatus,defglobalPtr)) { /*======================================================*/ /* Initialize the construct header for the binary save. */ /*======================================================*/ MarkConstructHeaderNeededItems(&defglobalPtr->header,DefglobalBinaryData(theEnv,execStatus)->NumberOfDefglobals++); } } }
globle struct defglobal *QFindDefglobal( void *theEnv, SYMBOL_HN *defglobalName) { struct defglobal *theDefglobal; for (theDefglobal = (struct defglobal *) EnvGetNextDefglobal(theEnv,NULL); theDefglobal != NULL; theDefglobal = (struct defglobal *) EnvGetNextDefglobal(theEnv,theDefglobal)) { if (defglobalName == theDefglobal->header.name) return (theDefglobal); } return(NULL); }
/******************************************************************************* Name: PrintChangedGlobals Description: Update the global window Arguments: None Returns: *******************************************************************************/ int PrintChangedGlobals() { void *theEnv = GetCurrentEnvironment(); void *dgPtr; int n; char *buffer; char *name,labelBuffer[MAX_CHAR_IN_BUF]; Window GlobalWin; Display *theDisplay; struct defmodule* theModule = (struct defmodule *) EnvGetCurrentModule(theEnv); /* Change the name of the window to the current module */ GlobalWin = XtWindow(globals); theDisplay = XtDisplay(globals); if (theModule != NULL) { name = EnvGetDefmoduleName(theEnv,theModule); strcpy(labelBuffer,"Globals Window("); strcat(labelBuffer,name); strcat(labelBuffer,")"); } else { strcpy(labelBuffer,"Globals Window"); } XStoreName(theDisplay,GlobalWin,labelBuffer); /* Clear the old contents */ n = 0; XtSetArg(TheArgs[n],XtNstring,"");n++; XtSetValues(globals_text,TheArgs,n); XawAsciiSourceFreeString(XawTextGetSource(globals_text)); /* Print the new defglobal list */ dgPtr = EnvGetNextDefglobal(theEnv,NULL); while (dgPtr != NULL) { buffer = (char *) EnvGetDefglobalPPForm(theEnv,(struct constructHeader *) dgPtr); EnvPrintRouter(theEnv,"xglobals",buffer); EnvPrintRouter(theEnv,"xglobals","\n"); dgPtr = EnvGetNextDefglobal(theEnv,dgPtr); } return 0; }
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 defglobal *theDefglobal; int moduleCount = 0, moduleArrayCount = 0, moduleArrayVersion = 1; int defglobalArrayCount = 0, defglobalArrayVersion = 1; FILE *moduleFile = NULL, *defglobalFile = NULL; /*================================================*/ /* Include the appropriate defglobal header file. */ /*================================================*/ fprintf(headerFP,"#include \"globldef.h\"\n"); /*===================================================================*/ /* Loop through all the modules and all the defglobals 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, "struct defglobalModule",ModulePrefix(DefglobalData(theEnv)->DefglobalCodeItem), FALSE,NULL); if (moduleFile == NULL) { CloseDefglobalFiles(theEnv,moduleFile,defglobalFile,maxIndices); return(0); } DefglobalModuleToCode(theEnv,moduleFile,theModule,imageID,maxIndices,moduleCount); moduleFile = CloseFileIfNeeded(theEnv,moduleFile,&moduleArrayCount,&moduleArrayVersion, maxIndices,NULL,NULL); for (theDefglobal = (struct defglobal *) EnvGetNextDefglobal(theEnv,NULL); theDefglobal != NULL; theDefglobal = (struct defglobal *) EnvGetNextDefglobal(theEnv,theDefglobal)) { defglobalFile = OpenFileIfNeeded(theEnv,defglobalFile,fileName,pathName,fileNameBuffer,fileID,imageID,&fileCount, defglobalArrayVersion,headerFP, "struct defglobal",ConstructPrefix(DefglobalData(theEnv)->DefglobalCodeItem), FALSE,NULL); if (defglobalFile == NULL) { CloseDefglobalFiles(theEnv,moduleFile,defglobalFile,maxIndices); return(0); } DefglobalToCode(theEnv,defglobalFile,theDefglobal,imageID,maxIndices,moduleCount); defglobalArrayCount++; defglobalFile = CloseFileIfNeeded(theEnv,defglobalFile,&defglobalArrayCount, &defglobalArrayVersion,maxIndices,NULL,NULL); } moduleCount++; moduleArrayCount++; } CloseDefglobalFiles(theEnv,moduleFile,defglobalFile,maxIndices); return(1); }
/******************************************************************************* 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, EXEC_STATUS, FILE *fp) { size_t space; struct defglobal *theDefglobal; struct bsaveDefglobal newDefglobal; struct defmodule *theModule; struct bsaveDefglobalModule tempDefglobalModule; struct defglobalModule *theModuleItem; /*==========================================================*/ /* Write out the amount of space taken up by the defglobal */ /* and defglobalModule data structures in the binary image. */ /*==========================================================*/ space = DefglobalBinaryData(theEnv,execStatus)->NumberOfDefglobals * sizeof(struct bsaveDefglobal) + (DefglobalBinaryData(theEnv,execStatus)->NumberOfDefglobalModules * sizeof(struct bsaveDefglobalModule)); GenWrite(&space,sizeof(size_t),fp); /*=================================================*/ /* Write out each defglobal module data structure. */ /*=================================================*/ DefglobalBinaryData(theEnv,execStatus)->NumberOfDefglobals = 0; for (theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,execStatus,NULL); theModule != NULL; theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,execStatus,theModule)) { EnvSetCurrentModule(theEnv,execStatus,(void *) theModule); theModuleItem = (struct defglobalModule *) GetModuleItem(theEnv,execStatus,NULL,FindModuleItem(theEnv,execStatus,"defglobal")->moduleIndex); AssignBsaveDefmdlItemHdrVals(&tempDefglobalModule.header, &theModuleItem->header); GenWrite(&tempDefglobalModule,sizeof(struct bsaveDefglobalModule),fp); } /*===========================*/ /* Write out each defglobal. */ /*===========================*/ DefglobalBinaryData(theEnv,execStatus)->NumberOfDefglobals = 0; for (theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,execStatus,NULL); theModule != NULL; theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,execStatus,theModule)) { EnvSetCurrentModule(theEnv,execStatus,(void *) theModule); for (theDefglobal = (struct defglobal *) EnvGetNextDefglobal(theEnv,execStatus,NULL); theDefglobal != NULL; theDefglobal = (struct defglobal *) EnvGetNextDefglobal(theEnv,execStatus,theDefglobal)) { AssignBsaveConstructHeaderVals(&newDefglobal.header, &theDefglobal->header); newDefglobal.initial = HashedExpressionIndex(theEnv,execStatus,theDefglobal->initial); GenWrite(&newDefglobal,sizeof(struct bsaveDefglobal),fp); } } /*=============================================================*/ /* If a binary image was already loaded when the bsave command */ /* was issued, then restore the counts indicating the number */ /* of defglobals and defglobal modules in the binary image */ /* (these were overwritten by the binary save). */ /*=============================================================*/ RestoreBloadCount(theEnv,execStatus,&DefglobalBinaryData(theEnv,execStatus)->NumberOfDefglobalModules); RestoreBloadCount(theEnv,execStatus,&DefglobalBinaryData(theEnv,execStatus)->NumberOfDefglobals); }