📄 classinf.c
字号:
DESCRIPTION : Determines if a class is reactive or not
INPUTS : Generic pointer to class
RETURNS : 1 if class is reactive, 0 otherwise
SIDE EFFECTS : None
NOTES : None
********************************************************************/
#if IBM_TBC
#pragma argsused
#endif
globle intBool EnvClassReactiveP(
void *theEnv,
void *clsptr)
{
#if MAC_MCW || IBM_MCW || MAC_XCD
#pragma unused(theEnv)
#endif
return(((DEFCLASS *) clsptr)->reactive);
}
#endif
/********************************************************************
NAME : EnvClassSlots
DESCRIPTION : Groups slot info for a class into a multifield value
for dynamic perusal
INPUTS : 1) Generic pointer to class
2) Data object buffer to hold the slots of the class
3) Include (1) or exclude (0) inherited slots
RETURNS : Nothing useful
SIDE EFFECTS : Creates a multifield storing the names of
the slots of the class
NOTES : None
********************************************************************/
globle void EnvClassSlots(
void *theEnv,
void *clsptr,
DATA_OBJECT *result,
int inhp)
{
unsigned long size;
register DEFCLASS *cls;
register unsigned long i;
cls = (DEFCLASS *) clsptr;
size = inhp ? cls->instanceSlotCount : cls->slotCount;
result->type = MULTIFIELD;
SetpDOBegin(result,1);
SetpDOEnd(result,size);
result->value = (void *) EnvCreateMultifield(theEnv,size);
if (size == 0)
return;
if (inhp)
{
for (i = 0 ; i < cls->instanceSlotCount ; i++)
{
SetMFType(result->value,i+1,SYMBOL);
SetMFValue(result->value,i+1,cls->instanceTemplate[i]->slotName->name);
}
}
else
{
for (i = 0 ; i < cls->slotCount ; i++)
{
SetMFType(result->value,i+1,SYMBOL);
SetMFValue(result->value,i+1,cls->slots[i].slotName->name);
}
}
}
/************************************************************************
NAME : EnvGetDefmessageHandlerList
DESCRIPTION : Groups handler info for a class into a multifield value
for dynamic perusal
INPUTS : 1) Generic pointer to class (NULL to get handlers for
all classes)
2) Data object buffer to hold the handlers of the class
3) Include (1) or exclude (0) inherited handlers
RETURNS : Nothing useful
SIDE EFFECTS : Creates a multifield storing the names and types of
the message-handlers of the class
NOTES : None
************************************************************************/
globle void EnvGetDefmessageHandlerList(
void *theEnv,
void *clsptr,
DATA_OBJECT *result,
int inhp)
{
DEFCLASS *cls,*svcls,*svnxt,*supcls;
unsigned j;
register int classi,classiLimit;
unsigned long i, sublen, len;
if (clsptr == NULL)
{
inhp = 0;
cls = (DEFCLASS *) EnvGetNextDefclass(theEnv,NULL);
svnxt = (DEFCLASS *) EnvGetNextDefclass(theEnv,(void *) cls);
}
else
{
cls = (DEFCLASS *) clsptr;
svnxt = (DEFCLASS *) EnvGetNextDefclass(theEnv,(void *) cls);
SetNextDefclass((void *) cls,NULL);
}
for (svcls = cls , i = 0 ;
cls != NULL ;
cls = (DEFCLASS *) EnvGetNextDefclass(theEnv,(void *) cls))
{
classiLimit = inhp ? cls->allSuperclasses.classCount : 1;
for (classi = 0 ; classi < classiLimit ; classi++)
i += cls->allSuperclasses.classArray[classi]->handlerCount;
}
len = i * 3;
result->type = MULTIFIELD;
SetpDOBegin(result,1);
SetpDOEnd(result,len);
result->value = (void *) EnvCreateMultifield(theEnv,len);
for (cls = svcls , sublen = 0 ;
cls != NULL ;
cls = (DEFCLASS *) EnvGetNextDefclass(theEnv,(void *) cls))
{
classiLimit = inhp ? cls->allSuperclasses.classCount : 1;
for (classi = 0 ; classi < classiLimit ; classi++)
{
supcls = cls->allSuperclasses.classArray[classi];
if (inhp == 0)
i = sublen + 1;
else
i = len - (supcls->handlerCount * 3) - sublen + 1;
for (j = 0 ; j < supcls->handlerCount ; j++)
{
SetMFType(result->value,i,SYMBOL);
SetMFValue(result->value,i++,GetDefclassNamePointer((void *) supcls));
SetMFType(result->value,i,SYMBOL);
SetMFValue(result->value,i++,supcls->handlers[j].name);
SetMFType(result->value,i,SYMBOL);
SetMFValue(result->value,i++,EnvAddSymbol(theEnv,MessageHandlerData(theEnv)->hndquals[supcls->handlers[j].type]));
}
sublen += supcls->handlerCount * 3;
}
}
if (svcls != NULL)
SetNextDefclass((void *) svcls,(void *) svnxt);
}
/***************************************************************************
NAME : EnvClassSuperclasses
DESCRIPTION : Groups the names of superclasses into a multifield
value for dynamic perusal
INPUTS : 1) Generic pointer to class
2) Data object buffer to hold the superclasses of the class
3) Include (1) or exclude (0) indirect superclasses
RETURNS : Nothing useful
SIDE EFFECTS : Creates a multifield storing the names of
the superclasses of the class
NOTES : None
***************************************************************************/
globle void EnvClassSuperclasses(
void *theEnv,
void *clsptr,
DATA_OBJECT *result,
int inhp)
{
PACKED_CLASS_LINKS *plinks;
unsigned offset;
register unsigned i,j;
if (inhp)
{
plinks = &((DEFCLASS *) clsptr)->allSuperclasses;
offset = 1;
}
else
{
plinks = &((DEFCLASS *) clsptr)->directSuperclasses;
offset = 0;
}
result->type = MULTIFIELD;
result->begin = 0;
SetpDOEnd(result,plinks->classCount - offset);
result->value = (void *) EnvCreateMultifield(theEnv,result->end + 1U);
if (result->end == -1)
return;
for (i = offset , j = 1 ; i < plinks->classCount ; i++ , j++)
{
SetMFType(result->value,j,SYMBOL);
SetMFValue(result->value,j,GetDefclassNamePointer((void *) plinks->classArray[i]));
}
}
/**************************************************************************
NAME : EnvClassSubclasses
DESCRIPTION : Groups the names of subclasses for a class into a
multifield value for dynamic perusal
INPUTS : 1) Generic pointer to class
2) Data object buffer to hold the sublclasses of the class
3) Include (1) or exclude (0) indirect subclasses
RETURNS : Nothing useful
SIDE EFFECTS : Creates a multifield storing the names
the subclasses of the class
NOTES : None
**************************************************************************/
globle void EnvClassSubclasses(
void *theEnv,
void *clsptr,
DATA_OBJECT *result,
int inhp)
{
register unsigned i;
register int id;
if ((id = GetTraversalID(theEnv)) == -1)
return;
i = CountSubclasses((DEFCLASS *) clsptr,inhp,id);
ReleaseTraversalID(theEnv);
result->type = MULTIFIELD;
result->begin = 0;
SetpDOEnd(result,i);
result->value = (void *) EnvCreateMultifield(theEnv,i);
if (i == 0)
return;
if ((id = GetTraversalID(theEnv)) == -1)
return;
StoreSubclasses(result->value,1,(DEFCLASS *) clsptr,inhp,id,TRUE);
ReleaseTraversalID(theEnv);
}
/**************************************************************************
NAME : ClassSubclassAddresses
DESCRIPTION : Groups the class addresses of subclasses for a class into a
multifield value for dynamic perusal
INPUTS : 1) Generic pointer to class
2) Data object buffer to hold the sublclasses of the class
3) Include (1) or exclude (0) indirect subclasses
RETURNS : Nothing useful
SIDE EFFECTS : Creates a multifield storing the subclass
addresss of the class
NOTES : None
**************************************************************************/
globle void ClassSubclassAddresses(
void *theEnv,
void *clsptr,
DATA_OBJECT *result,
int inhp)
{
register unsigned i;
register int id;
if ((id = GetTraversalID(theEnv)) == -1)
return;
i = CountSubclasses((DEFCLASS *) clsptr,inhp,id);
ReleaseTraversalID(theEnv);
result->type = MULTIFIELD;
result->begin = 0;
SetpDOEnd(result,i);
result->value = (void *) EnvCreateMultifield(theEnv,i);
if (i == 0)
return;
if ((id = GetTraversalID(theEnv)) == -1)
return;
StoreSubclasses(result->value,1,(DEFCLASS *) clsptr,inhp,id,FALSE);
ReleaseTraversalID(theEnv);
}
/**************************************************************************
NAME : Slot... Slot information access functions
DESCRIPTION : Groups the sources/facets/types/allowed-values/range or
cardinality of a slot for a class into a multifield
value for dynamic perusal
INPUTS : 1) Generic pointer to class
2) Name of the slot
3) Data object buffer to hold the attributes of the class
RETURNS : Nothing useful
SIDE EFFECTS : Creates a multifield storing the attributes for the slot
of the class
NOTES : None
**************************************************************************/
globle void EnvSlotFacets(
void *theEnv,
void *clsptr,
char *sname,
DATA_OBJECT *result)
{
register int i;
register SLOT_DESC *sp;
if ((sp = SlotInfoSlot(theEnv,result,(DEFCLASS *) clsptr,sname,"slot-facets")) == NULL)
return;
#if DEFRULE_CONSTRUCT
result->end = 9;
result->value = (void *) EnvCreateMultifield(theEnv,10L);
for (i = 1 ; i <= 10 ; i++)
SetMFType(result->value,i,SYMBOL);
#else
result->end = 8;
result->value = (void *) EnvCreateMultifield(theEnv,9L);
for (i = 1 ; i <= 9 ; i++)
SetMFType(result->value,i,SYMBOL);
#endif
SetMFValue(result->value,1,EnvAddSymbol(theEnv,(char *) (sp->multiple ? "MLT" : "SGL")));
if (sp->noDefault)
SetMFValue(result->value,2,EnvAddSymbol(theEnv,"NIL"));
else
SetMFValue(result->value,2,EnvAddSymbol(theEnv,(char *) (sp->dynamicDefault ? "DYN" : "STC")));
SetMFValue(result->value,3,EnvAddSymbol(theEnv,(char *) (sp->noInherit ? "NIL" : "INH")));
if (sp->initializeOnly)
SetMFValue(result->value,4,EnvAddSymbol(theEnv,"INT"));
else if (sp->noWrite)
SetMFValue(result->value,4,EnvAddSymbol(theEnv,"R"));
else
SetMFValue(result->value,4,EnvAddSymbol(theEnv,"RW"));
SetMFValue(result->value,5,EnvAddSymbol(theEnv,(char *) (sp->shared ? "SHR" : "LCL")));
#if DEFRULE_CONSTRUCT
SetMFValue(result->value,6,EnvAddSymbol(theEnv,(char *) (sp->reactive ? "RCT" : "NIL")));
SetMFValue(result->value,7,EnvAddSymbol(theEnv,(char *) (sp->composite ? "CMP" : "EXC")));
SetMFValue(result->value,8,EnvAddSymbol(theEnv,(char *) (sp->publicVisibility ? "PUB" : "PRV")));
SetMFValue(result->value,9,EnvAddSymbol(theEnv,GetCreateAccessorString((void *) sp)));
SetMFValue(result->value,10,sp->noWrite ? EnvAddSymbol(theEnv,"NIL") : (void *) sp->overrideMessage);
#else
SetMFValue(result->value,6,EnvAddSymbol(theEnv,(char *) (sp->composite ? "CMP" : "EXC")));
SetMFValue(result->value,7,EnvAddSymbol(theEnv,(char *) (sp->publicVisibility ? "PUB" : "PRV")));
SetMFValue(result->value,8,EnvAddSymbol(theEnv,GetCreateAccessorString((void *) sp)));
SetMFValue(result->value,9,sp->noWrite ? EnvAddSymbol(theEnv,"NIL") : (void *) sp->overrideMessage);
#endif
}
globle void EnvSlotSources(
void *theEnv,
void *clsptr,
char *sname,
DATA_OBJECT *result)
{
register unsigned i;
register int classi;
register SLOT_DESC *sp,*csp;
CLASS_LINK *ctop,*ctmp;
DEFCLASS *cls;
if ((sp = SlotInfoSlot(theEnv,result,(DEFCLASS *) clsptr,sname,"slot-sources")) == NULL)
return;
i = 1;
ctop = get_struct(theEnv,classLink);
ctop->cls = sp->cls;
ctop->nxt = NULL;
if (sp->composite)
{
for (classi = 1 ; classi < sp->cls->allSuperclasses.classCount ; classi++)
{
cls = sp->cls->allSuperclasses.classArray[classi];
csp = FindClassSlot(cls,sp->slotName->name);
if ((csp != NULL) ? (csp->noInherit == 0) : FALSE)
{
ctmp = get_struct(theEnv,classLink);
ctmp->cls = cls;
ctmp->nxt = ctop;
ctop = ctmp;
i++;
if (csp->composite == 0)
break;
}
}
}
SetpDOEnd(result,i);
result->value = (void *) EnvCreateMultifield(theEnv,i);
for (ctmp = ctop , i = 1 ; ctmp != NULL ; ctmp = ctmp->nxt , i++)
{
SetMFType(result->value,i,SYMBOL);
SetMFValue(result->value,i,GetDefclassNamePointer((void *) ctmp->cls));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -