Esempio n. 1
0
globle void AllocateDefmoduleGlobals(
  void *theEnv)
  {
   AllocateEnvironmentData(theEnv,DEFMODULE_DATA,sizeof(struct defmoduleData),NULL);
   AddEnvironmentCleanupFunction(theEnv,"defmodules",DeallocateDefmoduleData,-1000);
   DefmoduleData(theEnv)->CallModuleChangeFunctions = TRUE;
   DefmoduleData(theEnv)->MainModuleRedefinable = TRUE;
  }
Esempio n. 2
0
globle void AddAfterModuleDefinedFunction(
  void *theEnv,
  char *name,
  void (*func)(void *),
  int priority)
  {
   DefmoduleData(theEnv)->AfterModuleDefinedFunctions =
     AddFunctionToCallList(theEnv,name,priority,func,DefmoduleData(theEnv)->AfterModuleDefinedFunctions,TRUE);
  }
Esempio n. 3
0
void AddAfterModuleChangeFunction(
  Environment *theEnv,
  const char *name,
  VoidCallFunction *func,
  int priority,
  void *context)
  {
   DefmoduleData(theEnv)->AfterModuleChangeFunctions =
     AddVoidFunctionToCallList(theEnv,name,priority,func,DefmoduleData(theEnv)->AfterModuleChangeFunctions,context);
  }
Esempio n. 4
0
static void BsaveStorage(
  void *theEnv,
  FILE *fp)
  {
   unsigned long space;

   space = sizeof(long) * 2;
   GenWrite(&space,(unsigned long) sizeof(unsigned long int),fp);
   GenWrite(&DefmoduleData(theEnv)->BNumberOfDefmodules,(unsigned long) sizeof(long int),fp);
   GenWrite(&DefmoduleData(theEnv)->NumberOfPortItems,(unsigned long) sizeof(long int),fp);
  }
Esempio n. 5
0
globle void RestoreCurrentModule(
  void *theEnv)
  {
   MODULE_STACK_ITEM *tmp;

   tmp = DefmoduleData(theEnv)->ModuleStack;
   DefmoduleData(theEnv)->ModuleStack = tmp->next;
   DefmoduleData(theEnv)->CallModuleChangeFunctions = tmp->changeFlag;
   DefmoduleData(theEnv)->CurrentModule = tmp->theModule;
   rtn_struct(theEnv,moduleStackItem,tmp);
  }
Esempio n. 6
0
void RestoreCurrentModule(
  Environment *theEnv)
  {
   ModuleStackItem *tmp;

   tmp = DefmoduleData(theEnv)->ModuleStack;
   DefmoduleData(theEnv)->ModuleStack = tmp->next;
   DefmoduleData(theEnv)->CallModuleChangeFunctions = tmp->changeFlag;
   DefmoduleData(theEnv)->CurrentModule = tmp->theModule;
   rtn_struct(theEnv,moduleStackItem,tmp);
  }
Esempio n. 7
0
globle void SaveCurrentModule(
  void *theEnv)
  {
   MODULE_STACK_ITEM *tmp;

   tmp = get_struct(theEnv,moduleStackItem);
   tmp->changeFlag = DefmoduleData(theEnv)->CallModuleChangeFunctions;
   DefmoduleData(theEnv)->CallModuleChangeFunctions = FALSE;
   tmp->theModule = DefmoduleData(theEnv)->CurrentModule;
   tmp->next = DefmoduleData(theEnv)->ModuleStack;
   DefmoduleData(theEnv)->ModuleStack = tmp;
  }
Esempio n. 8
0
void SaveCurrentModule(
  Environment *theEnv)
  {
   ModuleStackItem *tmp;

   tmp = get_struct(theEnv,moduleStackItem);
   tmp->changeFlag = DefmoduleData(theEnv)->CallModuleChangeFunctions;
   DefmoduleData(theEnv)->CallModuleChangeFunctions = false;
   tmp->theModule = DefmoduleData(theEnv)->CurrentModule;
   tmp->next = DefmoduleData(theEnv)->ModuleStack;
   DefmoduleData(theEnv)->ModuleStack = tmp;
  }
