/************************************************************ NAME : WildDeleteHandler DESCRIPTION : Deletes a handler from a class INPUTS : 1) Class address (Can be NULL) 2) Message Handler Name (Can be NULL) 3) Type name ("primary", etc.) RETURNS : 1 if successful, 0 otherwise SIDE EFFECTS : Handler deleted if possible NOTES : None ************************************************************/ static int WildDeleteHandler( DEFCLASS *cls, SYMBOL_HN *msym, char *tname) { int mtype; if (msym == NULL) msym = (SYMBOL_HN *) AddSymbol("*"); if (tname != NULL) { mtype = HandlerType("undefmessage-handler",tname); if (mtype == MERROR) return(0); } else mtype = -1; if (cls == NULL) { int success = 1; for (cls = (DEFCLASS *) GetNextDefclass(NULL) ; cls != NULL ; cls = (DEFCLASS *) GetNextDefclass((void *) cls)) if (DeleteHandler(cls,msym,mtype,FALSE) == 0) success = 0; return(success); } return(DeleteHandler(cls,msym,mtype,TRUE)); }
/******************************************************************* NAME : ListDefmessageHandlers DESCRIPTION : Lists message-handlers for a class INPUTS : 1) The logical name of the output 2) Class name (NULL to display all handlers) 3) A flag indicating whether to list inherited handlers or not RETURNS : Nothing useful SIDE EFFECTS : None NOTES : None *******************************************************************/ globle void ListDefmessageHandlers( char *log, void *vptr, int inhp) { DEFCLASS *cls; long cnt; PACKED_CLASS_LINKS plinks; if (vptr != NULL) { cls = (DEFCLASS *) vptr; if (inhp) cnt = DisplayHandlersInLinks(log,&cls->allSuperclasses,0); else { plinks.classCount = 1; plinks.classArray = &cls; cnt = DisplayHandlersInLinks(log,&plinks,0); } } else { plinks.classCount = 1; cnt = 0L; for (cls = (DEFCLASS *) GetNextDefclass(NULL) ; cls != NULL ; cls = (DEFCLASS *) GetNextDefclass((void *) cls)) { plinks.classArray = &cls; cnt += DisplayHandlersInLinks(log,&plinks,0); } } PrintTally(log,cnt,"message-handler","message-handlers"); }
static void OutputConstructsCodeInfo( Environment *theEnv) { #if (! DEFFUNCTION_CONSTRUCT) && (! DEFGENERIC_CONSTRUCT) && (! OBJECT_SYSTEM) && (! DEFRULE_CONSTRUCT) #pragma unused(theEnv) #endif #if DEFFUNCTION_CONSTRUCT Deffunction *theDeffunction; #endif #if DEFRULE_CONSTRUCT Defrule *theDefrule; #endif #if DEFGENERIC_CONSTRUCT Defgeneric *theDefgeneric; Defmethod *theMethod; unsigned short methodIndex; StringBuilder *theSB; #endif #if OBJECT_SYSTEM Defclass *theDefclass; DefmessageHandler *theHandler; unsigned handlerIndex; #endif #if DEFGENERIC_CONSTRUCT || OBJECT_SYSTEM const char *prefix, *prefixBefore, *prefixAfter; #endif const char *banner; banner = "\n*** Deffunctions ***\n\n"; #if DEFFUNCTION_CONSTRUCT for (theDeffunction = GetNextDeffunction(theEnv,NULL); theDeffunction != NULL; theDeffunction = GetNextDeffunction(theEnv,theDeffunction)) { OutputProfileInfo(theEnv,DeffunctionName(theDeffunction), (struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDeffunction->header.usrData), NULL,NULL,NULL,&banner); } #endif banner = "\n*** Defgenerics ***\n"; #if DEFGENERIC_CONSTRUCT theSB = CreateStringBuilder(theEnv,512); for (theDefgeneric = GetNextDefgeneric(theEnv,NULL); theDefgeneric != NULL; theDefgeneric = GetNextDefgeneric(theEnv,theDefgeneric)) { prefixBefore = "\n"; prefix = DefgenericName(theDefgeneric); prefixAfter = "\n"; for (methodIndex = GetNextDefmethod(theDefgeneric,0); methodIndex != 0; methodIndex = GetNextDefmethod(theDefgeneric,methodIndex)) { theMethod = GetDefmethodPointer(theDefgeneric,methodIndex); DefmethodDescription(theDefgeneric,methodIndex,theSB); if (OutputProfileInfo(theEnv,theSB->contents, (struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theMethod->header.usrData), prefixBefore,prefix,prefixAfter,&banner)) { prefixBefore = NULL; prefix = NULL; prefixAfter = NULL; } } } SBDispose(theSB); #endif banner = "\n*** Defclasses ***\n"; #if OBJECT_SYSTEM for (theDefclass = GetNextDefclass(theEnv,NULL); theDefclass != NULL; theDefclass = GetNextDefclass(theEnv,theDefclass)) { prefixAfter = "\n"; prefix = DefclassName(theDefclass); prefixBefore = "\n"; for (handlerIndex = GetNextDefmessageHandler(theDefclass,0); handlerIndex != 0; handlerIndex = GetNextDefmessageHandler(theDefclass,handlerIndex)) { theHandler = GetDefmessageHandlerPointer(theDefclass,handlerIndex); if (OutputProfileInfo(theEnv,DefmessageHandlerName(theDefclass,handlerIndex), (struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID, theHandler->header.usrData), prefixBefore,prefix,prefixAfter,&banner)) { prefixBefore = NULL; prefix = NULL; prefixAfter = NULL; } } } #endif banner = "\n*** Defrules ***\n\n"; #if DEFRULE_CONSTRUCT for (theDefrule = GetNextDefrule(theEnv,NULL); theDefrule != NULL; theDefrule = GetNextDefrule(theEnv,theDefrule)) { OutputProfileInfo(theEnv,DefruleName(theDefrule), (struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDefrule->header.usrData), NULL,NULL,NULL,&banner); } #endif }
void ProfileResetCommand( Environment *theEnv, UDFContext *context, UDFValue *returnValue) { struct functionDefinition *theFunction; int i; #if DEFFUNCTION_CONSTRUCT Deffunction *theDeffunction; #endif #if DEFRULE_CONSTRUCT Defrule *theDefrule; #endif #if DEFGENERIC_CONSTRUCT Defgeneric *theDefgeneric; unsigned short methodIndex; Defmethod *theMethod; #endif #if OBJECT_SYSTEM Defclass *theDefclass; DefmessageHandler *theHandler; unsigned handlerIndex; #endif ProfileFunctionData(theEnv)->ProfileStartTime = 0.0; ProfileFunctionData(theEnv)->ProfileEndTime = 0.0; ProfileFunctionData(theEnv)->ProfileTotalTime = 0.0; ProfileFunctionData(theEnv)->LastProfileInfo = NO_PROFILE; for (theFunction = GetFunctionList(theEnv); theFunction != NULL; theFunction = theFunction->next) { ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theFunction->usrData)); } for (i = 0; i < MAXIMUM_PRIMITIVES; i++) { if (EvaluationData(theEnv)->PrimitivesArray[i] != NULL) { ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,EvaluationData(theEnv)->PrimitivesArray[i]->usrData)); } } #if DEFFUNCTION_CONSTRUCT for (theDeffunction = GetNextDeffunction(theEnv,NULL); theDeffunction != NULL; theDeffunction = GetNextDeffunction(theEnv,theDeffunction)) { ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDeffunction->header.usrData)); } #endif #if DEFRULE_CONSTRUCT for (theDefrule = GetNextDefrule(theEnv,NULL); theDefrule != NULL; theDefrule = GetNextDefrule(theEnv,theDefrule)) { ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDefrule->header.usrData)); } #endif #if DEFGENERIC_CONSTRUCT for (theDefgeneric = GetNextDefgeneric(theEnv,NULL); theDefgeneric != NULL; theDefgeneric = GetNextDefgeneric(theEnv,theDefgeneric)) { ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDefgeneric->header.usrData)); for (methodIndex = GetNextDefmethod(theDefgeneric,0); methodIndex != 0; methodIndex = GetNextDefmethod(theDefgeneric,methodIndex)) { theMethod = GetDefmethodPointer(theDefgeneric,methodIndex); ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theMethod->header.usrData)); } } #endif #if OBJECT_SYSTEM for (theDefclass = GetNextDefclass(theEnv,NULL); theDefclass != NULL; theDefclass = GetNextDefclass(theEnv,theDefclass)) { ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theDefclass->header.usrData)); for (handlerIndex = GetNextDefmessageHandler(theDefclass,0); handlerIndex != 0; handlerIndex = GetNextDefmessageHandler(theDefclass,handlerIndex)) { theHandler = GetDefmessageHandlerPointer(theDefclass,handlerIndex); ResetProfileInfo((struct constructProfileInfo *) TestUserData(ProfileFunctionData(theEnv)->ProfileDataID,theHandler->header.usrData)); } } #endif }
/******************************************************* NAME : DefmessageHandlerWatchSupport DESCRIPTION : Sets or displays handlers specified INPUTS : 1) The calling function name 2) The logical output name for displays (can be NULL) 4) The new set state (can be -1) 5) The print function (can be NULL) 6) The trace function (can be NULL) 7) The handlers expression list RETURNS : TRUE if all OK, FALSE otherwise SIDE EFFECTS : Handler trace flags set or displayed NOTES : None *******************************************************/ static BOOLEAN DefmessageHandlerWatchSupport( char *funcName, char *log, int newState, void (*printFunc)(char *,void *,unsigned), void (*traceFunc)(int,void *,unsigned), EXPRESSION *argExprs) { struct defmodule *theModule; void *theClass; char *theHandlerStr; int theType; int argIndex = 2; DATA_OBJECT tmpData; /* =============================== If no handlers are specified, show the trace for all handlers in all handlers =============================== */ if (argExprs == NULL) { SaveCurrentModule(); theModule = (struct defmodule *) GetNextDefmodule(NULL); while (theModule != NULL) { SetCurrentModule((void *) theModule); if (traceFunc == NULL) { PrintRouter(log,GetDefmoduleName((void *) theModule)); PrintRouter(log,":\n"); } theClass = GetNextDefclass(NULL); while (theClass != NULL) { if (WatchClassHandlers(theClass,NULL,-1,log,newState, TRUE,printFunc,traceFunc) == FALSE) return(FALSE); theClass = GetNextDefclass(theClass); } theModule = (struct defmodule *) GetNextDefmodule((void *) theModule); } RestoreCurrentModule(); return(TRUE); } /* ================================================ Set or show the traces for the specified handler ================================================ */ while (argExprs != NULL) { if (EvaluateExpression(argExprs,&tmpData)) return(FALSE); if (tmpData.type != SYMBOL) { ExpectedTypeError1(funcName,argIndex,"class name"); return(FALSE); } theClass = (void *) LookupDefclassByMdlOrScope(DOToString(tmpData)); if (theClass == NULL) { ExpectedTypeError1(funcName,argIndex,"class name"); return(FALSE); } if (GetNextArgument(argExprs) != NULL) { argExprs = GetNextArgument(argExprs); argIndex++; if (EvaluateExpression(argExprs,&tmpData)) return(FALSE); if (tmpData.type != SYMBOL) { ExpectedTypeError1(funcName,argIndex,"handler name"); return(FALSE); } theHandlerStr = DOToString(tmpData); if (GetNextArgument(argExprs) != NULL) { argExprs = GetNextArgument(argExprs); argIndex++; if (EvaluateExpression(argExprs,&tmpData)) return(FALSE); if (tmpData.type != SYMBOL) { ExpectedTypeError1(funcName,argIndex,"handler type"); return(FALSE); } if ((theType = HandlerType(funcName,DOToString(tmpData))) == MERROR) return(FALSE); } else theType = -1; } else { theHandlerStr = NULL; theType = -1; } if (WatchClassHandlers(theClass,theHandlerStr,theType,log, newState,FALSE,printFunc,traceFunc) == FALSE) { ExpectedTypeError1(funcName,argIndex,"handler"); return(FALSE); } argIndex++; argExprs = GetNextArgument(argExprs); } return(TRUE); }
/************************************************************************ NAME : GetDefmessageHandlerList 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 GetDefmessageHandlerList( void *clsptr, DATA_OBJECT *result, int inhp) { DEFCLASS *cls,*svcls,*svnxt,*supcls; register int j,classi,classiLimit; long i,len,sublen; if (clsptr == NULL) { inhp = 0; cls = (DEFCLASS *) GetNextDefclass(NULL); svnxt = (DEFCLASS *) GetNextDefclass((void *) cls); } else { cls = (DEFCLASS *) clsptr; svnxt = (DEFCLASS *) GetNextDefclass((void *) cls); SetNextDefclass((void *) cls,NULL); } for (svcls = cls , i = 0 ; cls != NULL ; cls = (DEFCLASS *) GetNextDefclass((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; result->begin = 0; result->end = len - 1; result->value = (void *) CreateMultifield(len); for (cls = svcls , sublen = 0 ; cls != NULL ; cls = (DEFCLASS *) GetNextDefclass((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++,AddSymbol(hndquals[supcls->handlers[j].type])); } sublen += supcls->handlerCount * 3; } } if (svcls != NULL) SetNextDefclass((void *) svcls,(void *) svnxt); }