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
00037
00038
00039
00040
00041 #include "setup.h"
00042
00043 #if DEFGENERIC_CONSTRUCT
00044
00045 #include <string.h>
00046
00047 #if DEFRULE_CONSTRUCT
00048 #include "network.h"
00049 #endif
00050
00051 #if BLOAD || BLOAD_AND_BSAVE
00052 #include "bload.h"
00053 #endif
00054
00055 #if BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE
00056 #include "genrcbin.h"
00057 #endif
00058
00059 #if CONSTRUCT_COMPILER
00060 #include "genrccmp.h"
00061 #endif
00062
00063 #if (! BLOAD_ONLY) && (! RUN_TIME)
00064 #include "constrct.h"
00065 #include "genrcpsr.h"
00066 #endif
00067
00068 #if OBJECT_SYSTEM
00069 #include "classcom.h"
00070 #include "inscom.h"
00071 #endif
00072
00073 #if DEBUGGING_FUNCTIONS
00074 #include "watch.h"
00075 #endif
00076
00077 #include "argacces.h"
00078 #include "cstrcpsr.h"
00079 #include "envrnmnt.h"
00080 #include "extnfunc.h"
00081 #include "genrcexe.h"
00082 #include "memalloc.h"
00083 #include "modulpsr.h"
00084 #include "multifld.h"
00085 #include "router.h"
00086
00087 #define _GENRCCOM_SOURCE_
00088 #include "genrccom.h"
00089
00090
00091
00092
00093
00094
00095
00096 static void PrintGenericCall(void *,char *,void *);
00097 static intBool EvaluateGenericCall(void *,void *,DATA_OBJECT *);
00098 static void DecrementGenericBusyCount(void *,void *);
00099 static void IncrementGenericBusyCount(void *,void *);
00100 static void DeallocateDefgenericData(void *);
00101 #if ! RUN_TIME
00102 static void DestroyDefgenericAction(void *,struct constructHeader *,void *);
00103 #endif
00104
00105 #if (! BLOAD_ONLY) && (! RUN_TIME)
00106
00107 static void SaveDefgenerics(void *,void *,char *);
00108 static void SaveDefmethods(void *,void *,char *);
00109 static void SaveDefmethodsForDefgeneric(void *,struct constructHeader *,void *);
00110 static void RemoveDefgenericMethod(void *,DEFGENERIC *,long);
00111
00112 #endif
00113
00114 #if DEBUGGING_FUNCTIONS
00115 static long ListMethodsForGeneric(void *,char *,DEFGENERIC *);
00116 static unsigned DefgenericWatchAccess(void *,int,unsigned,EXPRESSION *);
00117 static unsigned DefgenericWatchPrint(void *,char *,int,EXPRESSION *);
00118 static unsigned DefmethodWatchAccess(void *,int,unsigned,EXPRESSION *);
00119 static unsigned DefmethodWatchPrint(void *,char *,int,EXPRESSION *);
00120 static unsigned DefmethodWatchSupport(void *,char *,char *,unsigned,
00121 void (*)(void *,char *,void *,long),
00122 void (*)(void *,unsigned,void *,long),
00123 EXPRESSION *);
00124 static void PrintMethodWatchFlag(void *,char *,void *,long);
00125 #endif
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 globle void SetupGenericFunctions(
00143 void *theEnv)
00144 {
00145 ENTITY_RECORD genericEntityRecord =
00146 { "GCALL", GCALL,0,0,1,
00147 PrintGenericCall,PrintGenericCall,
00148 NULL,EvaluateGenericCall,NULL,
00149 DecrementGenericBusyCount,IncrementGenericBusyCount,
00150 NULL,NULL,NULL,NULL,NULL };
00151
00152 AllocateEnvironmentData(theEnv,DEFGENERIC_DATA,sizeof(struct defgenericData),DeallocateDefgenericData);
00153 memcpy(&DefgenericData(theEnv)->GenericEntityRecord,&genericEntityRecord,sizeof(struct entityRecord));
00154
00155 InstallPrimitive(theEnv,&DefgenericData(theEnv)->GenericEntityRecord,GCALL);
00156
00157 DefgenericData(theEnv)->DefgenericModuleIndex =
00158 RegisterModuleItem(theEnv,"defgeneric",
00159 #if (! RUN_TIME)
00160 AllocateDefgenericModule,FreeDefgenericModule,
00161 #else
00162 NULL,NULL,
00163 #endif
00164 #if BLOAD_AND_BSAVE || BLOAD || BLOAD_ONLY
00165 BloadDefgenericModuleReference,
00166 #else
00167 NULL,
00168 #endif
00169 #if CONSTRUCT_COMPILER && (! RUN_TIME)
00170 DefgenericCModuleReference,
00171 #else
00172 NULL,
00173 #endif
00174 EnvFindDefgeneric);
00175
00176 DefgenericData(theEnv)->DefgenericConstruct = AddConstruct(theEnv,"defgeneric","defgenerics",
00177 #if (! BLOAD_ONLY) && (! RUN_TIME)
00178 ParseDefgeneric,
00179 #else
00180 NULL,
00181 #endif
00182 EnvFindDefgeneric,
00183 GetConstructNamePointer,GetConstructPPForm,
00184 GetConstructModuleItem,EnvGetNextDefgeneric,
00185 SetNextConstruct,EnvIsDefgenericDeletable,
00186 EnvUndefgeneric,
00187 #if (! BLOAD_ONLY) && (! RUN_TIME)
00188 RemoveDefgeneric
00189 #else
00190 NULL
00191 #endif
00192 );
00193
00194 #if ! RUN_TIME
00195 AddClearReadyFunction(theEnv,"defgeneric",ClearDefgenericsReady,0);
00196
00197 #if BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE
00198 SetupGenericsBload(theEnv);
00199 #endif
00200
00201 #if CONSTRUCT_COMPILER
00202 SetupGenericsCompiler(theEnv);
00203 #endif
00204
00205 #if ! BLOAD_ONLY
00206 #if DEFMODULE_CONSTRUCT
00207 AddPortConstructItem(theEnv,"defgeneric",SYMBOL);
00208 #endif
00209 AddConstruct(theEnv,"defmethod","defmethods",ParseDefmethod,
00210 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
00211
00212
00213
00214
00215
00216
00217
00218
00219 AddSaveFunction(theEnv,"defgeneric",SaveDefgenerics,1000);
00220 AddSaveFunction(theEnv,"defmethod",SaveDefmethods,-1000);
00221 EnvDefineFunction2(theEnv,"undefgeneric",'v',PTIEF UndefgenericCommand,"UndefgenericCommand","11w");
00222 EnvDefineFunction2(theEnv,"undefmethod",'v',PTIEF UndefmethodCommand,"UndefmethodCommand","22*wg");
00223 #endif
00224
00225 EnvDefineFunction2(theEnv,"call-next-method",'u',PTIEF CallNextMethod,"CallNextMethod","00");
00226 FuncSeqOvlFlags(theEnv,"call-next-method",TRUE,FALSE);
00227 EnvDefineFunction2(theEnv,"call-specific-method",'u',PTIEF CallSpecificMethod,
00228 "CallSpecificMethod","2**wi");
00229 FuncSeqOvlFlags(theEnv,"call-specific-method",TRUE,FALSE);
00230 EnvDefineFunction2(theEnv,"override-next-method",'u',PTIEF OverrideNextMethod,
00231 "OverrideNextMethod",NULL);
00232 FuncSeqOvlFlags(theEnv,"override-next-method",TRUE,FALSE);
00233 EnvDefineFunction2(theEnv,"next-methodp",'b',PTIEF NextMethodP,"NextMethodP","00");
00234 FuncSeqOvlFlags(theEnv,"next-methodp",TRUE,FALSE);
00235
00236 EnvDefineFunction2(theEnv,"(gnrc-current-arg)",'u',PTIEF GetGenericCurrentArgument,
00237 "GetGenericCurrentArgument",NULL);
00238
00239 #if DEBUGGING_FUNCTIONS
00240 EnvDefineFunction2(theEnv,"ppdefgeneric",'v',PTIEF PPDefgenericCommand,"PPDefgenericCommand","11w");
00241 EnvDefineFunction2(theEnv,"list-defgenerics",'v',PTIEF ListDefgenericsCommand,"ListDefgenericsCommand","01");
00242 EnvDefineFunction2(theEnv,"ppdefmethod",'v',PTIEF PPDefmethodCommand,"PPDefmethodCommand","22*wi");
00243 EnvDefineFunction2(theEnv,"list-defmethods",'v',PTIEF ListDefmethodsCommand,"ListDefmethodsCommand","01w");
00244 EnvDefineFunction2(theEnv,"preview-generic",'v',PTIEF PreviewGeneric,"PreviewGeneric","1**w");
00245 #endif
00246
00247 EnvDefineFunction2(theEnv,"get-defgeneric-list",'m',PTIEF GetDefgenericListFunction,
00248 "GetDefgenericListFunction","01");
00249 EnvDefineFunction2(theEnv,"get-defmethod-list",'m',PTIEF GetDefmethodListCommand,
00250 "GetDefmethodListCommand","01w");
00251 EnvDefineFunction2(theEnv,"get-method-restrictions",'m',PTIEF GetMethodRestrictionsCommand,
00252 "GetMethodRestrictionsCommand","22iw");
00253 EnvDefineFunction2(theEnv,"defgeneric-module",'w',PTIEF GetDefgenericModuleCommand,
00254 "GetDefgenericModuleCommand","11w");
00255
00256 #if OBJECT_SYSTEM
00257 EnvDefineFunction2(theEnv,"type",'u',PTIEF ClassCommand,"ClassCommand","11u");
00258 #else
00259 EnvDefineFunction2(theEnv,"type",'u',PTIEF TypeCommand,"TypeCommand","11u");
00260 #endif
00261
00262 #endif
00263
00264 #if DEBUGGING_FUNCTIONS
00265 AddWatchItem(theEnv,"generic-functions",0,&DefgenericData(theEnv)->WatchGenerics,34,
00266 DefgenericWatchAccess,DefgenericWatchPrint);
00267 AddWatchItem(theEnv,"methods",0,&DefgenericData(theEnv)->WatchMethods,33,
00268 DefmethodWatchAccess,DefmethodWatchPrint);
00269 #endif
00270 }
00271
00272
00273
00274
00275
00276 static void DeallocateDefgenericData(
00277 void *theEnv)
00278 {
00279 #if ! RUN_TIME
00280 struct defgenericModule *theModuleItem;
00281 void *theModule;
00282
00283 #if BLOAD || BLOAD_AND_BSAVE
00284 if (Bloaded(theEnv)) return;
00285 #endif
00286
00287 DoForAllConstructs(theEnv,DestroyDefgenericAction,DefgenericData(theEnv)->DefgenericModuleIndex,FALSE,NULL);
00288
00289 for (theModule = EnvGetNextDefmodule(theEnv,NULL);
00290 theModule != NULL;
00291 theModule = EnvGetNextDefmodule(theEnv,theModule))
00292 {
00293 theModuleItem = (struct defgenericModule *)
00294 GetModuleItem(theEnv,(struct defmodule *) theModule,
00295 DefgenericData(theEnv)->DefgenericModuleIndex);
00296
00297 rtn_struct(theEnv,defgenericModule,theModuleItem);
00298 }
00299 #else
00300 #if MAC_MCW || WIN_MCW || MAC_XCD
00301 #pragma unused(theEnv)
00302 #endif
00303 #endif
00304 }
00305
00306 #if ! RUN_TIME
00307
00308
00309
00310
00311 #if WIN_BTC
00312 #pragma argsused
00313 #endif
00314 static void DestroyDefgenericAction(
00315 void *theEnv,
00316 struct constructHeader *theConstruct,
00317 void *buffer)
00318 {
00319 #if MAC_MCW || WIN_MCW || MAC_XCD
00320 #pragma unused(buffer)
00321 #endif
00322 #if (! BLOAD_ONLY) && (! RUN_TIME)
00323 struct defgeneric *theDefgeneric = (struct defgeneric *) theConstruct;
00324 long i;
00325
00326 if (theDefgeneric == NULL) return;
00327
00328 for (i = 0 ; i < theDefgeneric->mcnt ; i++)
00329 { DestroyMethodInfo(theEnv,theDefgeneric,&theDefgeneric->methods[i]); }
00330
00331 if (theDefgeneric->mcnt != 0)
00332 rm(theEnv,(void *) theDefgeneric->methods,(sizeof(DEFMETHOD) * theDefgeneric->mcnt));
00333
00334 DestroyConstructHeader(theEnv,&theDefgeneric->header);
00335
00336 rtn_struct(theEnv,defgeneric,theDefgeneric);
00337 #else
00338 #if MAC_MCW || WIN_MCW || MAC_XCD
00339 #pragma unused(theEnv,theConstruct)
00340 #endif
00341 #endif
00342 }
00343 #endif
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355 globle void *EnvFindDefgeneric(
00356 void *theEnv,
00357 char *genericModuleAndName)
00358 {
00359 return(FindNamedConstruct(theEnv,genericModuleAndName,DefgenericData(theEnv)->DefgenericConstruct));
00360 }
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373 globle DEFGENERIC *LookupDefgenericByMdlOrScope(
00374 void *theEnv,
00375 char *defgenericName)
00376 {
00377 return((DEFGENERIC *) LookupConstruct(theEnv,DefgenericData(theEnv)->DefgenericConstruct,defgenericName,TRUE));
00378 }
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391 globle DEFGENERIC *LookupDefgenericInScope(
00392 void *theEnv,
00393 char *defgenericName)
00394 {
00395 return((DEFGENERIC *) LookupConstruct(theEnv,DefgenericData(theEnv)->DefgenericConstruct,defgenericName,FALSE));
00396 }
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408 globle void *EnvGetNextDefgeneric(
00409 void *theEnv,
00410 void *ptr)
00411 {
00412 return((void *) GetNextConstructItem(theEnv,(struct constructHeader *) ptr,DefgenericData(theEnv)->DefgenericModuleIndex));
00413 }
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426 #if WIN_BTC
00427 #pragma argsused
00428 #endif
00429 globle long EnvGetNextDefmethod(
00430 void *theEnv,
00431 void *ptr,
00432 long theIndex)
00433 {
00434 DEFGENERIC *gfunc;
00435 long mi;
00436 #if MAC_MCW || WIN_MCW || MAC_XCD
00437 #pragma unused(theEnv)
00438 #endif
00439
00440 gfunc = (DEFGENERIC *) ptr;
00441 if (theIndex == 0)
00442 {
00443 if (gfunc->methods != NULL)
00444 return(gfunc->methods[0].index);
00445 return(0);
00446 }
00447 mi = FindMethodByIndex(gfunc,theIndex);
00448 if ((mi+1) == gfunc->mcnt)
00449 return(0);
00450 return(gfunc->methods[mi+1].index);
00451 }
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463 globle DEFMETHOD *GetDefmethodPointer(
00464 void *ptr,
00465 long theIndex)
00466 {
00467 return(&((DEFGENERIC *) ptr)->methods[theIndex-1]);
00468 }
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479 globle int EnvIsDefgenericDeletable(
00480 void *theEnv,
00481 void *ptr)
00482 {
00483 if (! ConstructsDeletable(theEnv))
00484 { return FALSE; }
00485
00486 return ((((DEFGENERIC *) ptr)->busy == 0) ? TRUE : FALSE);
00487 }
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499 globle int EnvIsDefmethodDeletable(
00500 void *theEnv,
00501 void *ptr,
00502 long theIndex)
00503 {
00504 if (! ConstructsDeletable(theEnv))
00505 { return FALSE; }
00506
00507 if (((DEFGENERIC *) ptr)->methods[FindMethodByIndex((DEFGENERIC *) ptr,theIndex)].system)
00508 return(FALSE);
00509
00510 #if (! BLOAD_ONLY) && (! RUN_TIME)
00511 return((MethodsExecuting((DEFGENERIC *) ptr) == FALSE) ? TRUE : FALSE);
00512 #else
00513 return FALSE;
00514 #endif
00515 }
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525 globle void UndefgenericCommand(
00526 void *theEnv)
00527 {
00528 UndefconstructCommand(theEnv,"undefgeneric",DefgenericData(theEnv)->DefgenericConstruct);
00529 }
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539 globle void *GetDefgenericModuleCommand(
00540 void *theEnv)
00541 {
00542 return(GetConstructModuleCommand(theEnv,"defgeneric-module",DefgenericData(theEnv)->DefgenericConstruct));
00543 }
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553 globle void UndefmethodCommand(
00554 void *theEnv)
00555 {
00556 DATA_OBJECT temp;
00557 DEFGENERIC *gfunc;
00558 long mi;
00559
00560 if (EnvArgTypeCheck(theEnv,"undefmethod",1,SYMBOL,&temp) == FALSE)
00561 return;
00562 gfunc = LookupDefgenericByMdlOrScope(theEnv,DOToString(temp));
00563 if ((gfunc == NULL) ? (strcmp(DOToString(temp),"*") != 0) : FALSE)
00564 {
00565 PrintErrorID(theEnv,"GENRCCOM",1,FALSE);
00566 EnvPrintRouter(theEnv,WERROR,"No such generic function ");
00567 EnvPrintRouter(theEnv,WERROR,DOToString(temp));
00568 EnvPrintRouter(theEnv,WERROR," in function undefmethod.\n");
00569 return;
00570 }
00571 EnvRtnUnknown(theEnv,2,&temp);
00572 if (temp.type == SYMBOL)
00573 {
00574 if (strcmp(DOToString(temp),"*") != 0)
00575 {
00576 PrintErrorID(theEnv,"GENRCCOM",2,FALSE);
00577 EnvPrintRouter(theEnv,WERROR,"Expected a valid method index in function undefmethod.\n");
00578 return;
00579 }
00580 mi = 0;
00581 }
00582 else if (temp.type == INTEGER)
00583 {
00584 mi = (long) DOToLong(temp);
00585 if (mi == 0)
00586 {
00587 PrintErrorID(theEnv,"GENRCCOM",2,FALSE);
00588 EnvPrintRouter(theEnv,WERROR,"Expected a valid method index in function undefmethod.\n");
00589 return;
00590 }
00591 }
00592 else
00593 {
00594 PrintErrorID(theEnv,"GENRCCOM",2,FALSE);
00595 EnvPrintRouter(theEnv,WERROR,"Expected a valid method index in function undefmethod.\n");
00596 return;
00597 }
00598 EnvUndefmethod(theEnv,(void *) gfunc,mi);
00599 }
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610 globle intBool EnvUndefgeneric(
00611 void *theEnv,
00612 void *vptr)
00613 {
00614 #if (MAC_MCW || WIN_MCW) && (RUN_TIME || BLOAD_ONLY)
00615 #pragma unused(theEnv,vptr)
00616 #endif
00617
00618 #if RUN_TIME || BLOAD_ONLY
00619 return(FALSE);
00620 #else
00621 DEFGENERIC *gfunc;
00622 int success = TRUE;
00623
00624 gfunc = (DEFGENERIC *) vptr;
00625 if (gfunc == NULL)
00626 {
00627 if (ClearDefmethods(theEnv) == FALSE)
00628 success = FALSE;
00629 if (ClearDefgenerics(theEnv) == FALSE)
00630 success = FALSE;
00631 return(success);
00632 }
00633 if (EnvIsDefgenericDeletable(theEnv,vptr) == FALSE)
00634 return(FALSE);
00635 RemoveConstructFromModule(theEnv,(struct constructHeader *) vptr);
00636 RemoveDefgeneric(theEnv,gfunc);
00637 return(TRUE);
00638 #endif
00639 }
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651 globle intBool EnvUndefmethod(
00652 void *theEnv,
00653 void *vptr,
00654 long mi)
00655 {
00656 DEFGENERIC *gfunc;
00657
00658 #if RUN_TIME || BLOAD_ONLY
00659 gfunc = (DEFGENERIC *) vptr;
00660 PrintErrorID(theEnv,"PRNTUTIL",4,FALSE);
00661 EnvPrintRouter(theEnv,WERROR,"Unable to delete method ");
00662 if (gfunc != NULL)
00663 {
00664 PrintGenericName(theEnv,WERROR,gfunc);
00665 EnvPrintRouter(theEnv,WERROR," #");
00666 PrintLongInteger(theEnv,WERROR,(long long) mi);
00667 }
00668 else
00669 EnvPrintRouter(theEnv,WERROR,"*");
00670 EnvPrintRouter(theEnv,WERROR,".\n");
00671 return(FALSE);
00672 #else
00673 long nmi;
00674
00675 gfunc = (DEFGENERIC *) vptr;
00676 #if BLOAD || BLOAD_AND_BSAVE
00677 if (Bloaded(theEnv) == TRUE)
00678 {
00679 PrintErrorID(theEnv,"PRNTUTIL",4,FALSE);
00680 EnvPrintRouter(theEnv,WERROR,"Unable to delete method ");
00681 if (gfunc != NULL)
00682 {
00683 EnvPrintRouter(theEnv,WERROR,EnvGetDefgenericName(theEnv,(void *) gfunc));
00684 EnvPrintRouter(theEnv,WERROR," #");
00685 PrintLongInteger(theEnv,WERROR,(long long) mi);
00686 }
00687 else
00688 EnvPrintRouter(theEnv,WERROR,"*");
00689 EnvPrintRouter(theEnv,WERROR,".\n");
00690 return(FALSE);
00691 }
00692 #endif
00693 if (gfunc == NULL)
00694 {
00695 if (mi != 0)
00696 {
00697 PrintErrorID(theEnv,"GENRCCOM",3,FALSE);
00698 EnvPrintRouter(theEnv,WERROR,"Incomplete method specification for deletion.\n");
00699 return(FALSE);
00700 }
00701 return(ClearDefmethods(theEnv));
00702 }
00703 if (MethodsExecuting(gfunc))
00704 {
00705 MethodAlterError(theEnv,gfunc);
00706 return(FALSE);
00707 }
00708 if (mi == 0)
00709 RemoveAllExplicitMethods(theEnv,gfunc);
00710 else
00711 {
00712 nmi = CheckMethodExists(theEnv,"undefmethod",gfunc,mi);
00713 if (nmi == -1)
00714 return(FALSE);
00715 RemoveDefgenericMethod(theEnv,gfunc,nmi);
00716 }
00717 return(TRUE);
00718 #endif
00719 }
00720
00721 #if DEBUGGING_FUNCTIONS
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736 globle void EnvGetDefmethodDescription(
00737 void *theEnv,
00738 char *buf,
00739 int buflen,
00740 void *ptr,
00741 long theIndex)
00742 {
00743 DEFGENERIC *gfunc;
00744 long mi;
00745 #if MAC_MCW || WIN_MCW || MAC_XCD
00746 #pragma unused(theEnv)
00747 #endif
00748
00749 gfunc = (DEFGENERIC *) ptr;
00750 mi = FindMethodByIndex(gfunc,theIndex);
00751 PrintMethod(theEnv,buf,buflen,&gfunc->methods[mi]);
00752 }
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764 #if WIN_BTC
00765 #pragma argsused
00766 #endif
00767 globle unsigned EnvGetDefgenericWatch(
00768 void *theEnv,
00769 void *theGeneric)
00770 {
00771 #if MAC_MCW || WIN_MCW || MAC_XCD
00772 #pragma unused(theEnv)
00773 #endif
00774
00775 return(((DEFGENERIC *) theGeneric)->trace);
00776 }
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789 #if WIN_BTC
00790 #pragma argsused
00791 #endif
00792 globle void EnvSetDefgenericWatch(
00793 void *theEnv,
00794 unsigned newState,
00795 void *theGeneric)
00796 {
00797 #if MAC_MCW || WIN_MCW || MAC_XCD
00798 #pragma unused(theEnv)
00799 #endif
00800
00801 ((DEFGENERIC *) theGeneric)->trace = newState;
00802 }
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815 #if WIN_BTC
00816 #pragma argsused
00817 #endif
00818 globle unsigned EnvGetDefmethodWatch(
00819 void *theEnv,
00820 void *theGeneric,
00821 long theIndex)
00822 {
00823 DEFGENERIC *gfunc;
00824 long mi;
00825 #if MAC_MCW || WIN_MCW || MAC_XCD
00826 #pragma unused(theEnv)
00827 #endif
00828
00829 gfunc = (DEFGENERIC *) theGeneric;
00830 mi = FindMethodByIndex(gfunc,theIndex);
00831 return(gfunc->methods[mi].trace);
00832 }
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846 #if WIN_BTC
00847 #pragma argsused
00848 #endif
00849 globle void EnvSetDefmethodWatch(
00850 void *theEnv,
00851 unsigned newState,
00852 void *theGeneric,
00853 long theIndex)
00854 {
00855 DEFGENERIC *gfunc;
00856 long mi;
00857 #if MAC_MCW || WIN_MCW || MAC_XCD
00858 #pragma unused(theEnv)
00859 #endif
00860
00861 gfunc = (DEFGENERIC *) theGeneric;
00862 mi = FindMethodByIndex(gfunc,theIndex);
00863 gfunc->methods[mi].trace = newState;
00864 }
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876 globle void PPDefgenericCommand(
00877 void *theEnv)
00878 {
00879 PPConstructCommand(theEnv,"ppdefgeneric",DefgenericData(theEnv)->DefgenericConstruct);
00880 }
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891 globle void PPDefmethodCommand(
00892 void *theEnv)
00893 {
00894 DATA_OBJECT temp;
00895 char *gname;
00896 DEFGENERIC *gfunc;
00897 int gi;
00898
00899 if (EnvArgTypeCheck(theEnv,"ppdefmethod",1,SYMBOL,&temp) == FALSE)
00900 return;
00901 gname = DOToString(temp);
00902 if (EnvArgTypeCheck(theEnv,"ppdefmethod",2,INTEGER,&temp) == FALSE)
00903 return;
00904 gfunc = CheckGenericExists(theEnv,"ppdefmethod",gname);
00905 if (gfunc == NULL)
00906 return;
00907 gi = CheckMethodExists(theEnv,"ppdefmethod",gfunc,(long) DOToLong(temp));
00908 if (gi == -1)
00909 return;
00910 if (gfunc->methods[gi].ppForm != NULL)
00911 PrintInChunks(theEnv,WDISPLAY,gfunc->methods[gi].ppForm);
00912 }
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923 globle void ListDefmethodsCommand(
00924 void *theEnv)
00925 {
00926 DATA_OBJECT temp;
00927 DEFGENERIC *gfunc;
00928
00929 if (EnvRtnArgCount(theEnv) == 0)
00930 EnvListDefmethods(theEnv,WDISPLAY,NULL);
00931 else
00932 {
00933 if (EnvArgTypeCheck(theEnv,"list-defmethods",1,SYMBOL,&temp) == FALSE)
00934 return;
00935 gfunc = CheckGenericExists(theEnv,"list-defmethods",DOToString(temp));
00936 if (gfunc != NULL)
00937 EnvListDefmethods(theEnv,WDISPLAY,(void *) gfunc);
00938 }
00939 }
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950 #if WIN_BTC
00951 #pragma argsused
00952 #endif
00953 globle char *EnvGetDefmethodPPForm(
00954 void *theEnv,
00955 void *ptr,
00956 long theIndex)
00957 {
00958 DEFGENERIC *gfunc;
00959 int mi;
00960 #if MAC_MCW || WIN_MCW || MAC_XCD
00961 #pragma unused(theEnv)
00962 #endif
00963
00964 gfunc = (DEFGENERIC *) ptr;
00965 mi = FindMethodByIndex(gfunc,theIndex);
00966 return(gfunc->methods[mi].ppForm);
00967 }
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977 globle void ListDefgenericsCommand(
00978 void *theEnv)
00979 {
00980 ListConstructCommand(theEnv,"list-defgenerics",DefgenericData(theEnv)->DefgenericConstruct);
00981 }
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992 globle void EnvListDefgenerics(
00993 void *theEnv,
00994 char *logicalName,
00995 struct defmodule *theModule)
00996 {
00997 ListConstruct(theEnv,DefgenericData(theEnv)->DefgenericConstruct,logicalName,theModule);
00998 }
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011 globle void EnvListDefmethods(
01012 void *theEnv,
01013 char *logicalName,
01014 void *vptr)
01015 {
01016 DEFGENERIC *gfunc;
01017 long count;
01018 if (vptr != NULL)
01019 count = ListMethodsForGeneric(theEnv,logicalName,(DEFGENERIC *) vptr);
01020 else
01021 {
01022 count = 0L;
01023 for (gfunc = (DEFGENERIC *) EnvGetNextDefgeneric(theEnv,NULL) ;
01024 gfunc != NULL ;
01025 gfunc = (DEFGENERIC *) EnvGetNextDefgeneric(theEnv,(void *) gfunc))
01026 {
01027 count += ListMethodsForGeneric(theEnv,logicalName,gfunc);
01028 if (EnvGetNextDefgeneric(theEnv,(void *) gfunc) != NULL)
01029 EnvPrintRouter(theEnv,logicalName,"\n");
01030 }
01031 }
01032 PrintTally(theEnv,logicalName,count,"method","methods");
01033 }
01034
01035 #endif
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047 globle void GetDefgenericListFunction(
01048 void *theEnv,
01049 DATA_OBJECT*returnValue)
01050 {
01051 GetConstructListFunction(theEnv,"get-defgeneric-list",returnValue,DefgenericData(theEnv)->DefgenericConstruct);
01052 }
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065 globle void EnvGetDefgenericList(
01066 void *theEnv,
01067 DATA_OBJECT *returnValue,
01068 struct defmodule *theModule)
01069 {
01070 GetConstructList(theEnv,returnValue,DefgenericData(theEnv)->DefgenericConstruct,theModule);
01071 }
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083 globle void GetDefmethodListCommand(
01084 void *theEnv,
01085 DATA_OBJECT_PTR returnValue)
01086 {
01087 DATA_OBJECT temp;
01088 DEFGENERIC *gfunc;
01089
01090 if (EnvRtnArgCount(theEnv) == 0)
01091 EnvGetDefmethodList(theEnv,NULL,returnValue);
01092 else
01093 {
01094 if (EnvArgTypeCheck(theEnv,"get-defmethod-list",1,SYMBOL,&temp) == FALSE)
01095 {
01096 EnvSetMultifieldErrorValue(theEnv,returnValue);
01097 return;
01098 }
01099 gfunc = CheckGenericExists(theEnv,"get-defmethod-list",DOToString(temp));
01100 if (gfunc != NULL)
01101 EnvGetDefmethodList(theEnv,(void *) gfunc,returnValue);
01102 else
01103 EnvSetMultifieldErrorValue(theEnv,returnValue);
01104 }
01105 }
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118 globle void EnvGetDefmethodList(
01119 void *theEnv,
01120 void *vgfunc,
01121 DATA_OBJECT_PTR returnValue)
01122 {
01123 DEFGENERIC *gfunc,*svg,*svnxt;
01124 long i,j;
01125 unsigned long count;
01126 MULTIFIELD_PTR theList;
01127
01128 if (vgfunc != NULL)
01129 {
01130 gfunc = (DEFGENERIC *) vgfunc;
01131 svnxt = (DEFGENERIC *) EnvGetNextDefgeneric(theEnv,vgfunc);
01132 SetNextDefgeneric(vgfunc,NULL);
01133 }
01134 else
01135 {
01136 gfunc = (DEFGENERIC *) EnvGetNextDefgeneric(theEnv,NULL);
01137 svnxt = (gfunc != NULL) ? (DEFGENERIC *) EnvGetNextDefgeneric(theEnv,(void *) gfunc) : NULL;
01138 }
01139 count = 0;
01140 for (svg = gfunc ;
01141 gfunc != NULL ;
01142 gfunc = (DEFGENERIC *) EnvGetNextDefgeneric(theEnv,(void *) gfunc))
01143 count += (unsigned long) gfunc->mcnt;
01144 count *= 2;
01145 SetpType(returnValue,MULTIFIELD);
01146 SetpDOBegin(returnValue,1);
01147 SetpDOEnd(returnValue,count);
01148 theList = (MULTIFIELD_PTR) EnvCreateMultifield(theEnv,count);
01149 SetpValue(returnValue,theList);
01150 for (gfunc = svg , i = 1 ;
01151 gfunc != NULL ;
01152 gfunc = (DEFGENERIC *) EnvGetNextDefgeneric(theEnv,(void *) gfunc))
01153 {
01154 for (j = 0 ; j < gfunc->mcnt ; j++)
01155 {
01156 SetMFType(theList,i,SYMBOL);
01157 SetMFValue(theList,i++,GetDefgenericNamePointer((void *) gfunc));
01158 SetMFType(theList,i,INTEGER);
01159 SetMFValue(theList,i++,EnvAddLong(theEnv,(long long) gfunc->methods[j].index));
01160 }
01161 }
01162 if (svg != NULL)
01163 SetNextDefgeneric((void *) svg,(void *) svnxt);
01164 }
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174 globle void GetMethodRestrictionsCommand(
01175 void *theEnv,
01176 DATA_OBJECT *result)
01177 {
01178 DATA_OBJECT temp;
01179 DEFGENERIC *gfunc;
01180
01181 if (EnvArgTypeCheck(theEnv,"get-method-restrictions",1,SYMBOL,&temp) == FALSE)
01182 {
01183 EnvSetMultifieldErrorValue(theEnv,result);
01184 return;
01185 }
01186 gfunc = CheckGenericExists(theEnv,"get-method-restrictions",DOToString(temp));
01187 if (gfunc == NULL)
01188 {
01189 EnvSetMultifieldErrorValue(theEnv,result);
01190 return;
01191 }
01192 if (EnvArgTypeCheck(theEnv,"get-method-restrictions",2,INTEGER,&temp) == FALSE)
01193 {
01194 EnvSetMultifieldErrorValue(theEnv,result);
01195 return;
01196 }
01197 if (CheckMethodExists(theEnv,"get-method-restrictions",gfunc,(long) DOToLong(temp)) == -1)
01198 {
01199 EnvSetMultifieldErrorValue(theEnv,result);
01200 return;
01201 }
01202 EnvGetMethodRestrictions(theEnv,(void *) gfunc,(unsigned) DOToLong(temp),result);
01203 }
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225
01226
01227
01228
01229
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240
01241 globle void EnvGetMethodRestrictions(
01242 void *theEnv,
01243 void *vgfunc,
01244 long mi,
01245 DATA_OBJECT *result)
01246 {
01247 short i,j;
01248 register DEFMETHOD *meth;
01249 register RESTRICTION *rptr;
01250 long count;
01251 int roffset,rstrctIndex;
01252 MULTIFIELD_PTR theList;
01253
01254 meth = ((DEFGENERIC *) vgfunc)->methods + FindMethodByIndex((DEFGENERIC *) vgfunc,mi);
01255 count = 3;
01256 for (i = 0 ; i < meth->restrictionCount ; i++)
01257 count += meth->restrictions[i].tcnt + 3;
01258 theList = (MULTIFIELD_PTR) EnvCreateMultifield(theEnv,count);
01259 SetpType(result,MULTIFIELD);
01260 SetpValue(result,theList);
01261 SetpDOBegin(result,1);
01262 SetpDOEnd(result,count);
01263 SetMFType(theList,1,INTEGER);
01264 SetMFValue(theList,1,EnvAddLong(theEnv,(long long) meth->minRestrictions));
01265 SetMFType(theList,2,INTEGER);
01266 SetMFValue(theList,2,EnvAddLong(theEnv,(long long) meth->maxRestrictions));
01267 SetMFType(theList,3,INTEGER);
01268 SetMFValue(theList,3,EnvAddLong(theEnv,(long long) meth->restrictionCount));
01269 roffset = 3 + meth->restrictionCount + 1;
01270 rstrctIndex = 4;
01271 for (i = 0 ; i < meth->restrictionCount ; i++)
01272 {
01273 rptr = meth->restrictions + i;
01274 SetMFType(theList,rstrctIndex,INTEGER);
01275 SetMFValue(theList,rstrctIndex++,EnvAddLong(theEnv,(long long) roffset));
01276 SetMFType(theList,roffset,SYMBOL);
01277 SetMFValue(theList,roffset++,(rptr->query != NULL) ? EnvTrueSymbol(theEnv) : EnvFalseSymbol(theEnv));
01278 SetMFType(theList,roffset,INTEGER);
01279 SetMFValue(theList,roffset++,EnvAddLong(theEnv,(long long) rptr->tcnt));
01280 for (j = 0 ; j < rptr->tcnt ; j++)
01281 {
01282 SetMFType(theList,roffset,SYMBOL);
01283 #if OBJECT_SYSTEM
01284 SetMFValue(theList,roffset++,EnvAddSymbol(theEnv,EnvGetDefclassName(theEnv,rptr->types[j])));
01285 #else
01286 SetMFValue(theList,roffset++,EnvAddSymbol(theEnv,TypeName(theEnv,ValueToInteger(rptr->types[j]))));
01287 #endif
01288 }
01289 }
01290 }
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305
01306
01307
01308 #if WIN_BTC && (! DEVELOPER)
01309 #pragma argsused
01310 #endif
01311 static void PrintGenericCall(
01312 void *theEnv,
01313 char *logName,
01314 void *value)
01315 {
01316 #if DEVELOPER
01317
01318 EnvPrintRouter(theEnv,logName,"(");
01319 EnvPrintRouter(theEnv,logName,EnvGetDefgenericName(theEnv,value));
01320 if (GetFirstArgument() != NULL)
01321 {
01322 EnvPrintRouter(theEnv,logName," ");
01323 PrintExpression(theEnv,logName,GetFirstArgument());
01324 }
01325 EnvPrintRouter(theEnv,logName,")");
01326 #else
01327 #if MAC_MCW || WIN_MCW || MAC_XCD
01328 #pragma unused(theEnv)
01329 #pragma unused(logName)
01330 #pragma unused(value)
01331 #endif
01332 #endif
01333 }
01334
01335
01336
01337
01338
01339
01340
01341
01342
01343
01344
01345
01346
01347
01348
01349 static intBool EvaluateGenericCall(
01350 void *theEnv,
01351 void *value,
01352 DATA_OBJECT *result)
01353 {
01354 GenericDispatch(theEnv,(DEFGENERIC *) value,NULL,NULL,GetFirstArgument(),result);
01355 if ((GetpType(result) == SYMBOL) &&
01356 (GetpValue(result) == EnvFalseSymbol(theEnv)))
01357 return(FALSE);
01358 return(TRUE);
01359 }
01360
01361
01362
01363
01364
01365
01366
01367
01368
01369
01370
01371 static void DecrementGenericBusyCount(
01372 void *theEnv,
01373 void *value)
01374 {
01375
01376
01377
01378
01379
01380
01381 if (! ConstructData(theEnv)->ClearInProgress)
01382 ((DEFGENERIC *) value)->busy--;
01383 }
01384
01385
01386
01387
01388
01389
01390
01391
01392
01393
01394 #if WIN_BTC
01395 #pragma argsused
01396 #endif
01397 static void IncrementGenericBusyCount(
01398 void *theEnv,
01399 void *value)
01400 {
01401 #if MAC_MCW || WIN_MCW || MAC_XCD
01402 #pragma unused(theEnv)
01403 #endif
01404 ((DEFGENERIC *) value)->busy++;
01405 }
01406
01407 #if (! BLOAD_ONLY) && (! RUN_TIME)
01408
01409
01410
01411
01412
01413
01414
01415
01416
01417 static void SaveDefgenerics(
01418 void *theEnv,
01419 void *theModule,
01420 char *logName)
01421 {
01422 SaveConstruct(theEnv,theModule,logName,DefgenericData(theEnv)->DefgenericConstruct);
01423 }
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433 static void SaveDefmethods(
01434 void *theEnv,
01435 void *theModule,
01436 char *logName)
01437 {
01438 DoForAllConstructsInModule(theEnv,theModule,SaveDefmethodsForDefgeneric,
01439 DefgenericData(theEnv)->DefgenericModuleIndex,
01440 FALSE,(void *) logName);
01441 }
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454 static void SaveDefmethodsForDefgeneric(
01455 void *theEnv,
01456 struct constructHeader *theDefgeneric,
01457 void *userBuffer)
01458 {
01459 DEFGENERIC *gfunc = (DEFGENERIC *) theDefgeneric;
01460 char *logName = (char *) userBuffer;
01461 long i;
01462
01463 for (i = 0 ; i < gfunc->mcnt ; i++)
01464 {
01465 if (gfunc->methods[i].ppForm != NULL)
01466 {
01467 PrintInChunks(theEnv,logName,gfunc->methods[i].ppForm);
01468 EnvPrintRouter(theEnv,logName,"\n");
01469 }
01470 }
01471 }
01472
01473
01474
01475
01476
01477
01478
01479
01480
01481
01482
01483
01484
01485 static void RemoveDefgenericMethod(
01486 void *theEnv,
01487 DEFGENERIC *gfunc,
01488 long gi)
01489 {
01490 DEFMETHOD *narr;
01491 long b,e;
01492
01493 if (gfunc->methods[gi].system)
01494 {
01495 SetEvaluationError(theEnv,TRUE);
01496 PrintErrorID(theEnv,"GENRCCOM",4,FALSE);
01497 EnvPrintRouter(theEnv,WERROR,"Cannot remove implicit system function method for generic function ");
01498 EnvPrintRouter(theEnv,WERROR,EnvGetDefgenericName(theEnv,(void *) gfunc));
01499 EnvPrintRouter(theEnv,WERROR,".\n");
01500 return;
01501 }
01502 DeleteMethodInfo(theEnv,gfunc,&gfunc->methods[gi]);
01503 if (gfunc->mcnt == 1)
01504 {
01505 rm(theEnv,(void *) gfunc->methods,(int) sizeof(DEFMETHOD));
01506 gfunc->mcnt = 0;
01507 gfunc->methods = NULL;
01508 }
01509 else
01510 {
01511 gfunc->mcnt--;
01512 narr = (DEFMETHOD *) gm2(theEnv,(sizeof(DEFMETHOD) * gfunc->mcnt));
01513 for (b = e = 0 ; b < gfunc->mcnt ; b++ , e++)
01514 {
01515 if (((int) b) == gi)
01516 e++;
01517 GenCopyMemory(DEFMETHOD,1,&narr[b],&gfunc->methods[e]);
01518 }
01519 rm(theEnv,(void *) gfunc->methods,(sizeof(DEFMETHOD) * (gfunc->mcnt+1)));
01520 gfunc->methods = narr;
01521 }
01522 }
01523
01524 #endif
01525
01526 #if DEBUGGING_FUNCTIONS
01527
01528
01529
01530
01531
01532
01533
01534
01535
01536
01537
01538 static long ListMethodsForGeneric(
01539 void *theEnv,
01540 char *logicalName,
01541 DEFGENERIC *gfunc)
01542 {
01543 long gi;
01544 char buf[256];
01545
01546 for (gi = 0 ; gi < gfunc->mcnt ; gi++)
01547 {
01548 EnvPrintRouter(theEnv,logicalName,EnvGetDefgenericName(theEnv,(void *) gfunc));
01549 EnvPrintRouter(theEnv,logicalName," #");
01550 PrintMethod(theEnv,buf,255,&gfunc->methods[gi]);
01551 EnvPrintRouter(theEnv,logicalName,buf);
01552 EnvPrintRouter(theEnv,logicalName,"\n");
01553 }
01554 return((long) gfunc->mcnt);
01555 }
01556
01557
01558
01559
01560
01561
01562
01563
01564
01565
01566
01567
01568
01569
01570 #if WIN_BTC
01571 #pragma argsused
01572 #endif
01573 static unsigned DefgenericWatchAccess(
01574 void *theEnv,
01575 int code,
01576 unsigned newState,
01577 EXPRESSION *argExprs)
01578 {
01579 #if MAC_MCW || WIN_MCW || MAC_XCD
01580 #pragma unused(code)
01581 #endif
01582
01583 return(ConstructSetWatchAccess(theEnv,DefgenericData(theEnv)->DefgenericConstruct,newState,argExprs,
01584 EnvGetDefgenericWatch,EnvSetDefgenericWatch));
01585 }
01586
01587
01588
01589
01590
01591
01592
01593
01594
01595
01596
01597
01598
01599
01600 #if WIN_BTC
01601 #pragma argsused
01602 #endif
01603 static unsigned DefgenericWatchPrint(
01604 void *theEnv,
01605 char *logName,
01606 int code,
01607 EXPRESSION *argExprs)
01608 {
01609 #if MAC_MCW || WIN_MCW || MAC_XCD
01610 #pragma unused(code)
01611 #endif
01612
01613 return(ConstructPrintWatchAccess(theEnv,DefgenericData(theEnv)->DefgenericConstruct,logName,argExprs,
01614 EnvGetDefgenericWatch,EnvSetDefgenericWatch));
01615 }
01616
01617
01618
01619
01620
01621
01622
01623
01624
01625
01626
01627
01628
01629
01630 #if WIN_BTC
01631 #pragma argsused
01632 #endif
01633 static unsigned DefmethodWatchAccess(
01634 void *theEnv,
01635 int code,
01636 unsigned newState,
01637 EXPRESSION *argExprs)
01638 {
01639 #if MAC_MCW || WIN_MCW || MAC_XCD
01640 #pragma unused(code)
01641 #endif
01642 if (newState)
01643 return(DefmethodWatchSupport(theEnv,"watch",NULL,newState,NULL,EnvSetDefmethodWatch,argExprs));
01644 else
01645 return(DefmethodWatchSupport(theEnv,"unwatch",NULL,newState,NULL,EnvSetDefmethodWatch,argExprs));
01646 }
01647
01648
01649
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659
01660
01661 #if WIN_BTC
01662 #pragma argsused
01663 #endif
01664 static unsigned DefmethodWatchPrint(
01665 void *theEnv,
01666 char *logName,
01667 int code,
01668 EXPRESSION *argExprs)
01669 {
01670 #if MAC_MCW || WIN_MCW || MAC_XCD
01671 #pragma unused(code)
01672 #endif
01673 return(DefmethodWatchSupport(theEnv,"list-watch-items",logName,0,
01674 PrintMethodWatchFlag,NULL,argExprs));
01675 }
01676
01677
01678
01679
01680
01681
01682
01683
01684
01685
01686
01687
01688
01689
01690
01691
01692 static unsigned DefmethodWatchSupport(
01693 void *theEnv,
01694 char *funcName,
01695 char *logName,
01696 unsigned newState,
01697 void (*printFunc)(void *,char *,void *,long),
01698 void (*traceFunc)(void *,unsigned,void *,long),
01699 EXPRESSION *argExprs)
01700 {
01701 void *theGeneric;
01702 unsigned long theMethod = 0;
01703 int argIndex = 2;
01704 DATA_OBJECT genericName,methodIndex;
01705 struct defmodule *theModule;
01706
01707
01708
01709
01710
01711
01712 if (argExprs == NULL)
01713 {
01714 SaveCurrentModule(theEnv);
01715 theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL);
01716 while (theModule != NULL)
01717 {
01718 EnvSetCurrentModule(theEnv,(void *) theModule);
01719 if (traceFunc == NULL)
01720 {
01721 EnvPrintRouter(theEnv,logName,EnvGetDefmoduleName(theEnv,(void *) theModule));
01722 EnvPrintRouter(theEnv,logName,":\n");
01723 }
01724 theGeneric = EnvGetNextDefgeneric(theEnv,NULL);
01725 while (theGeneric != NULL)
01726 {
01727 theMethod = EnvGetNextDefmethod(theEnv,theGeneric,0);
01728 while (theMethod != 0)
01729 {
01730 if (traceFunc != NULL)
01731 (*traceFunc)(theEnv,newState,theGeneric,theMethod);
01732 else
01733 {
01734 EnvPrintRouter(theEnv,logName," ");
01735 (*printFunc)(theEnv,logName,theGeneric,theMethod);
01736 }
01737 theMethod = EnvGetNextDefmethod(theEnv,theGeneric,theMethod);
01738 }
01739 theGeneric = EnvGetNextDefgeneric(theEnv,theGeneric);
01740 }
01741 theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,(void *) theModule);
01742 }
01743 RestoreCurrentModule(theEnv);
01744 return(TRUE);
01745 }
01746
01747
01748
01749
01750 while (argExprs != NULL)
01751 {
01752 if (EvaluateExpression(theEnv,argExprs,&genericName))
01753 return(FALSE);
01754 if ((genericName.type != SYMBOL) ? TRUE :
01755 ((theGeneric = (void *)
01756 LookupDefgenericByMdlOrScope(theEnv,DOToString(genericName))) == NULL))
01757 {
01758 ExpectedTypeError1(theEnv,funcName,argIndex,"generic function name");
01759 return(FALSE);
01760 }
01761 if (GetNextArgument(argExprs) == NULL)
01762 theMethod = 0;
01763 else
01764 {
01765 argExprs = GetNextArgument(argExprs);
01766 argIndex++;
01767 if (EvaluateExpression(theEnv,argExprs,&methodIndex))
01768 return(FALSE);
01769 if ((methodIndex.type != INTEGER) ? FALSE :
01770 ((DOToLong(methodIndex) <= 0) ? FALSE :
01771 (FindMethodByIndex((DEFGENERIC *) theGeneric,theMethod) != -1)))
01772 theMethod = (long) DOToLong(methodIndex);
01773 else
01774 {
01775 ExpectedTypeError1(theEnv,funcName,argIndex,"method index");
01776 return(FALSE);
01777 }
01778 }
01779 if (theMethod == 0)
01780 {
01781 theMethod = EnvGetNextDefmethod(theEnv,theGeneric,0);
01782 while (theMethod != 0)
01783 {
01784 if (traceFunc != NULL)
01785 (*traceFunc)(theEnv,newState,theGeneric,theMethod);
01786 else
01787 (*printFunc)(theEnv,logName,theGeneric,theMethod);
01788 theMethod = EnvGetNextDefmethod(theEnv,theGeneric,theMethod);
01789 }
01790 }
01791 else
01792 {
01793 if (traceFunc != NULL)
01794 (*traceFunc)(theEnv,newState,theGeneric,theMethod);
01795 else
01796 (*printFunc)(theEnv,logName,theGeneric,theMethod);
01797 }
01798 argExprs = GetNextArgument(argExprs);
01799 argIndex++;
01800 }
01801 return(TRUE);
01802 }
01803
01804
01805
01806
01807
01808
01809
01810
01811
01812
01813
01814 static void PrintMethodWatchFlag(
01815 void *theEnv,
01816 char *logName,
01817 void *theGeneric,
01818 long theMethod)
01819 {
01820 char buf[60];
01821
01822 EnvPrintRouter(theEnv,logName,EnvGetDefgenericName(theEnv,theGeneric));
01823 EnvPrintRouter(theEnv,logName," ");
01824 EnvGetDefmethodDescription(theEnv,buf,59,theGeneric,theMethod);
01825 EnvPrintRouter(theEnv,logName,buf);
01826 if (EnvGetDefmethodWatch(theEnv,theGeneric,theMethod))
01827 EnvPrintRouter(theEnv,logName," = on\n");
01828 else
01829 EnvPrintRouter(theEnv,logName," = off\n");
01830 }
01831
01832 #endif
01833
01834 #if ! OBJECT_SYSTEM
01835
01836
01837
01838
01839
01840
01841
01842
01843
01844 globle void TypeCommand(
01845 void *theEnv,
01846 DATA_OBJECT *result)
01847 {
01848 EvaluateExpression(theEnv,GetFirstArgument(),result);
01849 result->value = (void *) EnvAddSymbol(theEnv,TypeName(theEnv,result->type));
01850 result->type = SYMBOL;
01851 }
01852
01853 #endif
01854
01855 #endif
01856