Esempio n. 9
0
/*******************************************************************************
          Name:        UpdateMenus
          Description: Updates the windows if necessary
          Arguments:   None 
          Returns:     None
*******************************************************************************/
void UpdateMenus()
  {
   void *theEnv = GetCurrentEnvironment();
  static long LastModuleIndex = -1; 
  Boolean UpdateAll = False;

  UpdateWindowsMenu();
  if(LastModuleIndex != DefmoduleData(theEnv)->ModuleChangeIndex)
   {
     UpdateAll = True;
     LastModuleIndex = DefmoduleData(theEnv)->ModuleChangeIndex;
   }
#if DEFRULE_CONSTRUCT
  if((Browse_status[AGENDA_WIN] == True ) ? (UpdateAll || (EnvGetAgendaChanged(theEnv) == CLIPS_TRUE)) : FALSE)
      {
      EnvSetAgendaChanged(theEnv,CLIPS_FALSE);
      PrintChangedAgenda();
      }

 if((Browse_status[FOCUS_WIN] == True) ? ( UpdateAll || (EnvGetFocusChanged(theEnv) == CLIPS_TRUE)) : FALSE)
     {
     EnvSetFocusChanged(theEnv,CLIPS_FALSE);
     PrintChangedFocus();
     }

#endif

#if DEFTEMPLATE_CONSTRUCT
  if((Browse_status[FACT_WIN] == True) ? ( UpdateAll || (EnvGetFactListChanged(theEnv) == CLIPS_TRUE)) : FALSE)
      {
      EnvSetFactListChanged(theEnv,CLIPS_FALSE);
      PrintChangedFacts();
      }
#endif

#if OBJECT_SYSTEM
 if((Browse_status[INSTANCE_WIN]) ? (UpdateAll || (EnvGetInstancesChanged(theEnv) == CLIPS_TRUE)) : FALSE)
      {
      EnvSetInstancesChanged(theEnv,CLIPS_FALSE);
      PrintChangedInstances();
      }
#endif

#ifdef DEFGLOBAL_CONSTRUCT
 if((Browse_status[GLOBAL_WIN] == True) ? (UpdateAll || (EnvGetGlobalsChanged(theEnv) == CLIPS_TRUE)) : FALSE)
      {
      EnvSetGlobalsChanged(theEnv,CLIPS_FALSE);
      PrintChangedGlobals();
      }

#endif
  }
Esempio n. 10
0
globle void AddPortConstructItem(
  void *theEnv,
  char *theName,
  int theType)
  {
   struct portConstructItem *newItem;

   newItem = get_struct(theEnv,portConstructItem);
   newItem->constructName = theName;
   newItem->typeExpected = theType;
   newItem->next = DefmoduleData(theEnv)->ListOfPortConstructItems;
   DefmoduleData(theEnv)->ListOfPortConstructItems = newItem;
  }
Esempio n. 11
0
static void BloadBinaryItem(
  void *theEnv)
  {
   unsigned long int space;

   GenReadBinary(theEnv,&space,(unsigned long) sizeof(unsigned long int));
   if (DefmoduleData(theEnv)->BNumberOfDefmodules == 0) return;

   BloadandRefresh(theEnv,DefmoduleData(theEnv)->BNumberOfDefmodules,(unsigned) sizeof(struct bsaveDefmodule),UpdateDefmodule);
   BloadandRefresh(theEnv,DefmoduleData(theEnv)->NumberOfPortItems,(unsigned) sizeof(struct bsavePortItem),UpdatePortItem);

   SetListOfDefmodules(theEnv,(void *) DefmoduleData(theEnv)->DefmoduleArray);
   EnvSetCurrentModule(theEnv,(void *) EnvGetNextDefmodule(theEnv,NULL));
  }
Esempio n. 12
0
globle void *GetModuleItem(
  void *theEnv,
  struct defmodule *theModule,
  int moduleItemIndex)
  {
   if (theModule == NULL)
     {
      if (DefmoduleData(theEnv)->CurrentModule == NULL) return(NULL);
      theModule = DefmoduleData(theEnv)->CurrentModule;
     }

   if (theModule->itemsArray == NULL) return (NULL);
   return ((void *) theModule->itemsArray[moduleItemIndex]);
  }
Esempio n. 13
0
void *GetModuleItem(
  Environment *theEnv,
  Defmodule *theModule,
  unsigned moduleItemIndex)
  {
   if (theModule == NULL)
     {
      if (DefmoduleData(theEnv)->CurrentModule == NULL) return NULL;
      theModule = DefmoduleData(theEnv)->CurrentModule;
     }

   if (theModule->itemsArray == NULL) return (NULL);

   return ((void *) theModule->itemsArray[moduleItemIndex]);
  }
