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 #include "setup.h"
00039
00040 #if OBJECT_SYSTEM
00041
00042 #ifndef _STDIO_INCLUDED_
00043 #define _STDIO_INCLUDED_
00044 #include <stdio.h>
00045 #endif
00046
00047 #include <string.h>
00048
00049 #include "argacces.h"
00050 #include "classcom.h"
00051 #include "classexm.h"
00052 #include "classfun.h"
00053 #include "classini.h"
00054 #include "envrnmnt.h"
00055 #include "memalloc.h"
00056 #include "insfun.h"
00057 #include "msgcom.h"
00058 #include "msgfun.h"
00059 #include "multifld.h"
00060 #include "prntutil.h"
00061
00062 #define _CLASSINF_SOURCE_
00063 #include "classinf.h"
00064
00065
00066
00067
00068
00069
00070
00071 static void SlotInfoSupportFunction(void *,DATA_OBJECT *,char *,void (*)(void *,void *,char *,DATA_OBJECT *));
00072 static unsigned CountSubclasses(DEFCLASS *,int,int);
00073 static unsigned StoreSubclasses(void *,unsigned,DEFCLASS *,int,int,short);
00074 static SLOT_DESC *SlotInfoSlot(void *,DATA_OBJECT *,DEFCLASS *,char *,char *);
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 globle int ClassAbstractPCommand(
00085 void *theEnv)
00086 {
00087 DATA_OBJECT tmp;
00088 DEFCLASS *cls;
00089
00090 if (EnvArgTypeCheck(theEnv,"class-abstractp",1,SYMBOL,&tmp) == FALSE)
00091 return(FALSE);
00092 cls = LookupDefclassByMdlOrScope(theEnv,DOToString(tmp));
00093 if (cls == NULL)
00094 {
00095 ClassExistError(theEnv,"class-abstractp",ValueToString(tmp.value));
00096 return(FALSE);
00097 }
00098 return(EnvClassAbstractP(theEnv,(void *) cls));
00099 }
00100
00101 #if DEFRULE_CONSTRUCT
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 globle int ClassReactivePCommand(
00114 void *theEnv)
00115 {
00116 DATA_OBJECT tmp;
00117 DEFCLASS *cls;
00118
00119 if (EnvArgTypeCheck(theEnv,"class-reactivep",1,SYMBOL,&tmp) == FALSE)
00120 return(FALSE);
00121 cls = LookupDefclassByMdlOrScope(theEnv,DOToString(tmp));
00122 if (cls == NULL)
00123 {
00124 ClassExistError(theEnv,"class-reactivep",ValueToString(tmp.value));
00125 return(FALSE);
00126 }
00127 return(EnvClassReactiveP(theEnv,(void *) cls));
00128 }
00129
00130 #endif
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146 globle void *ClassInfoFnxArgs(
00147 void *theEnv,
00148 char *fnx,
00149 int *inhp)
00150 {
00151 void *clsptr;
00152 DATA_OBJECT tmp;
00153
00154 *inhp = 0;
00155 if (EnvRtnArgCount(theEnv) == 0)
00156 {
00157 ExpectedCountError(theEnv,fnx,AT_LEAST,1);
00158 SetEvaluationError(theEnv,TRUE);
00159 return(NULL);
00160 }
00161 if (EnvArgTypeCheck(theEnv,fnx,1,SYMBOL,&tmp) == FALSE)
00162 return(NULL);
00163 clsptr = (void *) LookupDefclassByMdlOrScope(theEnv,DOToString(tmp));
00164 if (clsptr == NULL)
00165 {
00166 ClassExistError(theEnv,fnx,ValueToString(tmp.value));
00167 return(NULL);
00168 }
00169 if (EnvRtnArgCount(theEnv) == 2)
00170 {
00171 if (EnvArgTypeCheck(theEnv,fnx,2,SYMBOL,&tmp) == FALSE)
00172 return(NULL);
00173 if (strcmp(ValueToString(tmp.value),"inherit") == 0)
00174 *inhp = 1;
00175 else
00176 {
00177 SyntaxErrorMessage(theEnv,fnx);
00178 SetEvaluationError(theEnv,TRUE);
00179 return(NULL);
00180 }
00181 }
00182 return(clsptr);
00183 }
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195 globle void ClassSlotsCommand(
00196 void *theEnv,
00197 DATA_OBJECT *result)
00198 {
00199 int inhp;
00200 void *clsptr;
00201
00202 clsptr = ClassInfoFnxArgs(theEnv,"class-slots",&inhp);
00203 if (clsptr == NULL)
00204 {
00205 EnvSetMultifieldErrorValue(theEnv,result);
00206 return;
00207 }
00208 EnvClassSlots(theEnv,clsptr,result,inhp);
00209 }
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221 globle void ClassSuperclassesCommand(
00222 void *theEnv,
00223 DATA_OBJECT *result)
00224 {
00225 int inhp;
00226 void *clsptr;
00227
00228 clsptr = ClassInfoFnxArgs(theEnv,"class-superclasses",&inhp);
00229 if (clsptr == NULL)
00230 {
00231 EnvSetMultifieldErrorValue(theEnv,result);
00232 return;
00233 }
00234 EnvClassSuperclasses(theEnv,clsptr,result,inhp);
00235 }
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247 globle void ClassSubclassesCommand(
00248 void *theEnv,
00249 DATA_OBJECT *result)
00250 {
00251 int inhp;
00252 void *clsptr;
00253
00254 clsptr = ClassInfoFnxArgs(theEnv,"class-subclasses",&inhp);
00255 if (clsptr == NULL)
00256 {
00257 EnvSetMultifieldErrorValue(theEnv,result);
00258 return;
00259 }
00260 EnvClassSubclasses(theEnv,clsptr,result,inhp);
00261 }
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273 globle void GetDefmessageHandlersListCmd(
00274 void *theEnv,
00275 DATA_OBJECT *result)
00276 {
00277 int inhp;
00278 void *clsptr;
00279
00280 if (EnvRtnArgCount(theEnv) == 0)
00281 EnvGetDefmessageHandlerList(theEnv,NULL,result,0);
00282 else
00283 {
00284 clsptr = ClassInfoFnxArgs(theEnv,"get-defmessage-handler-list",&inhp);
00285 if (clsptr == NULL)
00286 {
00287 EnvSetMultifieldErrorValue(theEnv,result);
00288 return;
00289 }
00290 EnvGetDefmessageHandlerList(theEnv,clsptr,result,inhp);
00291 }
00292 }
00293
00294
00295
00296
00297 globle void SlotFacetsCommand(
00298 void *theEnv,
00299 DATA_OBJECT *result)
00300 {
00301 SlotInfoSupportFunction(theEnv,result,"slot-facets",EnvSlotFacets);
00302 }
00303
00304 globle void SlotSourcesCommand(
00305 void *theEnv,
00306 DATA_OBJECT *result)
00307 {
00308 SlotInfoSupportFunction(theEnv,result,"slot-sources",EnvSlotSources);
00309 }
00310
00311 globle void SlotTypesCommand(
00312 void *theEnv,
00313 DATA_OBJECT *result)
00314 {
00315 SlotInfoSupportFunction(theEnv,result,"slot-types",EnvSlotTypes);
00316 }
00317
00318 globle void SlotAllowedValuesCommand(
00319 void *theEnv,
00320 DATA_OBJECT *result)
00321 {
00322 SlotInfoSupportFunction(theEnv,result,"slot-allowed-values",EnvSlotAllowedValues);
00323 }
00324
00325 globle void SlotAllowedClassesCommand(
00326 void *theEnv,
00327 DATA_OBJECT *result)
00328 {
00329 SlotInfoSupportFunction(theEnv,result,"slot-allowed-classes",EnvSlotAllowedClasses);
00330 }
00331
00332 globle void SlotRangeCommand(
00333 void *theEnv,
00334 DATA_OBJECT *result)
00335 {
00336 SlotInfoSupportFunction(theEnv,result,"slot-range",EnvSlotRange);
00337 }
00338
00339 globle void SlotCardinalityCommand(
00340 void *theEnv,
00341 DATA_OBJECT *result)
00342 {
00343 SlotInfoSupportFunction(theEnv,result,"slot-cardinality",EnvSlotCardinality);
00344 }
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354 #if WIN_BTC
00355 #pragma argsused
00356 #endif
00357 globle intBool EnvClassAbstractP(
00358 void *theEnv,
00359 void *clsptr)
00360 {
00361 #if MAC_MCW || WIN_MCW || MAC_XCD
00362 #pragma unused(theEnv)
00363 #endif
00364
00365 return(((DEFCLASS *) clsptr)->abstract);
00366 }
00367
00368 #if DEFRULE_CONSTRUCT
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378 #if WIN_BTC
00379 #pragma argsused
00380 #endif
00381 globle intBool EnvClassReactiveP(
00382 void *theEnv,
00383 void *clsptr)
00384 {
00385 #if MAC_MCW || WIN_MCW || MAC_XCD
00386 #pragma unused(theEnv)
00387 #endif
00388
00389 return(((DEFCLASS *) clsptr)->reactive);
00390 }
00391
00392 #endif
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406 globle void EnvClassSlots(
00407 void *theEnv,
00408 void *clsptr,
00409 DATA_OBJECT *result,
00410 int inhp)
00411 {
00412 long size;
00413 register DEFCLASS *cls;
00414 long i;
00415
00416 cls = (DEFCLASS *) clsptr;
00417 size = inhp ? cls->instanceSlotCount : cls->slotCount;
00418 result->type = MULTIFIELD;
00419 SetpDOBegin(result,1);
00420 SetpDOEnd(result,size);
00421 result->value = (void *) EnvCreateMultifield(theEnv,size);
00422 if (size == 0)
00423 return;
00424 if (inhp)
00425 {
00426 for (i = 0 ; i < cls->instanceSlotCount ; i++)
00427 {
00428 SetMFType(result->value,i+1,SYMBOL);
00429 SetMFValue(result->value,i+1,cls->instanceTemplate[i]->slotName->name);
00430 }
00431 }
00432 else
00433 {
00434 for (i = 0 ; i < cls->slotCount ; i++)
00435 {
00436 SetMFType(result->value,i+1,SYMBOL);
00437 SetMFValue(result->value,i+1,cls->slots[i].slotName->name);
00438 }
00439 }
00440 }
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455 globle void EnvGetDefmessageHandlerList(
00456 void *theEnv,
00457 void *clsptr,
00458 DATA_OBJECT *result,
00459 int inhp)
00460 {
00461 DEFCLASS *cls,*svcls,*svnxt,*supcls;
00462 long j;
00463 register int classi,classiLimit;
00464 unsigned long i, sublen, len;
00465
00466 if (clsptr == NULL)
00467 {
00468 inhp = 0;
00469 cls = (DEFCLASS *) EnvGetNextDefclass(theEnv,NULL);
00470 svnxt = (DEFCLASS *) EnvGetNextDefclass(theEnv,(void *) cls);
00471 }
00472 else
00473 {
00474 cls = (DEFCLASS *) clsptr;
00475 svnxt = (DEFCLASS *) EnvGetNextDefclass(theEnv,(void *) cls);
00476 SetNextDefclass((void *) cls,NULL);
00477 }
00478 for (svcls = cls , i = 0 ;
00479 cls != NULL ;
00480 cls = (DEFCLASS *) EnvGetNextDefclass(theEnv,(void *) cls))
00481 {
00482 classiLimit = inhp ? cls->allSuperclasses.classCount : 1;
00483 for (classi = 0 ; classi < classiLimit ; classi++)
00484 i += cls->allSuperclasses.classArray[classi]->handlerCount;
00485 }
00486 len = i * 3;
00487 result->type = MULTIFIELD;
00488 SetpDOBegin(result,1);
00489 SetpDOEnd(result,len);
00490 result->value = (void *) EnvCreateMultifield(theEnv,len);
00491 for (cls = svcls , sublen = 0 ;
00492 cls != NULL ;
00493 cls = (DEFCLASS *) EnvGetNextDefclass(theEnv,(void *) cls))
00494 {
00495 classiLimit = inhp ? cls->allSuperclasses.classCount : 1;
00496 for (classi = 0 ; classi < classiLimit ; classi++)
00497 {
00498 supcls = cls->allSuperclasses.classArray[classi];
00499 if (inhp == 0)
00500 i = sublen + 1;
00501 else
00502 i = len - (supcls->handlerCount * 3) - sublen + 1;
00503 for (j = 0 ; j < supcls->handlerCount ; j++)
00504 {
00505 SetMFType(result->value,i,SYMBOL);
00506 SetMFValue(result->value,i++,GetDefclassNamePointer((void *) supcls));
00507 SetMFType(result->value,i,SYMBOL);
00508 SetMFValue(result->value,i++,supcls->handlers[j].name);
00509 SetMFType(result->value,i,SYMBOL);
00510 SetMFValue(result->value,i++,EnvAddSymbol(theEnv,MessageHandlerData(theEnv)->hndquals[supcls->handlers[j].type]));
00511 }
00512 sublen += supcls->handlerCount * 3;
00513 }
00514 }
00515 if (svcls != NULL)
00516 SetNextDefclass((void *) svcls,(void *) svnxt);
00517 }
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531 globle void EnvClassSuperclasses(
00532 void *theEnv,
00533 void *clsptr,
00534 DATA_OBJECT *result,
00535 int inhp)
00536 {
00537 PACKED_CLASS_LINKS *plinks;
00538 unsigned offset;
00539 long i,j;
00540
00541 if (inhp)
00542 {
00543 plinks = &((DEFCLASS *) clsptr)->allSuperclasses;
00544 offset = 1;
00545 }
00546 else
00547 {
00548 plinks = &((DEFCLASS *) clsptr)->directSuperclasses;
00549 offset = 0;
00550 }
00551 result->type = MULTIFIELD;
00552 result->begin = 0;
00553 SetpDOEnd(result,plinks->classCount - offset);
00554 result->value = (void *) EnvCreateMultifield(theEnv,result->end + 1U);
00555 if (result->end == -1)
00556 return;
00557 for (i = offset , j = 1 ; i < plinks->classCount ; i++ , j++)
00558 {
00559 SetMFType(result->value,j,SYMBOL);
00560 SetMFValue(result->value,j,GetDefclassNamePointer((void *) plinks->classArray[i]));
00561 }
00562 }
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576 globle void EnvClassSubclasses(
00577 void *theEnv,
00578 void *clsptr,
00579 DATA_OBJECT *result,
00580 int inhp)
00581 {
00582 register unsigned i;
00583 register int id;
00584
00585 if ((id = GetTraversalID(theEnv)) == -1)
00586 return;
00587 i = CountSubclasses((DEFCLASS *) clsptr,inhp,id);
00588 ReleaseTraversalID(theEnv);
00589 result->type = MULTIFIELD;
00590 result->begin = 0;
00591 SetpDOEnd(result,i);
00592 result->value = (void *) EnvCreateMultifield(theEnv,i);
00593 if (i == 0)
00594 return;
00595 if ((id = GetTraversalID(theEnv)) == -1)
00596 return;
00597 StoreSubclasses(result->value,1,(DEFCLASS *) clsptr,inhp,id,TRUE);
00598 ReleaseTraversalID(theEnv);
00599 }
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613 globle void ClassSubclassAddresses(
00614 void *theEnv,
00615 void *clsptr,
00616 DATA_OBJECT *result,
00617 int inhp)
00618 {
00619 register unsigned i;
00620 register int id;
00621
00622 if ((id = GetTraversalID(theEnv)) == -1)
00623 return;
00624 i = CountSubclasses((DEFCLASS *) clsptr,inhp,id);
00625 ReleaseTraversalID(theEnv);
00626 result->type = MULTIFIELD;
00627 result->begin = 0;
00628 SetpDOEnd(result,i);
00629 result->value = (void *) EnvCreateMultifield(theEnv,i);
00630 if (i == 0)
00631 return;
00632 if ((id = GetTraversalID(theEnv)) == -1)
00633 return;
00634 StoreSubclasses(result->value,1,(DEFCLASS *) clsptr,inhp,id,FALSE);
00635 ReleaseTraversalID(theEnv);
00636 }
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651 globle void EnvSlotFacets(
00652 void *theEnv,
00653 void *clsptr,
00654 char *sname,
00655 DATA_OBJECT *result)
00656 {
00657 register int i;
00658 register SLOT_DESC *sp;
00659
00660 if ((sp = SlotInfoSlot(theEnv,result,(DEFCLASS *) clsptr,sname,"slot-facets")) == NULL)
00661 return;
00662 #if DEFRULE_CONSTRUCT
00663 result->end = 9;
00664 result->value = (void *) EnvCreateMultifield(theEnv,10L);
00665 for (i = 1 ; i <= 10 ; i++)
00666 SetMFType(result->value,i,SYMBOL);
00667 #else
00668 result->end = 8;
00669 result->value = (void *) EnvCreateMultifield(theEnv,9L);
00670 for (i = 1 ; i <= 9 ; i++)
00671 SetMFType(result->value,i,SYMBOL);
00672 #endif
00673 if (sp->multiple)
00674 SetMFValue(result->value,1,EnvAddSymbol(theEnv,"MLT"));
00675 else
00676 SetMFValue(result->value,1,EnvAddSymbol(theEnv,"SGL"));
00677
00678 if (sp->noDefault)
00679 SetMFValue(result->value,2,EnvAddSymbol(theEnv,"NIL"));
00680 else
00681 {
00682 if (sp->dynamicDefault)
00683 SetMFValue(result->value,2,EnvAddSymbol(theEnv,"DYN"));
00684 else
00685 SetMFValue(result->value,2,EnvAddSymbol(theEnv,"STC"));
00686 }
00687
00688 if (sp->noInherit)
00689 SetMFValue(result->value,3,EnvAddSymbol(theEnv,"NIL"));
00690 else
00691 SetMFValue(result->value,3,EnvAddSymbol(theEnv,"INH"));
00692
00693 if (sp->initializeOnly)
00694 SetMFValue(result->value,4,EnvAddSymbol(theEnv,"INT"));
00695 else if (sp->noWrite)
00696 SetMFValue(result->value,4,EnvAddSymbol(theEnv,"R"));
00697 else
00698 SetMFValue(result->value,4,EnvAddSymbol(theEnv,"RW"));
00699
00700 if (sp->shared)
00701 SetMFValue(result->value,5,EnvAddSymbol(theEnv,"SHR"));
00702 else
00703 SetMFValue(result->value,5,EnvAddSymbol(theEnv,"LCL"));
00704
00705 #if DEFRULE_CONSTRUCT
00706 if (sp->reactive)
00707 SetMFValue(result->value,6,EnvAddSymbol(theEnv,"RCT"));
00708 else
00709 SetMFValue(result->value,6,EnvAddSymbol(theEnv,"NIL"));
00710
00711 if (sp->composite)
00712 SetMFValue(result->value,7,EnvAddSymbol(theEnv,"CMP"));
00713 else
00714 SetMFValue(result->value,7,EnvAddSymbol(theEnv,"EXC"));
00715
00716 if (sp->publicVisibility)
00717 SetMFValue(result->value,8,EnvAddSymbol(theEnv,"PUB"));
00718 else
00719 SetMFValue(result->value,8,EnvAddSymbol(theEnv,"PRV"));
00720
00721 SetMFValue(result->value,9,EnvAddSymbol(theEnv,GetCreateAccessorString((void *) sp)));
00722 SetMFValue(result->value,10,sp->noWrite ? EnvAddSymbol(theEnv,"NIL") : (void *) sp->overrideMessage);
00723 #else
00724 if (sp->composite)
00725 SetMFValue(result->value,6,EnvAddSymbol(theEnv,"CMP"));
00726 else
00727 SetMFValue(result->value,6,EnvAddSymbol(theEnv,"EXC"));
00728
00729 if (sp->publicVisibility)
00730 SetMFValue(result->value,7,EnvAddSymbol(theEnv,"PUB"));
00731 else
00732 SetMFValue(result->value,7,EnvAddSymbol(theEnv,"PRV"));
00733
00734 SetMFValue(result->value,8,EnvAddSymbol(theEnv,GetCreateAccessorString((void *) sp)));
00735 SetMFValue(result->value,9,sp->noWrite ? EnvAddSymbol(theEnv,"NIL") : (void *) sp->overrideMessage);
00736 #endif
00737 }
00738
00739 globle void EnvSlotSources(
00740 void *theEnv,
00741 void *clsptr,
00742 char *sname,
00743 DATA_OBJECT *result)
00744 {
00745 register unsigned i;
00746 register int classi;
00747 register SLOT_DESC *sp,*csp;
00748 CLASS_LINK *ctop,*ctmp;
00749 DEFCLASS *cls;
00750
00751 if ((sp = SlotInfoSlot(theEnv,result,(DEFCLASS *) clsptr,sname,"slot-sources")) == NULL)
00752 return;
00753 i = 1;
00754 ctop = get_struct(theEnv,classLink);
00755 ctop->cls = sp->cls;
00756 ctop->nxt = NULL;
00757 if (sp->composite)
00758 {
00759 for (classi = 1 ; classi < sp->cls->allSuperclasses.classCount ; classi++)
00760 {
00761 cls = sp->cls->allSuperclasses.classArray[classi];
00762 csp = FindClassSlot(cls,sp->slotName->name);
00763 if ((csp != NULL) ? (csp->noInherit == 0) : FALSE)
00764 {
00765 ctmp = get_struct(theEnv,classLink);
00766 ctmp->cls = cls;
00767 ctmp->nxt = ctop;
00768 ctop = ctmp;
00769 i++;
00770 if (csp->composite == 0)
00771 break;
00772 }
00773 }
00774 }
00775 SetpDOEnd(result,i);
00776 result->value = (void *) EnvCreateMultifield(theEnv,i);
00777 for (ctmp = ctop , i = 1 ; ctmp != NULL ; ctmp = ctmp->nxt , i++)
00778 {
00779 SetMFType(result->value,i,SYMBOL);
00780 SetMFValue(result->value,i,GetDefclassNamePointer((void *) ctmp->cls));
00781 }
00782 DeleteClassLinks(theEnv,ctop);
00783 }
00784
00785 globle void EnvSlotTypes(
00786 void *theEnv,
00787 void *clsptr,
00788 char *sname,
00789 DATA_OBJECT *result)
00790 {
00791 register unsigned i,j;
00792 register SLOT_DESC *sp;
00793 char typemap[2];
00794 unsigned msize;
00795
00796 if ((sp = SlotInfoSlot(theEnv,result,(DEFCLASS *) clsptr,sname,"slot-types")) == NULL)
00797 return;
00798 if ((sp->constraint != NULL) ? sp->constraint->anyAllowed : TRUE)
00799 {
00800 typemap[0] = typemap[1] = (char) 0xFF;
00801 ClearBitMap(typemap,MULTIFIELD);
00802 msize = 8;
00803 }
00804 else
00805 {
00806 typemap[0] = typemap[1] = (char) 0x00;
00807 msize = 0;
00808 if (sp->constraint->symbolsAllowed)
00809 {
00810 msize++;
00811 SetBitMap(typemap,SYMBOL);
00812 }
00813 if (sp->constraint->stringsAllowed)
00814 {
00815 msize++;
00816 SetBitMap(typemap,STRING);
00817 }
00818 if (sp->constraint->floatsAllowed)
00819 {
00820 msize++;
00821 SetBitMap(typemap,FLOAT);
00822 }
00823 if (sp->constraint->integersAllowed)
00824 {
00825 msize++;
00826 SetBitMap(typemap,INTEGER);
00827 }
00828 if (sp->constraint->instanceNamesAllowed)
00829 {
00830 msize++;
00831 SetBitMap(typemap,INSTANCE_NAME);
00832 }
00833 if (sp->constraint->instanceAddressesAllowed)
00834 {
00835 msize++;
00836 SetBitMap(typemap,INSTANCE_ADDRESS);
00837 }
00838 if (sp->constraint->externalAddressesAllowed)
00839 {
00840 msize++;
00841 SetBitMap(typemap,EXTERNAL_ADDRESS);
00842 }
00843 if (sp->constraint->factAddressesAllowed)
00844 {
00845 msize++;
00846 SetBitMap(typemap,FACT_ADDRESS);
00847 }
00848 }
00849 SetpDOEnd(result,msize);
00850 result->value = EnvCreateMultifield(theEnv,msize);
00851 i = 1;
00852 j = 0;
00853 while (i <= msize)
00854 {
00855 if (TestBitMap(typemap,j))
00856 {
00857 SetMFType(result->value,i,SYMBOL);
00858 SetMFValue(result->value,i,
00859 (void *) GetDefclassNamePointer((void *)
00860 DefclassData(theEnv)->PrimitiveClassMap[j]));
00861 i++;
00862 }
00863 j++;
00864 }
00865 }
00866
00867 globle void EnvSlotAllowedValues(
00868 void *theEnv,
00869 void *clsptr,
00870 char *sname,
00871 DATA_OBJECT *result)
00872 {
00873 register int i;
00874 register SLOT_DESC *sp;
00875 register EXPRESSION *theExp;
00876
00877 if ((sp = SlotInfoSlot(theEnv,result,(DEFCLASS *) clsptr,sname,"slot-allowed-values")) == NULL)
00878 return;
00879 if ((sp->constraint != NULL) ? (sp->constraint->restrictionList == NULL) : TRUE)
00880 {
00881 result->type = SYMBOL;
00882 result->value = EnvFalseSymbol(theEnv);
00883 return;
00884 }
00885 result->end = ExpressionSize(sp->constraint->restrictionList) - 1;
00886 result->value = EnvCreateMultifield(theEnv,(unsigned long) (result->end + 1));
00887 i = 1;
00888 theExp = sp->constraint->restrictionList;
00889 while (theExp != NULL)
00890 {
00891 SetMFType(result->value,i,theExp->type);
00892 SetMFValue(result->value,i,theExp->value);
00893 theExp = theExp->nextArg;
00894 i++;
00895 }
00896 }
00897
00898 globle void EnvSlotAllowedClasses(
00899 void *theEnv,
00900 void *clsptr,
00901 char *sname,
00902 DATA_OBJECT *result)
00903 {
00904 register int i;
00905 register SLOT_DESC *sp;
00906 register EXPRESSION *theExp;
00907
00908 if ((sp = SlotInfoSlot(theEnv,result,(DEFCLASS *) clsptr,sname,"slot-allowed-classes")) == NULL)
00909 return;
00910 if ((sp->constraint != NULL) ? (sp->constraint->classList == NULL) : TRUE)
00911 {
00912 result->type = SYMBOL;
00913 result->value = EnvFalseSymbol(theEnv);
00914 return;
00915 }
00916 result->end = ExpressionSize(sp->constraint->classList) - 1;
00917 result->value = EnvCreateMultifield(theEnv,(unsigned long) (result->end + 1));
00918 i = 1;
00919 theExp = sp->constraint->classList;
00920 while (theExp != NULL)
00921 {
00922 SetMFType(result->value,i,theExp->type);
00923 SetMFValue(result->value,i,theExp->value);
00924 theExp = theExp->nextArg;
00925 i++;
00926 }
00927 }
00928
00929 globle void EnvSlotRange(
00930 void *theEnv,
00931 void *clsptr,
00932 char *sname,
00933 DATA_OBJECT *result)
00934 {
00935 register SLOT_DESC *sp;
00936
00937 if ((sp = SlotInfoSlot(theEnv,result,(DEFCLASS *) clsptr,sname,"slot-range")) == NULL)
00938 return;
00939 if ((sp->constraint == NULL) ? FALSE :
00940 (sp->constraint->anyAllowed || sp->constraint->floatsAllowed ||
00941 sp->constraint->integersAllowed))
00942 {
00943 result->end = 1;
00944 result->value = EnvCreateMultifield(theEnv,2L);
00945 SetMFType(result->value,1,sp->constraint->minValue->type);
00946 SetMFValue(result->value,1,sp->constraint->minValue->value);
00947 SetMFType(result->value,2,sp->constraint->maxValue->type);
00948 SetMFValue(result->value,2,sp->constraint->maxValue->value);
00949 }
00950 else
00951 {
00952 result->type = SYMBOL;
00953 result->value = EnvFalseSymbol(theEnv);
00954 return;
00955 }
00956 }
00957
00958 globle void EnvSlotCardinality(
00959 void *theEnv,
00960 void *clsptr,
00961 char *sname,
00962 DATA_OBJECT *result)
00963 {
00964 register SLOT_DESC *sp;
00965
00966 if ((sp = SlotInfoSlot(theEnv,result,(DEFCLASS *) clsptr,sname,"slot-cardinality")) == NULL)
00967 return;
00968 if (sp->multiple == 0)
00969 {
00970 EnvSetMultifieldErrorValue(theEnv,result);
00971 return;
00972 }
00973 result->end = 1;
00974 result->value = EnvCreateMultifield(theEnv,2L);
00975 if (sp->constraint != NULL)
00976 {
00977 SetMFType(result->value,1,sp->constraint->minFields->type);
00978 SetMFValue(result->value,1,sp->constraint->minFields->value);
00979 SetMFType(result->value,2,sp->constraint->maxFields->type);
00980 SetMFValue(result->value,2,sp->constraint->maxFields->value);
00981 }
00982 else
00983 {
00984 SetMFType(result->value,1,INTEGER);
00985 SetMFValue(result->value,1,SymbolData(theEnv)->Zero);
00986 SetMFType(result->value,2,SYMBOL);
00987 SetMFValue(result->value,2,SymbolData(theEnv)->PositiveInfinity);
00988 }
00989 }
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009 static void SlotInfoSupportFunction(
01010 void *theEnv,
01011 DATA_OBJECT *result,
01012 char *fnxname,
01013 void (*fnx)(void *,void *,char *,DATA_OBJECT *))
01014 {
01015 SYMBOL_HN *ssym;
01016 DEFCLASS *cls;
01017
01018 ssym = CheckClassAndSlot(theEnv,fnxname,&cls);
01019 if (ssym == NULL)
01020 {
01021 EnvSetMultifieldErrorValue(theEnv,result);
01022 return;
01023 }
01024 (*fnx)(theEnv,(void *) cls,ValueToString(ssym),result);
01025 }
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038 static unsigned CountSubclasses(
01039 DEFCLASS *cls,
01040 int inhp,
01041 int tvid)
01042 {
01043 long i,cnt;
01044 register DEFCLASS *subcls;
01045
01046 for (cnt = 0 , i = 0 ; i < cls->directSubclasses.classCount ; i++)
01047 {
01048 subcls = cls->directSubclasses.classArray[i];
01049 if (TestTraversalID(subcls->traversalRecord,tvid) == 0)
01050 {
01051 cnt++;
01052 SetTraversalID(subcls->traversalRecord,tvid);
01053 if (inhp && (subcls->directSubclasses.classCount != 0))
01054 cnt += CountSubclasses(subcls,inhp,tvid);
01055 }
01056 }
01057 return(cnt);
01058 }
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073 static unsigned StoreSubclasses(
01074 void *mfval,
01075 unsigned si,
01076 DEFCLASS *cls,
01077 int inhp,
01078 int tvid,
01079 short storeName)
01080 {
01081 long i,classi;
01082 register DEFCLASS *subcls;
01083
01084 for (i = si , classi = 0 ; classi < cls->directSubclasses.classCount ; classi++)
01085 {
01086 subcls = cls->directSubclasses.classArray[classi];
01087 if (TestTraversalID(subcls->traversalRecord,tvid) == 0)
01088 {
01089 SetTraversalID(subcls->traversalRecord,tvid);
01090 if (storeName)
01091 {
01092 SetMFType(mfval,i,SYMBOL);
01093 SetMFValue(mfval,i++,(void *) GetDefclassNamePointer((void *) subcls));
01094 }
01095 else
01096 {
01097 SetMFType(mfval,i,DEFCLASS_PTR);
01098 SetMFValue(mfval,i++,(void *) subcls);
01099 }
01100
01101 if (inhp && (subcls->directSubclasses.classCount != 0))
01102 i += StoreSubclasses(mfval,i,subcls,inhp,tvid,storeName);
01103 }
01104 }
01105 return(i - si);
01106 }
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122 static SLOT_DESC *SlotInfoSlot(
01123 void *theEnv,
01124 DATA_OBJECT *result,
01125 DEFCLASS *cls,
01126 char *sname,
01127 char *fnxname)
01128 {
01129 SYMBOL_HN *ssym;
01130 int i;
01131
01132 if ((ssym = FindSymbolHN(theEnv,sname)) == NULL)
01133 {
01134 SetEvaluationError(theEnv,TRUE);
01135 EnvSetMultifieldErrorValue(theEnv,result);
01136 return(NULL);
01137 }
01138 i = FindInstanceTemplateSlot(theEnv,cls,ssym);
01139 if (i == -1)
01140 {
01141 SlotExistError(theEnv,sname,fnxname);
01142 SetEvaluationError(theEnv,TRUE);
01143 EnvSetMultifieldErrorValue(theEnv,result);
01144 return(NULL);
01145 }
01146 result->type = MULTIFIELD;
01147 result->begin = 0;
01148 return(cls->instanceTemplate[i]);
01149 }
01150
01151 #endif