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
00042
00043
00044
00045
00046 #include "setup.h"
00047
00048 #if OBJECT_SYSTEM
00049
00050 #include <string.h>
00051
00052 #include "argacces.h"
00053 #include "classcom.h"
00054 #include "classfun.h"
00055 #include "classini.h"
00056 #include "envrnmnt.h"
00057 #include "insfun.h"
00058 #include "memalloc.h"
00059 #include "msgcom.h"
00060 #include "msgfun.h"
00061 #include "router.h"
00062 #include "strngrtr.h"
00063 #include "sysdep.h"
00064
00065 #define _CLASSEXM_SOURCE_
00066 #include "classexm.h"
00067
00068
00069
00070
00071
00072
00073
00074 static int CheckTwoClasses(void *,char *,DEFCLASS **,DEFCLASS **);
00075 static SLOT_DESC *CheckSlotExists(void *,char *,DEFCLASS **,intBool,intBool);
00076 static SLOT_DESC *LookupSlot(void *,DEFCLASS *,char *,intBool);
00077
00078 #if DEBUGGING_FUNCTIONS
00079 static DEFCLASS *CheckClass(void *,char *,char *);
00080 static char *GetClassNameArgument(void *,char *);
00081 static void PrintClassBrowse(void *,char *,DEFCLASS *,long);
00082 static void DisplaySeparator(void *,char *,char *,int,int);
00083 static void DisplaySlotBasicInfo(void *,char *,char *,char *,char *,DEFCLASS *);
00084 static intBool PrintSlotSources(void *,char *,SYMBOL_HN *,PACKED_CLASS_LINKS *,long,int);
00085 static void DisplaySlotConstraintInfo(void *,char *,char *,char *,unsigned,DEFCLASS *);
00086 static char *ConstraintCode(CONSTRAINT_RECORD *,unsigned,unsigned);
00087 #endif
00088
00089
00090
00091
00092
00093
00094
00095 #if DEBUGGING_FUNCTIONS
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105 globle void BrowseClassesCommand(
00106 void *theEnv)
00107 {
00108 register DEFCLASS *cls;
00109
00110 if (EnvRtnArgCount(theEnv) == 0)
00111
00112
00113
00114 cls = LookupDefclassByMdlOrScope(theEnv,OBJECT_TYPE_NAME);
00115 else
00116 {
00117 DATA_OBJECT tmp;
00118
00119 if (EnvArgTypeCheck(theEnv,"browse-classes",1,SYMBOL,&tmp) == FALSE)
00120 return;
00121 cls = LookupDefclassByMdlOrScope(theEnv,DOToString(tmp));
00122 if (cls == NULL)
00123 {
00124 ClassExistError(theEnv,"browse-classes",DOToString(tmp));
00125 return;
00126 }
00127 }
00128 EnvBrowseClasses(theEnv,WDISPLAY,(void *) cls);
00129 }
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 globle void EnvBrowseClasses(
00141 void *theEnv,
00142 char *logicalName,
00143 void *clsptr)
00144 {
00145 PrintClassBrowse(theEnv,logicalName,(DEFCLASS *) clsptr,0);
00146 }
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 globle void DescribeClassCommand(
00159 void *theEnv)
00160 {
00161 char *cname;
00162 DEFCLASS *cls;
00163
00164 cname = GetClassNameArgument(theEnv,"describe-class");
00165 if (cname == NULL)
00166 return;
00167 cls = CheckClass(theEnv,"describe-class",cname);
00168 if (cls == NULL)
00169 return;
00170 EnvDescribeClass(theEnv,WDISPLAY,(void *) cls);
00171 }
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184 globle void EnvDescribeClass(
00185 void *theEnv,
00186 char *logicalName,
00187 void *clsptr)
00188 {
00189 DEFCLASS *cls;
00190 char buf[83],
00191 slotNamePrintFormat[12],
00192 overrideMessagePrintFormat[12];
00193 int messageBanner;
00194 long i;
00195 size_t slotNameLength, maxSlotNameLength;
00196 size_t overrideMessageLength, maxOverrideMessageLength;
00197
00198 cls = (DEFCLASS *) clsptr;
00199 DisplaySeparator(theEnv,logicalName,buf,82,'=');
00200 DisplaySeparator(theEnv,logicalName,buf,82,'*');
00201 if (cls->abstract)
00202 EnvPrintRouter(theEnv,logicalName,"Abstract: direct instances of this class cannot be created.\n\n");
00203 else
00204 {
00205 EnvPrintRouter(theEnv,logicalName,"Concrete: direct instances of this class can be created.\n");
00206 #if DEFRULE_CONSTRUCT
00207 if (cls->reactive)
00208 EnvPrintRouter(theEnv,logicalName,"Reactive: direct instances of this class can match defrule patterns.\n\n");
00209 else
00210 EnvPrintRouter(theEnv,logicalName,"Non-reactive: direct instances of this class cannot match defrule patterns.\n\n");
00211 #else
00212 EnvPrintRouter(theEnv,logicalName,"\n");
00213 #endif
00214 }
00215 PrintPackedClassLinks(theEnv,logicalName,"Direct Superclasses:",&cls->directSuperclasses);
00216 PrintPackedClassLinks(theEnv,logicalName,"Inheritance Precedence:",&cls->allSuperclasses);
00217 PrintPackedClassLinks(theEnv,logicalName,"Direct Subclasses:",&cls->directSubclasses);
00218 if (cls->instanceTemplate != NULL)
00219 {
00220 DisplaySeparator(theEnv,logicalName,buf,82,'-');
00221 maxSlotNameLength = 5;
00222 maxOverrideMessageLength = 8;
00223 for (i = 0 ; i < cls->instanceSlotCount ; i++)
00224 {
00225 slotNameLength = strlen(ValueToString(cls->instanceTemplate[i]->slotName->name));
00226 if (slotNameLength > maxSlotNameLength)
00227 maxSlotNameLength = slotNameLength;
00228 if (cls->instanceTemplate[i]->noWrite == 0)
00229 {
00230 overrideMessageLength =
00231 strlen(ValueToString(cls->instanceTemplate[i]->overrideMessage));
00232 if (overrideMessageLength > maxOverrideMessageLength)
00233 maxOverrideMessageLength = overrideMessageLength;
00234 }
00235 }
00236 if (maxSlotNameLength > 16)
00237 maxSlotNameLength = 16;
00238 if (maxOverrideMessageLength > 12)
00239 maxOverrideMessageLength = 12;
00240 #if WIN_MVC || WIN_BTC
00241 gensprintf(slotNamePrintFormat,"%%-%Id.%Ids : ",maxSlotNameLength,maxSlotNameLength);
00242 gensprintf(overrideMessagePrintFormat,"%%-%Id.%Ids ",maxOverrideMessageLength,
00243 maxOverrideMessageLength);
00244 #elif WIN_GCC
00245 gensprintf(slotNamePrintFormat,"%%-%ld.%lds : ",(long) maxSlotNameLength,(long) maxSlotNameLength);
00246 gensprintf(overrideMessagePrintFormat,"%%-%ld.%lds ",(long) maxOverrideMessageLength,
00247 (long) maxOverrideMessageLength);
00248 #else
00249 gensprintf(slotNamePrintFormat,"%%-%zd.%zds : ",maxSlotNameLength,maxSlotNameLength);
00250 gensprintf(overrideMessagePrintFormat,"%%-%zd.%zds ",maxOverrideMessageLength,
00251 maxOverrideMessageLength);
00252 #endif
00253
00254 DisplaySlotBasicInfo(theEnv,logicalName,slotNamePrintFormat,overrideMessagePrintFormat,buf,cls);
00255 EnvPrintRouter(theEnv,logicalName,"\nConstraint information for slots:\n\n");
00256 DisplaySlotConstraintInfo(theEnv,logicalName,slotNamePrintFormat,buf,82,cls);
00257 }
00258 if (cls->handlerCount > 0)
00259 messageBanner = TRUE;
00260 else
00261 {
00262 messageBanner = FALSE;
00263 for (i = 1 ; i < cls->allSuperclasses.classCount ; i++)
00264 if (cls->allSuperclasses.classArray[i]->handlerCount > 0)
00265 {
00266 messageBanner = TRUE;
00267 break;
00268 }
00269 }
00270 if (messageBanner)
00271 {
00272 DisplaySeparator(theEnv,logicalName,buf,82,'-');
00273 EnvPrintRouter(theEnv,logicalName,"Recognized message-handlers:\n");
00274 DisplayHandlersInLinks(theEnv,logicalName,&cls->allSuperclasses,0);
00275 }
00276 DisplaySeparator(theEnv,logicalName,buf,82,'*');
00277 DisplaySeparator(theEnv,logicalName,buf,82,'=');
00278 }
00279
00280 #endif
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292 globle char *GetCreateAccessorString(
00293 void *vsd)
00294 {
00295 SLOT_DESC *sd = (SLOT_DESC *) vsd;
00296
00297 if (sd->createReadAccessor && sd->createWriteAccessor)
00298 return("RW");
00299 if ((sd->createReadAccessor == 0) && (sd->createWriteAccessor == 0))
00300 return("NIL");
00301 else
00302 {
00303 if (sd->createReadAccessor) return "R";
00304 else return "W";
00305 }
00306 }
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316 globle void *GetDefclassModuleCommand(
00317 void *theEnv)
00318 {
00319 return(GetConstructModuleCommand(theEnv,"defclass-module",DefclassData(theEnv)->DefclassConstruct));
00320 }
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330 globle intBool SuperclassPCommand(
00331 void *theEnv)
00332 {
00333 DEFCLASS *c1,*c2;
00334
00335 if (CheckTwoClasses(theEnv,"superclassp",&c1,&c2) == FALSE)
00336 return(FALSE);
00337 return(EnvSuperclassP(theEnv,(void *) c1,(void *) c2));
00338 }
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352 #if WIN_BTC
00353 #pragma argsused
00354 #endif
00355 globle intBool EnvSuperclassP(
00356 void *theEnv,
00357 void *firstClass,
00358 void *secondClass)
00359 {
00360 #if MAC_MCW || WIN_MCW || MAC_XCD
00361 #pragma unused(theEnv)
00362 #endif
00363
00364 return(HasSuperclass((DEFCLASS *) secondClass,(DEFCLASS *) firstClass));
00365 }
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375 globle intBool SubclassPCommand(
00376 void *theEnv)
00377 {
00378 DEFCLASS *c1,*c2;
00379
00380 if (CheckTwoClasses(theEnv,"subclassp",&c1,&c2) == FALSE)
00381 return(FALSE);
00382 return(EnvSubclassP(theEnv,(void *) c1,(void *) c2));
00383 }
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397 #if WIN_BTC
00398 #pragma argsused
00399 #endif
00400 globle intBool EnvSubclassP(
00401 void *theEnv,
00402 void *firstClass,
00403 void *secondClass)
00404 {
00405 #if MAC_MCW || WIN_MCW || MAC_XCD
00406 #pragma unused(theEnv)
00407 #endif
00408
00409 return(HasSuperclass((DEFCLASS *) firstClass,(DEFCLASS *) secondClass));
00410 }
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420 globle int SlotExistPCommand(
00421 void *theEnv)
00422 {
00423 DEFCLASS *cls;
00424 SLOT_DESC *sd;
00425 int inheritFlag = FALSE;
00426 DATA_OBJECT dobj;
00427
00428 sd = CheckSlotExists(theEnv,"slot-existp",&cls,FALSE,TRUE);
00429 if (sd == NULL)
00430 return(FALSE);
00431 if (EnvRtnArgCount(theEnv) == 3)
00432 {
00433 if (EnvArgTypeCheck(theEnv,"slot-existp",3,SYMBOL,&dobj) == FALSE)
00434 return(FALSE);
00435 if (strcmp(DOToString(dobj),"inherit") != 0)
00436 {
00437 ExpectedTypeError1(theEnv,"slot-existp",3,"keyword \"inherit\"");
00438 SetEvaluationError(theEnv,TRUE);
00439 return(FALSE);
00440 }
00441 inheritFlag = TRUE;
00442 }
00443 return((sd->cls == cls) ? TRUE : inheritFlag);
00444 }
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458 globle intBool EnvSlotExistP(
00459 void *theEnv,
00460 void *theDefclass,
00461 char *slotName,
00462 intBool inheritFlag)
00463 {
00464 return((LookupSlot(theEnv,(DEFCLASS *) theDefclass,slotName,inheritFlag) != NULL)
00465 ? TRUE : FALSE);
00466 }
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476 globle int MessageHandlerExistPCommand(
00477 void *theEnv)
00478 {
00479 DEFCLASS *cls;
00480 SYMBOL_HN *mname;
00481 DATA_OBJECT temp;
00482 unsigned mtype = MPRIMARY;
00483
00484 if (EnvArgTypeCheck(theEnv,"message-handler-existp",1,SYMBOL,&temp) == FALSE)
00485 return(FALSE);
00486 cls = LookupDefclassByMdlOrScope(theEnv,DOToString(temp));
00487 if (cls == NULL)
00488 {
00489 ClassExistError(theEnv,"message-handler-existp",DOToString(temp));
00490 return(FALSE);
00491 }
00492 if (EnvArgTypeCheck(theEnv,"message-handler-existp",2,SYMBOL,&temp) == FALSE)
00493 return(FALSE);
00494 mname = (SYMBOL_HN *) GetValue(temp);
00495 if (EnvRtnArgCount(theEnv) == 3)
00496 {
00497 if (EnvArgTypeCheck(theEnv,"message-handler-existp",3,SYMBOL,&temp) == FALSE)
00498 return(FALSE);
00499 mtype = HandlerType(theEnv,"message-handler-existp",DOToString(temp));
00500 if (mtype == MERROR)
00501 {
00502 SetEvaluationError(theEnv,TRUE);
00503 return(FALSE);
00504 }
00505 }
00506 if (FindHandlerByAddress(cls,mname,mtype) != NULL)
00507 return(TRUE);
00508 return(FALSE);
00509 }
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519 globle intBool SlotWritablePCommand(
00520 void *theEnv)
00521 {
00522 DEFCLASS *theDefclass;
00523 SLOT_DESC *sd;
00524
00525 sd = CheckSlotExists(theEnv,"slot-writablep",&theDefclass,TRUE,TRUE);
00526 if (sd == NULL)
00527 return(FALSE);
00528 return((sd->noWrite || sd->initializeOnly) ? FALSE : TRUE);
00529 }
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541 globle intBool EnvSlotWritableP(
00542 void *theEnv,
00543 void *theDefclass,
00544 char *slotName)
00545 {
00546 SLOT_DESC *sd;
00547
00548 if ((sd = LookupSlot(theEnv,(DEFCLASS *) theDefclass,slotName,TRUE)) == NULL)
00549 return(FALSE);
00550 return((sd->noWrite || sd->initializeOnly) ? FALSE : TRUE);
00551 }
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562 globle intBool SlotInitablePCommand(
00563 void *theEnv)
00564 {
00565 DEFCLASS *theDefclass;
00566 SLOT_DESC *sd;
00567
00568 sd = CheckSlotExists(theEnv,"slot-initablep",&theDefclass,TRUE,TRUE);
00569 if (sd == NULL)
00570 return(FALSE);
00571 return((sd->noWrite && (sd->initializeOnly == 0)) ? FALSE : TRUE);
00572 }
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584 globle intBool EnvSlotInitableP(
00585 void *theEnv,
00586 void *theDefclass,
00587 char *slotName)
00588 {
00589 SLOT_DESC *sd;
00590
00591 if ((sd = LookupSlot(theEnv,(DEFCLASS *) theDefclass,slotName,TRUE)) == NULL)
00592 return(FALSE);
00593 return((sd->noWrite && (sd->initializeOnly == 0)) ? FALSE : TRUE);
00594 }
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605 globle intBool SlotPublicPCommand(
00606 void *theEnv)
00607 {
00608 DEFCLASS *theDefclass;
00609 SLOT_DESC *sd;
00610
00611 sd = CheckSlotExists(theEnv,"slot-publicp",&theDefclass,TRUE,FALSE);
00612 if (sd == NULL)
00613 return(FALSE);
00614 return(sd->publicVisibility ? TRUE : FALSE);
00615 }
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627 globle intBool EnvSlotPublicP(
00628 void *theEnv,
00629 void *theDefclass,
00630 char *slotName)
00631 {
00632 SLOT_DESC *sd;
00633
00634 if ((sd = LookupSlot(theEnv,(DEFCLASS *) theDefclass,slotName,FALSE)) == NULL)
00635 return(FALSE);
00636 return(sd->publicVisibility ? TRUE : FALSE);
00637 }
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649 globle int EnvSlotDefaultP(
00650 void *theEnv,
00651 void *theDefclass,
00652 char *slotName)
00653 {
00654 SLOT_DESC *sd;
00655
00656 if ((sd = LookupSlot(theEnv,(DEFCLASS *) theDefclass,slotName,FALSE)) == NULL)
00657 return(NO_DEFAULT);
00658
00659 if (sd->noDefault)
00660 { return(NO_DEFAULT); }
00661 else if (sd->dynamicDefault)
00662 { return(DYNAMIC_DEFAULT); }
00663
00664 return(STATIC_DEFAULT);
00665 }
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679 globle intBool SlotDirectAccessPCommand(
00680 void *theEnv)
00681 {
00682 DEFCLASS *theDefclass;
00683 SLOT_DESC *sd;
00684
00685 sd = CheckSlotExists(theEnv,"slot-direct-accessp",&theDefclass,TRUE,TRUE);
00686 if (sd == NULL)
00687 return(FALSE);
00688 return((sd->publicVisibility || (sd->cls == theDefclass)) ? TRUE : FALSE);
00689 }
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703 globle intBool EnvSlotDirectAccessP(
00704 void *theEnv,
00705 void *theDefclass,
00706 char *slotName)
00707 {
00708 SLOT_DESC *sd;
00709
00710 if ((sd = LookupSlot(theEnv,(DEFCLASS *) theDefclass,slotName,TRUE)) == NULL)
00711 return(FALSE);
00712 return((sd->publicVisibility || (sd->cls == (DEFCLASS *) theDefclass)) ?
00713 TRUE : FALSE);
00714 }
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725 globle void SlotDefaultValueCommand(
00726 void *theEnv,
00727 DATA_OBJECT_PTR theValue)
00728 {
00729 DEFCLASS *theDefclass;
00730 SLOT_DESC *sd;
00731
00732 SetpType(theValue,SYMBOL);
00733 SetpValue(theValue,EnvFalseSymbol(theEnv));
00734 sd = CheckSlotExists(theEnv,"slot-default-value",&theDefclass,TRUE,TRUE);
00735 if (sd == NULL)
00736 return;
00737
00738 if (sd->noDefault)
00739 {
00740 SetpType(theValue,SYMBOL);
00741 SetpValue(theValue,EnvAddSymbol(theEnv,"?NONE"));
00742 return;
00743 }
00744
00745 if (sd->dynamicDefault)
00746 EvaluateAndStoreInDataObject(theEnv,(int) sd->multiple,
00747 (EXPRESSION *) sd->defaultValue,
00748 theValue,TRUE);
00749 else
00750 GenCopyMemory(DATA_OBJECT,1,theValue,sd->defaultValue);
00751 }
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765 globle intBool EnvSlotDefaultValue(
00766 void *theEnv,
00767 void *theDefclass,
00768 char *slotName,
00769 DATA_OBJECT_PTR theValue)
00770 {
00771 SLOT_DESC *sd;
00772
00773 SetpType(theValue,SYMBOL);
00774 SetpValue(theValue,EnvFalseSymbol(theEnv));
00775 if ((sd = LookupSlot(theEnv,(DEFCLASS *) theDefclass,slotName,TRUE)) == NULL)
00776 return(FALSE);
00777
00778 if (sd->noDefault)
00779 {
00780 SetpType(theValue,SYMBOL);
00781 SetpValue(theValue,EnvAddSymbol(theEnv,"?NONE"));
00782 return(TRUE);
00783 }
00784
00785 if (sd->dynamicDefault)
00786 return(EvaluateAndStoreInDataObject(theEnv,(int) sd->multiple,
00787 (EXPRESSION *) sd->defaultValue,
00788 theValue,TRUE));
00789 GenCopyMemory(DATA_OBJECT,1,theValue,sd->defaultValue);
00790 return(TRUE);
00791 }
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801 globle intBool ClassExistPCommand(
00802 void *theEnv)
00803 {
00804 DATA_OBJECT temp;
00805
00806 if (EnvArgTypeCheck(theEnv,"class-existp",1,SYMBOL,&temp) == FALSE)
00807 return(FALSE);
00808 return((LookupDefclassByMdlOrScope(theEnv,DOToString(temp)) != NULL) ? TRUE : FALSE);
00809 }
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828 static int CheckTwoClasses(
00829 void *theEnv,
00830 char *func,
00831 DEFCLASS **c1,
00832 DEFCLASS **c2)
00833 {
00834 DATA_OBJECT temp;
00835
00836 if (EnvArgTypeCheck(theEnv,func,1,SYMBOL,&temp) == FALSE)
00837 return(FALSE);
00838 *c1 = LookupDefclassByMdlOrScope(theEnv,DOToString(temp));
00839 if (*c1 == NULL)
00840 {
00841 ClassExistError(theEnv,func,ValueToString(temp.value));
00842 return(FALSE);
00843 }
00844 if (EnvArgTypeCheck(theEnv,func,2,SYMBOL,&temp) == FALSE)
00845 return(FALSE);
00846 *c2 = LookupDefclassByMdlOrScope(theEnv,DOToString(temp));
00847 if (*c2 == NULL)
00848 {
00849 ClassExistError(theEnv,func,ValueToString(temp.value));
00850 return(FALSE);
00851 }
00852 return(TRUE);
00853 }
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873 static SLOT_DESC *CheckSlotExists(
00874 void *theEnv,
00875 char *func,
00876 DEFCLASS **classBuffer,
00877 intBool existsErrorFlag,
00878 intBool inheritFlag)
00879 {
00880 SYMBOL_HN *ssym;
00881 int slotIndex;
00882 SLOT_DESC *sd;
00883
00884 ssym = CheckClassAndSlot(theEnv,func,classBuffer);
00885 if (ssym == NULL)
00886 return(NULL);
00887 slotIndex = FindInstanceTemplateSlot(theEnv,*classBuffer,ssym);
00888 if (slotIndex == -1)
00889 {
00890 if (existsErrorFlag)
00891 {
00892 SlotExistError(theEnv,ValueToString(ssym),func);
00893 SetEvaluationError(theEnv,TRUE);
00894 }
00895 return(NULL);
00896 }
00897 sd = (*classBuffer)->instanceTemplate[slotIndex];
00898 if ((sd->cls == *classBuffer) || inheritFlag)
00899 return(sd);
00900 PrintErrorID(theEnv,"CLASSEXM",1,FALSE);
00901 EnvPrintRouter(theEnv,WERROR,"Inherited slot ");
00902 EnvPrintRouter(theEnv,WERROR,ValueToString(ssym));
00903 EnvPrintRouter(theEnv,WERROR," from class ");
00904 PrintClassName(theEnv,WERROR,sd->cls,FALSE);
00905 EnvPrintRouter(theEnv,WERROR," is not valid for function ");
00906 EnvPrintRouter(theEnv,WERROR,func);
00907 EnvPrintRouter(theEnv,WERROR,"\n");
00908 SetEvaluationError(theEnv,TRUE);
00909 return(NULL);
00910 }
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924 static SLOT_DESC *LookupSlot(
00925 void *theEnv,
00926 DEFCLASS *theDefclass,
00927 char *slotName,
00928 intBool inheritFlag)
00929 {
00930 SYMBOL_HN *slotSymbol;
00931 int slotIndex;
00932 SLOT_DESC *sd;
00933
00934 slotSymbol = FindSymbolHN(theEnv,slotName);
00935 if (slotSymbol == NULL)
00936 return(NULL);
00937 slotIndex = FindInstanceTemplateSlot(theEnv,theDefclass,slotSymbol);
00938 if (slotIndex == -1)
00939 return(NULL);
00940 sd = theDefclass->instanceTemplate[slotIndex];
00941 if ((sd->cls != theDefclass) && (inheritFlag == FALSE))
00942 return(NULL);
00943 return(sd);
00944 }
00945
00946 #if DEBUGGING_FUNCTIONS
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960 static DEFCLASS *CheckClass(
00961 void *theEnv,
00962 char *func,
00963 char *cname)
00964 {
00965 DEFCLASS *cls;
00966
00967 cls = LookupDefclassByMdlOrScope(theEnv,cname);
00968 if (cls == NULL)
00969 ClassExistError(theEnv,func,cname);
00970 return(cls);
00971 }
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981 static char *GetClassNameArgument(
00982 void *theEnv,
00983 char *fname)
00984 {
00985 DATA_OBJECT temp;
00986
00987 if (EnvArgTypeCheck(theEnv,fname,1,SYMBOL,&temp) == FALSE)
00988 return(NULL);
00989 return(DOToString(temp));
00990 }
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002 static void PrintClassBrowse(
01003 void *theEnv,
01004 char *logicalName,
01005 DEFCLASS *cls,
01006 long depth)
01007 {
01008 long i;
01009
01010 for (i = 0 ; i < depth ; i++)
01011 EnvPrintRouter(theEnv,logicalName," ");
01012 EnvPrintRouter(theEnv,logicalName,EnvGetDefclassName(theEnv,(void *) cls));
01013 if (cls->directSuperclasses.classCount > 1)
01014 EnvPrintRouter(theEnv,logicalName," *");
01015 EnvPrintRouter(theEnv,logicalName,"\n");
01016 for (i = 0 ;i < cls->directSubclasses.classCount ; i++)
01017 PrintClassBrowse(theEnv,logicalName,cls->directSubclasses.classArray[i],depth+1);
01018 }
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031 static void DisplaySeparator(
01032 void *theEnv,
01033 char *logicalName,
01034 char *buf,
01035 int maxlen,
01036 int sepchar)
01037 {
01038 register int i;
01039
01040 for (i = 0 ; i < maxlen-2 ; i++)
01041 buf[i] = (char) sepchar;
01042 buf[i++] = '\n';
01043 buf[i] = '\0';
01044 EnvPrintRouter(theEnv,logicalName,buf);
01045 }
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076 static void DisplaySlotBasicInfo(
01077 void *theEnv,
01078 char *logicalName,
01079 char *slotNamePrintFormat,
01080 char *overrideMessagePrintFormat,
01081 char *buf,
01082 DEFCLASS *cls)
01083 {
01084 long i;
01085 SLOT_DESC *sp;
01086 char *createString;
01087
01088 gensprintf(buf,slotNamePrintFormat,"SLOTS");
01089 #if DEFRULE_CONSTRUCT
01090 genstrcat(buf,"FLD DEF PRP ACC STO MCH SRC VIS CRT ");
01091 #else
01092 genstrcat(buf,"FLD DEF PRP ACC STO SRC VIS CRT ");
01093 #endif
01094 EnvPrintRouter(theEnv,logicalName,buf);
01095 gensprintf(buf,overrideMessagePrintFormat,"OVRD-MSG");
01096 EnvPrintRouter(theEnv,logicalName,buf);
01097 EnvPrintRouter(theEnv,logicalName,"SOURCE(S)\n");
01098 for (i = 0 ; i < cls->instanceSlotCount ; i++)
01099 {
01100 sp = cls->instanceTemplate[i];
01101 gensprintf(buf,slotNamePrintFormat,ValueToString(sp->slotName->name));
01102 genstrcat(buf,sp->multiple ? "MLT " : "SGL ");
01103 if (sp->noDefault)
01104 genstrcat(buf,"NIL ");
01105 else
01106 genstrcat(buf,sp->dynamicDefault ? "DYN " : "STC ");
01107 genstrcat(buf,sp->noInherit ? "NIL " : "INH ");
01108 if (sp->initializeOnly)
01109 genstrcat(buf,"INT ");
01110 else if (sp->noWrite)
01111 genstrcat(buf," R ");
01112 else
01113 genstrcat(buf,"RW ");
01114 genstrcat(buf,sp->shared ? "SHR " : "LCL ");
01115 #if DEFRULE_CONSTRUCT
01116 genstrcat(buf,sp->reactive ? "RCT " : "NIL ");
01117 #endif
01118 genstrcat(buf,sp->composite ? "CMP " : "EXC ");
01119 genstrcat(buf,sp->publicVisibility ? "PUB " : "PRV ");
01120 createString = GetCreateAccessorString(sp);
01121 if (createString[1] == '\0')
01122 genstrcat(buf," ");
01123 genstrcat(buf,createString);
01124 if ((createString[1] == '\0') ? TRUE : (createString[2] == '\0'))
01125 genstrcat(buf," ");
01126 genstrcat(buf," ");
01127 EnvPrintRouter(theEnv,logicalName,buf);
01128 gensprintf(buf,overrideMessagePrintFormat,
01129 sp->noWrite ? "NIL" : ValueToString(sp->overrideMessage));
01130 EnvPrintRouter(theEnv,logicalName,buf);
01131 PrintSlotSources(theEnv,logicalName,sp->slotName->name,&sp->cls->allSuperclasses,0,TRUE);
01132 EnvPrintRouter(theEnv,logicalName,"\n");
01133 }
01134 }
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156 static intBool PrintSlotSources(
01157 void *theEnv,
01158 char *logicalName,
01159 SYMBOL_HN *sname,
01160 PACKED_CLASS_LINKS *sprec,
01161 long theIndex,
01162 int inhp)
01163 {
01164 SLOT_DESC *csp;
01165
01166 if (theIndex == sprec->classCount)
01167 return(FALSE);
01168 csp = FindClassSlot(sprec->classArray[theIndex],sname);
01169 if ((csp != NULL) ? ((csp->noInherit == 0) || inhp) : FALSE)
01170 {
01171 if (csp->composite)
01172 {
01173 if (PrintSlotSources(theEnv,logicalName,sname,sprec,theIndex+1,FALSE))
01174 EnvPrintRouter(theEnv,logicalName," ");
01175 }
01176 PrintClassName(theEnv,logicalName,sprec->classArray[theIndex],FALSE);
01177 return(TRUE);
01178 }
01179 else
01180 return(PrintSlotSources(theEnv,logicalName,sname,sprec,theIndex+1,FALSE));
01181 }
01182
01183
01184
01185
01186
01187
01188
01189
01190
01191
01192
01193
01194
01195
01196
01197
01198
01199
01200
01201
01202
01203
01204
01205
01206
01207
01208 static void DisplaySlotConstraintInfo(
01209 void *theEnv,
01210 char *logicalName,
01211 char *slotNamePrintFormat,
01212 char *buf,
01213 unsigned maxlen,
01214 DEFCLASS *cls)
01215 {
01216 long i;
01217 CONSTRAINT_RECORD *cr;
01218 char *strdest = "***describe-class***";
01219
01220 gensprintf(buf,slotNamePrintFormat,"SLOTS");
01221 genstrcat(buf,"SYM STR INN INA EXA FTA INT FLT\n");
01222 EnvPrintRouter(theEnv,logicalName,buf);
01223 for (i = 0 ; i < cls->instanceSlotCount ; i++)
01224 {
01225 cr = cls->instanceTemplate[i]->constraint;
01226 gensprintf(buf,slotNamePrintFormat,ValueToString(cls->instanceTemplate[i]->slotName->name));
01227 if (cr != NULL)
01228 {
01229 genstrcat(buf,ConstraintCode(cr,(unsigned) cr->symbolsAllowed,
01230 (unsigned) cr->symbolRestriction));
01231 genstrcat(buf,ConstraintCode(cr,(unsigned) cr->stringsAllowed,
01232 (unsigned) cr->stringRestriction));
01233 genstrcat(buf,ConstraintCode(cr,(unsigned) cr->instanceNamesAllowed,
01234 (unsigned) (cr->instanceNameRestriction || cr->classRestriction)));
01235 genstrcat(buf,ConstraintCode(cr,(unsigned) cr->instanceAddressesAllowed,
01236 (unsigned) cr->classRestriction));
01237 genstrcat(buf,ConstraintCode(cr,(unsigned) cr->externalAddressesAllowed,0));
01238 genstrcat(buf,ConstraintCode(cr,(unsigned) cr->factAddressesAllowed,0));
01239 genstrcat(buf,ConstraintCode(cr,(unsigned) cr->integersAllowed,
01240 (unsigned) cr->integerRestriction));
01241 genstrcat(buf,ConstraintCode(cr,(unsigned) cr->floatsAllowed,
01242 (unsigned) cr->floatRestriction));
01243 OpenStringDestination(theEnv,strdest,buf + strlen(buf),(maxlen - strlen(buf) - 1));
01244 if (cr->integersAllowed || cr->floatsAllowed || cr->anyAllowed)
01245 {
01246 EnvPrintRouter(theEnv,strdest,"RNG:[");
01247 PrintExpression(theEnv,strdest,cr->minValue);
01248 EnvPrintRouter(theEnv,strdest,"..");
01249 PrintExpression(theEnv,strdest,cr->maxValue);
01250 EnvPrintRouter(theEnv,strdest,"] ");
01251 }
01252 if (cls->instanceTemplate[i]->multiple)
01253 {
01254 EnvPrintRouter(theEnv,strdest,"CRD:[");
01255 PrintExpression(theEnv,strdest,cr->minFields);
01256 EnvPrintRouter(theEnv,strdest,"..");
01257 PrintExpression(theEnv,strdest,cr->maxFields);
01258 EnvPrintRouter(theEnv,strdest,"]");
01259 }
01260 }
01261 else
01262 {
01263 OpenStringDestination(theEnv,strdest,buf,maxlen);
01264 EnvPrintRouter(theEnv,strdest," + + + + + + + + RNG:[-oo..+oo]");
01265 if (cls->instanceTemplate[i]->multiple)
01266 EnvPrintRouter(theEnv,strdest," CRD:[0..+oo]");
01267 }
01268 EnvPrintRouter(theEnv,strdest,"\n");
01269 CloseStringDestination(theEnv,strdest);
01270 EnvPrintRouter(theEnv,logicalName,buf);
01271 }
01272 }
01273
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287 static char *ConstraintCode(
01288 CONSTRAINT_RECORD *cr,
01289 unsigned allow,
01290 unsigned restrictValues)
01291 {
01292 if (allow || cr->anyAllowed)
01293 {
01294 if (restrictValues || cr->anyRestriction) return " # ";
01295 else return " + ";
01296 }
01297 return(" ");
01298 }
01299
01300 #endif
01301
01302 #endif
01303