00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #define _GLOBLCOM_SOURCE_
00026
00027 #include "setup.h"
00028
00029 #if DEFGLOBAL_CONSTRUCT
00030
00031 #include "extnfunc.h"
00032 #include "argacces.h"
00033 #include "prntutil.h"
00034 #include "router.h"
00035 #include "envrnmnt.h"
00036
00037 #include "globldef.h"
00038
00039 #include "globlcom.h"
00040
00041
00042
00043
00044
00045 #if DEBUGGING_FUNCTIONS
00046 static void PrintDefglobalValueForm(void *,char *,void *);
00047 #endif
00048
00049
00050
00051
00052 globle void DefglobalCommandDefinitions(
00053 void *theEnv)
00054 {
00055 #if ! RUN_TIME
00056 EnvDefineFunction2(theEnv,"set-reset-globals",'b',
00057 SetResetGlobalsCommand,"SetResetGlobalsCommand", "11");
00058 EnvDefineFunction2(theEnv,"get-reset-globals",'b',
00059 GetResetGlobalsCommand,"GetResetGlobalsCommand", "00");
00060
00061 #if DEBUGGING_FUNCTIONS
00062 EnvDefineFunction2(theEnv,"show-defglobals",'v',
00063 PTIEF ShowDefglobalsCommand,"ShowDefglobalsCommand", "01w");
00064 #endif
00065
00066 #else
00067 #if MAC_MCW || WIN_MCW || MAC_XCD
00068 #pragma unused(theEnv)
00069 #endif
00070 #endif
00071 }
00072
00073
00074
00075
00076
00077 globle int SetResetGlobalsCommand(
00078 void *theEnv)
00079 {
00080 int oldValue;
00081 DATA_OBJECT arg_ptr;
00082
00083
00084
00085
00086
00087 oldValue = EnvGetResetGlobals(theEnv);
00088
00089
00090
00091
00092
00093 if (EnvArgCountCheck(theEnv,"set-reset-globals",EXACTLY,1) == -1)
00094 { return(oldValue); }
00095
00096
00097
00098
00099
00100 EnvRtnUnknown(theEnv,1,&arg_ptr);
00101
00102 if ((arg_ptr.value == EnvFalseSymbol(theEnv)) && (arg_ptr.type == SYMBOL))
00103 { EnvSetResetGlobals(theEnv,FALSE); }
00104 else
00105 { EnvSetResetGlobals(theEnv,TRUE); }
00106
00107
00108
00109
00110
00111 return(oldValue);
00112 }
00113
00114
00115
00116
00117
00118 globle intBool EnvSetResetGlobals(
00119 void *theEnv,
00120 int value)
00121 {
00122 int ov;
00123
00124 ov = DefglobalData(theEnv)->ResetGlobals;
00125 DefglobalData(theEnv)->ResetGlobals = value;
00126 return(ov);
00127 }
00128
00129
00130
00131
00132
00133 globle int GetResetGlobalsCommand(
00134 void *theEnv)
00135 {
00136 int oldValue;
00137
00138 oldValue = EnvGetResetGlobals(theEnv);
00139
00140 if (EnvArgCountCheck(theEnv,"get-reset-globals",EXACTLY,0) == -1)
00141 { return(oldValue); }
00142
00143 return(oldValue);
00144 }
00145
00146
00147
00148
00149
00150 globle intBool EnvGetResetGlobals(
00151 void *theEnv)
00152 {
00153 return(DefglobalData(theEnv)->ResetGlobals);
00154 }
00155
00156 #if DEBUGGING_FUNCTIONS
00157
00158
00159
00160
00161
00162 globle void ShowDefglobalsCommand(
00163 void *theEnv)
00164 {
00165 struct defmodule *theModule;
00166 int numArgs, error;
00167
00168 if ((numArgs = EnvArgCountCheck(theEnv,"show-defglobals",NO_MORE_THAN,1)) == -1) return;
00169
00170 if (numArgs == 1)
00171 {
00172 theModule = GetModuleName(theEnv,"show-defglobals",1,&error);
00173 if (error) return;
00174 }
00175 else
00176 { theModule = ((struct defmodule *) EnvGetCurrentModule(theEnv)); }
00177
00178 EnvShowDefglobals(theEnv,WDISPLAY,theModule);
00179 }
00180
00181
00182
00183
00184
00185 globle void EnvShowDefglobals(
00186 void *theEnv,
00187 char *logicalName,
00188 void *vTheModule)
00189 {
00190 struct defmodule *theModule = (struct defmodule *) vTheModule;
00191 struct constructHeader *constructPtr;
00192 int allModules = FALSE;
00193 struct defmoduleItemHeader *theModuleItem;
00194
00195
00196
00197
00198
00199
00200 if (theModule == NULL)
00201 {
00202 theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL);
00203 allModules = TRUE;
00204 }
00205
00206
00207
00208
00209
00210 for (;
00211 theModule != NULL;
00212 theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,theModule))
00213 {
00214
00215
00216
00217
00218
00219
00220 if (allModules)
00221 {
00222 EnvPrintRouter(theEnv,logicalName,EnvGetDefmoduleName(theEnv,theModule));
00223 EnvPrintRouter(theEnv,logicalName,":\n");
00224 }
00225
00226
00227
00228
00229
00230
00231 theModuleItem = (struct defmoduleItemHeader *) GetModuleItem(theEnv,theModule,DefglobalData(theEnv)->DefglobalModuleIndex);
00232
00233 for (constructPtr = theModuleItem->firstItem;
00234 constructPtr != NULL;
00235 constructPtr = constructPtr->next)
00236 {
00237 if (EvaluationData(theEnv)->HaltExecution == TRUE) return;
00238
00239 if (allModules) EnvPrintRouter(theEnv,logicalName," ");
00240 PrintDefglobalValueForm(theEnv,logicalName,(void *) constructPtr);
00241 EnvPrintRouter(theEnv,logicalName,"\n");
00242 }
00243
00244
00245
00246
00247
00248
00249 if (! allModules) return;
00250 }
00251 }
00252
00253
00254
00255
00256
00257
00258 static void PrintDefglobalValueForm(
00259 void *theEnv,
00260 char *logicalName,
00261 void *vTheGlobal)
00262 {
00263 struct defglobal *theGlobal = (struct defglobal *) vTheGlobal;
00264
00265 EnvPrintRouter(theEnv,logicalName,"?*");
00266 EnvPrintRouter(theEnv,logicalName,ValueToString(theGlobal->header.name));
00267 EnvPrintRouter(theEnv,logicalName,"* = ");
00268 PrintDataObject(theEnv,logicalName,&theGlobal->current);
00269 }
00270
00271 #endif
00272
00273 #endif
00274