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
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #define _TMPLTBSC_SOURCE_
00037
00038 #include "setup.h"
00039
00040 #if DEFTEMPLATE_CONSTRUCT
00041
00042 #include <stdio.h>
00043 #define _STDIO_INCLUDED_
00044 #include <string.h>
00045
00046 #include "argacces.h"
00047 #include "memalloc.h"
00048 #include "scanner.h"
00049 #include "router.h"
00050 #include "extnfunc.h"
00051 #include "constrct.h"
00052 #include "cstrccom.h"
00053 #include "factrhs.h"
00054 #include "cstrcpsr.h"
00055 #include "tmpltpsr.h"
00056 #include "tmpltdef.h"
00057 #if BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE
00058 #include "tmpltbin.h"
00059 #endif
00060 #if CONSTRUCT_COMPILER && (! RUN_TIME)
00061 #include "tmpltcmp.h"
00062 #endif
00063 #include "tmpltutl.h"
00064 #include "envrnmnt.h"
00065
00066 #include "tmpltbsc.h"
00067
00068
00069
00070
00071
00072 #if ! DEFFACTS_CONSTRUCT
00073 static void ResetDeftemplates(void *);
00074 #endif
00075 static void ClearDeftemplates(void *);
00076 static void SaveDeftemplates(void *,void *,char *);
00077
00078
00079
00080
00081 globle void DeftemplateBasicCommands(
00082 void *theEnv)
00083 {
00084 #if ! DEFFACTS_CONSTRUCT
00085 EnvAddResetFunction(theEnv,"deftemplate",ResetDeftemplates,0);
00086 #endif
00087 EnvAddClearFunction(theEnv,"deftemplate",ClearDeftemplates,0);
00088 AddSaveFunction(theEnv,"deftemplate",SaveDeftemplates,10);
00089
00090 #if ! RUN_TIME
00091 EnvDefineFunction2(theEnv,"get-deftemplate-list",'m',PTIEF GetDeftemplateListFunction,"GetDeftemplateListFunction","01w");
00092 EnvDefineFunction2(theEnv,"undeftemplate",'v',PTIEF UndeftemplateCommand,"UndeftemplateCommand","11w");
00093 EnvDefineFunction2(theEnv,"deftemplate-module",'w',PTIEF DeftemplateModuleFunction,"DeftemplateModuleFunction","11w");
00094
00095 #if DEBUGGING_FUNCTIONS
00096 EnvDefineFunction2(theEnv,"list-deftemplates",'v', PTIEF ListDeftemplatesCommand,"ListDeftemplatesCommand","01w");
00097 EnvDefineFunction2(theEnv,"ppdeftemplate",'v',PTIEF PPDeftemplateCommand,"PPDeftemplateCommand","11w");
00098 #endif
00099
00100 #if (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE)
00101 DeftemplateBinarySetup(theEnv);
00102 #endif
00103
00104 #if CONSTRUCT_COMPILER && (! RUN_TIME)
00105 DeftemplateCompilerSetup(theEnv);
00106 #endif
00107
00108 #endif
00109 }
00110
00111
00112
00113
00114
00115
00116 #if ! DEFFACTS_CONSTRUCT
00117 static void ResetDeftemplates(
00118 void *theEnv)
00119 {
00120 struct fact *factPtr;
00121
00122 factPtr = StringToFact(theEnv,"(initial-fact)");
00123
00124 if (factPtr == NULL) return;
00125
00126 EnvAssert(theEnv,(void *) factPtr);
00127 }
00128 #endif
00129
00130
00131
00132
00133
00134 static void ClearDeftemplates(
00135 void *theEnv)
00136 {
00137 #if (! RUN_TIME) && (! BLOAD_ONLY)
00138
00139 CreateImpliedDeftemplate(theEnv,(SYMBOL_HN *) EnvAddSymbol(theEnv,"initial-fact"),FALSE);
00140 #else
00141 #if MAC_MCW || WIN_MCW || MAC_XCD
00142 #pragma unused(theEnv)
00143 #endif
00144 #endif
00145 }
00146
00147
00148
00149
00150
00151 static void SaveDeftemplates(
00152 void *theEnv,
00153 void *theModule,
00154 char *logicalName)
00155 {
00156 SaveConstruct(theEnv,theModule,logicalName,DeftemplateData(theEnv)->DeftemplateConstruct);
00157 }
00158
00159
00160
00161
00162
00163 globle void UndeftemplateCommand(
00164 void *theEnv)
00165 {
00166 UndefconstructCommand(theEnv,"undeftemplate",DeftemplateData(theEnv)->DeftemplateConstruct);
00167 }
00168
00169
00170
00171
00172
00173 globle intBool EnvUndeftemplate(
00174 void *theEnv,
00175 void *theDeftemplate)
00176 {
00177 return(Undefconstruct(theEnv,theDeftemplate,DeftemplateData(theEnv)->DeftemplateConstruct));
00178 }
00179
00180
00181
00182
00183
00184 globle void GetDeftemplateListFunction(
00185 void *theEnv,
00186 DATA_OBJECT_PTR returnValue)
00187 {
00188 GetConstructListFunction(theEnv,"get-deftemplate-list",returnValue,DeftemplateData(theEnv)->DeftemplateConstruct);
00189 }
00190
00191
00192
00193
00194
00195 globle void EnvGetDeftemplateList(
00196 void *theEnv,
00197 DATA_OBJECT_PTR returnValue,
00198 void *theModule)
00199 {
00200 GetConstructList(theEnv,returnValue,DeftemplateData(theEnv)->DeftemplateConstruct,(struct defmodule *) theModule);
00201 }
00202
00203
00204
00205
00206
00207 globle void *DeftemplateModuleFunction(
00208 void *theEnv)
00209 {
00210 return(GetConstructModuleCommand(theEnv,"deftemplate-module",DeftemplateData(theEnv)->DeftemplateConstruct));
00211 }
00212
00213 #if DEBUGGING_FUNCTIONS
00214
00215
00216
00217
00218
00219 globle void PPDeftemplateCommand(
00220 void *theEnv)
00221 {
00222 PPConstructCommand(theEnv,"ppdeftemplate",DeftemplateData(theEnv)->DeftemplateConstruct);
00223 }
00224
00225
00226
00227
00228
00229 globle int PPDeftemplate(
00230 void *theEnv,
00231 char *deftemplateName,
00232 char *logicalName)
00233 {
00234 return(PPConstruct(theEnv,deftemplateName,logicalName,DeftemplateData(theEnv)->DeftemplateConstruct));
00235 }
00236
00237
00238
00239
00240
00241 globle void ListDeftemplatesCommand(
00242 void *theEnv)
00243 {
00244 ListConstructCommand(theEnv,"list-deftemplates",DeftemplateData(theEnv)->DeftemplateConstruct);
00245 }
00246
00247
00248
00249
00250
00251 globle void EnvListDeftemplates(
00252 void *theEnv,
00253 char *logicalName,
00254 void *theModule)
00255 {
00256 ListConstruct(theEnv,DeftemplateData(theEnv)->DeftemplateConstruct,logicalName,(struct defmodule *) theModule);
00257 }
00258
00259
00260
00261
00262
00263 #if WIN_BTC
00264 #pragma argsused
00265 #endif
00266 globle unsigned EnvGetDeftemplateWatch(
00267 void *theEnv,
00268 void *theTemplate)
00269 {
00270 #if MAC_MCW || WIN_MCW || MAC_XCD
00271 #pragma unused(theEnv)
00272 #endif
00273
00274 return(((struct deftemplate *) theTemplate)->watch);
00275 }
00276
00277
00278
00279
00280
00281 #if WIN_BTC
00282 #pragma argsused
00283 #endif
00284 globle void EnvSetDeftemplateWatch(
00285 void *theEnv,
00286 unsigned newState,
00287 void *theTemplate)
00288 {
00289 #if MAC_MCW || WIN_MCW || MAC_XCD
00290 #pragma unused(theEnv)
00291 #endif
00292
00293 ((struct deftemplate *) theTemplate)->watch = newState;
00294 }
00295
00296
00297
00298
00299
00300 #if WIN_BTC
00301 #pragma argsused
00302 #endif
00303 globle unsigned DeftemplateWatchAccess(
00304 void *theEnv,
00305 int code,
00306 unsigned newState,
00307 EXPRESSION *argExprs)
00308 {
00309 #if MAC_MCW || WIN_MCW || MAC_XCD
00310 #pragma unused(code)
00311 #endif
00312
00313 return(ConstructSetWatchAccess(theEnv,DeftemplateData(theEnv)->DeftemplateConstruct,newState,argExprs,
00314 EnvGetDeftemplateWatch,EnvSetDeftemplateWatch));
00315 }
00316
00317
00318
00319
00320
00321 #if WIN_BTC
00322 #pragma argsused
00323 #endif
00324 globle unsigned DeftemplateWatchPrint(
00325 void *theEnv,
00326 char *logName,
00327 int code,
00328 EXPRESSION *argExprs)
00329 {
00330 #if MAC_MCW || WIN_MCW || MAC_XCD
00331 #pragma unused(code)
00332 #endif
00333
00334 return(ConstructPrintWatchAccess(theEnv,DeftemplateData(theEnv)->DeftemplateConstruct,logName,argExprs,
00335 EnvGetDeftemplateWatch,EnvSetDeftemplateWatch));
00336 }
00337
00338 #endif
00339
00340 #endif
00341
00342