Esempio n. 14
0
void SetModuleItem(
  Environment *theEnv,
  Defmodule *theModule,
  unsigned moduleItemIndex,
  void *newValue)
  {
   if (theModule == NULL)
     {
      if (DefmoduleData(theEnv)->CurrentModule == NULL) return;
      theModule = DefmoduleData(theEnv)->CurrentModule;
     }

   if (theModule->itemsArray == NULL) return;
   theModule->itemsArray[moduleItemIndex] = (struct defmoduleItemHeader *) newValue;
  }
Esempio n. 15
0
globle void SetModuleItem(
  void *theEnv,
  struct defmodule *theModule,
  int moduleItemIndex,
  void *newValue)
  {
   if (theModule == NULL)
     {
      if (DefmoduleData(theEnv)->CurrentModule == NULL) return;
      theModule = DefmoduleData(theEnv)->CurrentModule;
     }

   if (theModule->itemsArray == NULL) return;
   theModule->itemsArray[moduleItemIndex] = (struct defmoduleItemHeader *) newValue;
  }
Esempio n. 16
0
globle void DefmoduleCompilerSetup(
  void *theEnv)
  {
   DefmoduleData(theEnv)->DefmoduleCodeItem = 
      AddCodeGeneratorItem(theEnv,"defmodule",200,BeforeDefmodulesToCode,
                           InitDefmoduleCode,ConstructToCode,3);
  }
Esempio n. 17
0
globle void *EnvGetNextDefmodule(
  void *theEnv,
  void *defmodulePtr)
  {
   if (defmodulePtr == NULL)
     { return((void *) DefmoduleData(theEnv)->ListOfDefmodules); }
   else
     { return((void *) (((struct defmodule *) defmodulePtr)->next)); }
  }
Esempio n. 18
0
Defmodule *GetNextDefmodule(
  Environment *theEnv,
  Defmodule *defmodulePtr)
  {
   if (defmodulePtr == NULL)
     { return DefmoduleData(theEnv)->ListOfDefmodules; }
   else
     { return (Defmodule *) defmodulePtr->header.next; }
  }
Esempio n. 19
0
unsigned short GetNumberOfDefmodules(
  Environment *theEnv)
  {
#if DEFMODULE_CONSTRUCT && (! RUN_TIME) && (! BLOAD_ONLY)
   return DefmoduleData(theEnv)->NumberOfDefmodules;
#else
   return 1;
#endif
  }
Esempio n. 20
0
static intBool DeleteDefmodule(
  void *theEnv,
  void *theConstruct)
  {
   if (strcmp(EnvGetDefmoduleName(theEnv,theConstruct),"MAIN") == 0)
     { return(DefmoduleData(theEnv)->MainModuleRedefinable); }

   return(FALSE);
  }
Esempio n. 21
0
globle void *EnvSetCurrentModule(
  void *theEnv,
  void *xNewValue)
  {
   struct defmodule *newValue = (struct defmodule *) xNewValue;
   struct callFunctionItem *changeFunctions;
   void *rv;

   /*=============================================*/
   /* Change the current module to the specified  */
   /* module and save the previous current module */
   /* for the return value.                       */
   /*=============================================*/

   rv = (void *) DefmoduleData(theEnv)->CurrentModule;
   DefmoduleData(theEnv)->CurrentModule = newValue;

   /*==========================================================*/
   /* Call the list of registered functions that need to know  */
   /* when the module has changed. The module change functions */
   /* should only be called if this is a "real" module change. */
   /* Many routines temporarily change the module to look for  */
   /* constructs, etc. The SaveCurrentModule function will     */
   /* disable the change functions from being called.          */
   /*==========================================================*/

   if (DefmoduleData(theEnv)->CallModuleChangeFunctions)
     {
      DefmoduleData(theEnv)->ModuleChangeIndex++;
      changeFunctions = DefmoduleData(theEnv)->AfterModuleChangeFunctions;
      while (changeFunctions != NULL)
        {
         (* (void (*)(void *)) changeFunctions->func)(theEnv);
         changeFunctions = changeFunctions->next;
        }
     }

   /*=====================================*/
   /* Return the previous current module. */
   /*=====================================*/

   return(rv);
  }
Esempio n. 22
0
void SetListOfDefmodules(
  Environment *theEnv,
  Defmodule *defmodulePtr)
  {
   DefmoduleData(theEnv)->ListOfDefmodules = defmodulePtr;
   DefmoduleData(theEnv)->LastDefmodule = DefmoduleData(theEnv)->ListOfDefmodules;

   if (DefmoduleData(theEnv)->LastDefmodule == NULL) return;
   DefmoduleData(theEnv)->LastDefmodule->header.env = theEnv;

   while (DefmoduleData(theEnv)->LastDefmodule->header.next != NULL)
     {
      DefmoduleData(theEnv)->LastDefmodule = (Defmodule *) DefmoduleData(theEnv)->LastDefmodule->header.next;
      DefmoduleData(theEnv)->LastDefmodule->header.env = theEnv;
     }
  }
