00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #define _MODULBSC_SOURCE_
00025
00026 #include "setup.h"
00027
00028 #include <stdio.h>
00029 #define _STDIO_INCLUDED_
00030 #include <string.h>
00031
00032 #include "constrct.h"
00033 #include "extnfunc.h"
00034 #include "modulbin.h"
00035 #include "prntutil.h"
00036 #include "modulcmp.h"
00037 #include "router.h"
00038 #include "argacces.h"
00039 #include "bload.h"
00040 #include "envrnmnt.h"
00041
00042 #include "modulbsc.h"
00043
00044
00045
00046
00047
00048 static void ClearDefmodules(void *);
00049 #if DEFMODULE_CONSTRUCT
00050 static void SaveDefmodules(void *,void *,char *);
00051 #endif
00052
00053
00054
00055
00056 globle void DefmoduleBasicCommands(
00057 void *theEnv)
00058 {
00059 EnvAddClearFunction(theEnv,"defmodule",ClearDefmodules,2000);
00060
00061 #if DEFMODULE_CONSTRUCT
00062 AddSaveFunction(theEnv,"defmodule",SaveDefmodules,1100);
00063
00064 #if ! RUN_TIME
00065 EnvDefineFunction2(theEnv,"get-defmodule-list",'m',PTIEF EnvGetDefmoduleList,"EnvGetDefmoduleList","00");
00066
00067 #if DEBUGGING_FUNCTIONS
00068 EnvDefineFunction2(theEnv,"list-defmodules",'v', PTIEF ListDefmodulesCommand,"ListDefmodulesCommand","00");
00069 EnvDefineFunction2(theEnv,"ppdefmodule",'v',PTIEF PPDefmoduleCommand,"PPDefmoduleCommand","11w");
00070 #endif
00071 #endif
00072 #endif
00073
00074 #if (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE)
00075 DefmoduleBinarySetup(theEnv);
00076 #endif
00077
00078 #if CONSTRUCT_COMPILER && (! RUN_TIME)
00079 DefmoduleCompilerSetup(theEnv);
00080 #endif
00081 }
00082
00083
00084
00085
00086
00087 static void ClearDefmodules(
00088 void *theEnv)
00089 {
00090 #if (BLOAD || BLOAD_AND_BSAVE || BLOAD_ONLY) && (! RUN_TIME)
00091 if (Bloaded(theEnv) == TRUE) return;
00092 #endif
00093 #if (! RUN_TIME)
00094 RemoveAllDefmodules(theEnv);
00095
00096 CreateMainModule(theEnv);
00097 DefmoduleData(theEnv)->MainModuleRedefinable = TRUE;
00098 #else
00099 #if MAC_MCW || WIN_MCW || MAC_XCD
00100 #pragma unused(theEnv)
00101 #endif
00102 #endif
00103 }
00104
00105 #if DEFMODULE_CONSTRUCT
00106
00107
00108
00109
00110
00111 static void SaveDefmodules(
00112 void *theEnv,
00113 void *theModule,
00114 char *logicalName)
00115 {
00116 char *ppform;
00117
00118 ppform = EnvGetDefmodulePPForm(theEnv,theModule);
00119 if (ppform != NULL)
00120 {
00121 PrintInChunks(theEnv,logicalName,ppform);
00122 EnvPrintRouter(theEnv,logicalName,"\n");
00123 }
00124 }
00125
00126
00127
00128
00129
00130 globle void EnvGetDefmoduleList(
00131 void *theEnv,
00132 DATA_OBJECT_PTR returnValue)
00133 {
00134 OldGetConstructList(theEnv,returnValue,EnvGetNextDefmodule,EnvGetDefmoduleName);
00135 }
00136
00137 #if DEBUGGING_FUNCTIONS
00138
00139
00140
00141
00142
00143 globle void PPDefmoduleCommand(
00144 void *theEnv)
00145 {
00146 char *defmoduleName;
00147
00148 defmoduleName = GetConstructName(theEnv,"ppdefmodule","defmodule name");
00149 if (defmoduleName == NULL) return;
00150
00151 PPDefmodule(theEnv,defmoduleName,WDISPLAY);
00152
00153 return;
00154 }
00155
00156
00157
00158
00159
00160 globle int PPDefmodule(
00161 void *theEnv,
00162 char *defmoduleName,
00163 char *logicalName)
00164 {
00165 void *defmodulePtr;
00166
00167 defmodulePtr = EnvFindDefmodule(theEnv,defmoduleName);
00168 if (defmodulePtr == NULL)
00169 {
00170 CantFindItemErrorMessage(theEnv,"defmodule",defmoduleName);
00171 return(FALSE);
00172 }
00173
00174 if (EnvGetDefmodulePPForm(theEnv,defmodulePtr) == NULL) return(TRUE);
00175 PrintInChunks(theEnv,logicalName,EnvGetDefmodulePPForm(theEnv,defmodulePtr));
00176 return(TRUE);
00177 }
00178
00179
00180
00181
00182
00183 globle void ListDefmodulesCommand(
00184 void *theEnv)
00185 {
00186 if (EnvArgCountCheck(theEnv,"list-defmodules",EXACTLY,0) == -1) return;
00187
00188 EnvListDefmodules(theEnv,WDISPLAY);
00189 }
00190
00191
00192
00193
00194
00195 globle void EnvListDefmodules(
00196 void *theEnv,
00197 char *logicalName)
00198 {
00199 void *theModule;
00200 int count = 0;
00201
00202 for (theModule = EnvGetNextDefmodule(theEnv,NULL);
00203 theModule != NULL;
00204 theModule = EnvGetNextDefmodule(theEnv,theModule))
00205 {
00206 EnvPrintRouter(theEnv,logicalName,EnvGetDefmoduleName(theEnv,theModule));
00207 EnvPrintRouter(theEnv,logicalName,"\n");
00208 count++;
00209 }
00210
00211 PrintTally(theEnv,logicalName,count,"defmodule","defmodules");
00212 }
00213
00214 #endif
00215
00216 #endif
00217
00218