Esempio n. 23
0
Defmodule *SetCurrentModule(
  Environment *theEnv,
  Defmodule *newModule)
  {
   struct voidCallFunctionItem *changeFunctions;
   Defmodule *oldModule;

   /*=============================================*/
   /* Change the current module to the specified  */
   /* module and save the previous current module */
   /* for the return value.                       */
   /*=============================================*/

   oldModule = DefmoduleData(theEnv)->CurrentModule;
   DefmoduleData(theEnv)->CurrentModule = newModule;

   /*==========================================================*/
   /* Call the list of registered functions that need to know  */
   /* when the module has changed. The module change functions */
   /* should only be called if this is a "real" module change. */
   /* Many routines temporarily change the module to look for  */
   /* constructs, etc. The SaveCurrentModule function will     */
   /* disable the change functions from being called.          */
   /*==========================================================*/

   if (DefmoduleData(theEnv)->CallModuleChangeFunctions)
     {
      DefmoduleData(theEnv)->ModuleChangeIndex++;
      changeFunctions = DefmoduleData(theEnv)->AfterModuleChangeFunctions;
      while (changeFunctions != NULL)
        {
         (*changeFunctions->func)(theEnv,changeFunctions->context);
         changeFunctions = changeFunctions->next;
        }
     }

   /*=====================================*/
   /* Return the previous current module. */
   /*=====================================*/

   return oldModule;
  }
Esempio n. 24
0
static void BloadStorage(
  void *theEnv)
  {
   unsigned long int space;

   /*=======================================*/
   /* Determine the number of defmodule and */
   /* port item data structures to be read. */
   /*=======================================*/

   GenReadBinary(theEnv,&space,(unsigned long) sizeof(unsigned long int));
   GenReadBinary(theEnv,&DefmoduleData(theEnv)->BNumberOfDefmodules,(unsigned long) sizeof(long int));
   GenReadBinary(theEnv,&DefmoduleData(theEnv)->NumberOfPortItems,(unsigned long) sizeof(long int));

   /*================================*/
   /* Allocate the space needed for  */
   /* the defmodule data structures. */
   /*================================*/

   if (DefmoduleData(theEnv)->BNumberOfDefmodules == 0)
     {
      DefmoduleData(theEnv)->DefmoduleArray = NULL;
      return;
     }

   space = (unsigned long) (DefmoduleData(theEnv)->BNumberOfDefmodules * sizeof(struct defmodule));
   DefmoduleData(theEnv)->DefmoduleArray = (struct defmodule *) genlongalloc(theEnv,space);

   /*================================*/
   /* Allocate the space needed for  */
   /* the port item data structures. */
   /*================================*/

   if (DefmoduleData(theEnv)->NumberOfPortItems == 0)
     {
      DefmoduleData(theEnv)->PortItemArray = NULL;
      return;
     }

   space = (unsigned long) (DefmoduleData(theEnv)->NumberOfPortItems * sizeof(struct portItem));
   DefmoduleData(theEnv)->PortItemArray = (struct portItem *) genlongalloc(theEnv,space);
  }
Esempio n. 25
0
globle void MarkModulesAsUnvisited(
  void *theEnv,
  EXEC_STATUS)
  {
   struct defmodule *theModule;

   DefmoduleData(theEnv,execStatus)->CurrentModule->visitedFlag = FALSE;
   for (theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,execStatus,NULL);
        theModule != NULL;
        theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,execStatus,theModule))
     { theModule->visitedFlag = FALSE; }
  }
Esempio n. 26
0
unsigned RegisterModuleItem(
  Environment *theEnv,
  const char *theItem,
  AllocateModuleFunction *allocateFunction,
  FreeModuleFunction *freeFunction,
  void *(*bloadModuleReference)(Environment *,unsigned long),
  void  (*constructsToCModuleReference)(Environment *,FILE *,unsigned long,unsigned int,unsigned int),
  FindConstructFunction *findFunction)
  {
   struct moduleItem *newModuleItem;

   newModuleItem = get_struct(theEnv,moduleItem);
   newModuleItem->name = theItem;
   newModuleItem->allocateFunction = allocateFunction;
   newModuleItem->freeFunction = freeFunction;
   newModuleItem->bloadModuleReference = bloadModuleReference;
   newModuleItem->constructsToCModuleReference = constructsToCModuleReference;
   newModuleItem->findFunction = findFunction;
   newModuleItem->moduleIndex = DefmoduleData(theEnv)->NumberOfModuleItems++;
   newModuleItem->next = NULL;

   if (DefmoduleData(theEnv)->LastModuleItem == NULL)
     {
      DefmoduleData(theEnv)->ListOfModuleItems = newModuleItem;
      DefmoduleData(theEnv)->LastModuleItem = newModuleItem;
     }
   else
     {
      DefmoduleData(theEnv)->LastModuleItem->next = newModuleItem;
      DefmoduleData(theEnv)->LastModuleItem = newModuleItem;
     }

   return newModuleItem->moduleIndex;
  }
Esempio n. 27
0
void UpdateStatus(void)
  {  
   void *theEnv = GlobalEnv;
   static long lastModuleIndex = -1;

   if (lastModuleIndex != DefmoduleData(theEnv)->ModuleChangeIndex)
     {
#if DEFRULE_CONSTRUCT
      EnvSetFocusChanged(theEnv,TRUE);
      EnvSetAgendaChanged(theEnv,TRUE);
#endif
#if DEFTEMPLATE_CONSTRUCT
      EnvSetFactListChanged(theEnv,TRUE);
#endif
#if OBJECT_SYSTEM
      EnvSetInstancesChanged(theEnv,TRUE);
#endif
#if DEFGLOBAL_CONSTRUCT
      EnvSetGlobalsChanged(theEnv,TRUE);
#endif
      lastModuleIndex = DefmoduleData(GlobalEnv)->ModuleChangeIndex;
     }

#if DEFRULE_CONSTRUCT
   UpdateStatusContent(AgendaWindow);
   UpdateStatusContent(FocusWindow);
#endif

#if DEFTEMPLATE_CONSTRUCT
   UpdateStatusContent(FactsWindow);
#endif

#if OBJECT_SYSTEM
   UpdateStatusContent(InstancesWindow);
#endif

#if DEFGLOBAL_CONSTRUCT
   UpdateStatusContent(GlobalsWindow);    
#endif
}
Esempio n. 28
0
globle int RegisterModuleItem(
   void *theEnv,
   char *theItem,
   void *(*allocateFunction)(void *),
   void (*freeFunction)(void *,void *),
   void *(*bloadModuleReference)(void *,int),
   void  (*constructsToCModuleReference)(void *,FILE *,int,int,int),
   void *(*findFunction)(void *,char *))
  {
   struct moduleItem *newModuleItem;

   newModuleItem = get_struct(theEnv,moduleItem);
   newModuleItem->name = theItem;
   newModuleItem->allocateFunction = allocateFunction;
   newModuleItem->freeFunction = freeFunction;
   newModuleItem->bloadModuleReference = bloadModuleReference;
   newModuleItem->constructsToCModuleReference = constructsToCModuleReference;
   newModuleItem->findFunction = findFunction;
   newModuleItem->moduleIndex = DefmoduleData(theEnv)->NumberOfModuleItems++;
   newModuleItem->next = NULL;

   if (DefmoduleData(theEnv)->LastModuleItem == NULL)
     {
      DefmoduleData(theEnv)->ListOfModuleItems = newModuleItem;
      DefmoduleData(theEnv)->LastModuleItem = newModuleItem;
     }
   else
     {
      DefmoduleData(theEnv)->LastModuleItem->next = newModuleItem;
      DefmoduleData(theEnv)->LastModuleItem = newModuleItem;
     }

   return(newModuleItem->moduleIndex);
  }
Esempio n. 29
0
globle struct portConstructItem *ValidPortConstructItem(
  void *theEnv,
  char *theName)
  {
   struct portConstructItem *theItem;

   for (theItem = DefmoduleData(theEnv)->ListOfPortConstructItems;
        theItem != NULL;
        theItem = theItem->next)
     { if (strcmp(theName,theItem->constructName) == 0) return(theItem); }

   return(NULL);
  }
Esempio n. 30
0
globle struct moduleItem *FindModuleItem(
  void *theEnv,
  char *theName)
  {
   struct moduleItem *theModuleItem;

   for (theModuleItem = DefmoduleData(theEnv)->ListOfModuleItems;
        theModuleItem != NULL;
        theModuleItem = theModuleItem->next)
     { if (strcmp(theModuleItem->name,theName) == 0) return(theModuleItem); }

   return(NULL);
  }