📄 msgpass.c
字号:
WatchHandler(theEnv,WTRACE,MessageHandlerData(theEnv)->CurrentCore,BEGIN_TRACE);#endif if (CheckHandlerArgCount(theEnv)) {#if PROFILING_FUNCTIONS StartProfile(theEnv,&profileFrame, &MessageHandlerData(theEnv)->CurrentCore->hnd->usrData, ProfileFunctionData(theEnv)->ProfileConstructs);#endif EvaluateProcActions(theEnv,MessageHandlerData(theEnv)->CurrentCore->hnd->cls->header.whichModule->theModule, MessageHandlerData(theEnv)->CurrentCore->hnd->actions, MessageHandlerData(theEnv)->CurrentCore->hnd->localVarCount, result,UnboundHandlerErr);#if PROFILING_FUNCTIONS EndProfile(theEnv,&profileFrame);#endif }#if DEBUGGING_FUNCTIONS if (MessageHandlerData(theEnv)->CurrentCore->hnd->trace) WatchHandler(theEnv,WTRACE,MessageHandlerData(theEnv)->CurrentCore,END_TRACE);#endif } else CallHandlers(theEnv,result); } else { MessageHandlerData(theEnv)->CurrentCore = MessageHandlerData(theEnv)->NextInCore; MessageHandlerData(theEnv)->NextInCore = MessageHandlerData(theEnv)->NextInCore->nxt;#if DEBUGGING_FUNCTIONS if (MessageHandlerData(theEnv)->CurrentCore->hnd->trace) WatchHandler(theEnv,WTRACE,MessageHandlerData(theEnv)->CurrentCore,BEGIN_TRACE);#endif if (CheckHandlerArgCount(theEnv)) {#if PROFILING_FUNCTIONS StartProfile(theEnv,&profileFrame, &MessageHandlerData(theEnv)->CurrentCore->hnd->usrData, ProfileFunctionData(theEnv)->ProfileConstructs);#endif EvaluateProcActions(theEnv,MessageHandlerData(theEnv)->CurrentCore->hnd->cls->header.whichModule->theModule, MessageHandlerData(theEnv)->CurrentCore->hnd->actions, MessageHandlerData(theEnv)->CurrentCore->hnd->localVarCount, result,UnboundHandlerErr);#if PROFILING_FUNCTIONS EndProfile(theEnv,&profileFrame);#endif }#if DEBUGGING_FUNCTIONS if (MessageHandlerData(theEnv)->CurrentCore->hnd->trace) WatchHandler(theEnv,WTRACE,MessageHandlerData(theEnv)->CurrentCore,END_TRACE);#endif } MessageHandlerData(theEnv)->NextInCore = oldNext; MessageHandlerData(theEnv)->CurrentCore = oldCurrent; if (overridep) PopProcParameters(theEnv); ProcedureFunctionData(theEnv)->ReturnFlag = FALSE; }/************************************************************************* NAME : FindApplicableOfName DESCRIPTION : Groups all handlers of all types of the specified class of the specified name into the applicable handler list INPUTS : 1) The class address 2-3) The tops and bottoms of the four handler type lists: around, before, primary and after 4) The message name symbol RETURNS : Nothing useful SIDE EFFECTS : Modifies the handler lists to include applicable handlers NOTES : None *************************************************************************/globle void FindApplicableOfName( void *theEnv, DEFCLASS *cls, HANDLER_LINK *tops[4], HANDLER_LINK *bots[4], SYMBOL_HN *mname) { register int i; register int e; HANDLER *hnd; unsigned *arr; HANDLER_LINK *tmp; i = FindHandlerNameGroup(cls,mname); if (i == -1) return; e = ((int) cls->handlerCount) - 1; hnd = cls->handlers; arr = cls->handlerOrderMap; for ( ; i <= e ; i++) { if (hnd[arr[i]].name != mname) break; tmp = get_struct(theEnv,messageHandlerLink); hnd[arr[i]].busy++; IncrementDefclassBusyCount(theEnv,(void *) hnd[arr[i]].cls); tmp->hnd = &hnd[arr[i]]; if (tops[tmp->hnd->type] == NULL) { tmp->nxt = NULL; tops[tmp->hnd->type] = bots[tmp->hnd->type] = tmp; } else if (tmp->hnd->type == MAFTER) { tmp->nxt = tops[tmp->hnd->type]; tops[tmp->hnd->type] = tmp; } else { bots[tmp->hnd->type]->nxt = tmp; bots[tmp->hnd->type] = tmp; tmp->nxt = NULL; } } }/************************************************************************* NAME : JoinHandlerLinks DESCRIPTION : Joins the queues of different handlers together INPUTS : 1-2) The tops and bottoms of the four handler type lists: around, before, primary and after 3) The message name symbol RETURNS : The top of the joined lists, NULL on errors SIDE EFFECTS : Links all the handler type lists together, or all the lists are destroyed if there are no primary handlers NOTES : None *************************************************************************/globle HANDLER_LINK *JoinHandlerLinks( void *theEnv, HANDLER_LINK *tops[4], HANDLER_LINK *bots[4], SYMBOL_HN *mname) { register int i; HANDLER_LINK *mlink; if (tops[MPRIMARY] == NULL) { PrintNoHandlerError(theEnv,ValueToString(mname)); for (i = MAROUND ; i <= MAFTER ; i++) DestroyHandlerLinks(theEnv,tops[i]); SetEvaluationError(theEnv,TRUE); return(NULL); } mlink = tops[MPRIMARY]; if (tops[MBEFORE] != NULL) { bots[MBEFORE]->nxt = mlink; mlink = tops[MBEFORE]; } if (tops[MAROUND] != NULL) { bots[MAROUND]->nxt = mlink; mlink = tops[MAROUND]; } bots[MPRIMARY]->nxt = tops[MAFTER]; return(mlink); }/*************************************************** NAME : PrintHandlerSlotGetFunction DESCRIPTION : Developer access function for printing direct slot references in message-handlers INPUTS : 1) The logical name of the output 2) The bitmap expression RETURNS : Nothing useful SIDE EFFECTS : Expression printed NOTES : None ***************************************************/#if IBM_TBC && (! DEVELOPER)#pragma argsused#endifgloble void PrintHandlerSlotGetFunction( void *theEnv, char *logicalName, void *theValue) {#if DEVELOPER HANDLER_SLOT_REFERENCE *theReference; DEFCLASS *theDefclass; SLOT_DESC *sd; theReference = (HANDLER_SLOT_REFERENCE *) ValueToBitMap(theValue); EnvPrintRouter(theEnv,logicalName,"?self:["); theDefclass = DefclassData(theEnv)->ClassIDMap[theReference->classID]; EnvPrintRouter(theEnv,logicalName,ValueToString(theDefclass->header.name)); EnvPrintRouter(theEnv,logicalName,"]"); sd = theDefclass->instanceTemplate[theDefclass->slotNameMap[theReference->slotID] - 1]; EnvPrintRouter(theEnv,logicalName,ValueToString(sd->slotName->name));#else#if MAC_MCW || IBM_MCW || MAC_XCD#pragma unused(theEnv)#pragma unused(logicalName)#pragma unused(theValue)#endif#endif }/*************************************************** NAME : HandlerSlotGetFunction DESCRIPTION : Access function for handling the statically-bound direct slot references in message-handlers INPUTS : 1) The bitmap expression 2) A data object buffer RETURNS : TRUE if OK, FALSE on errors SIDE EFFECTS : Data object buffer gets value of slot. On errors, buffer gets symbol FALSE, EvaluationError is set and error messages are printed NOTES : It is possible for a handler (attached to a superclass of the currently active instance) containing these static references to be called for an instance which does not contain the slots (e.g., an instance of a subclass where the original slot was no-inherit or the subclass overrode the original slot) ***************************************************/globle intBool HandlerSlotGetFunction( void *theEnv, void *theValue, DATA_OBJECT *theResult) { HANDLER_SLOT_REFERENCE *theReference; DEFCLASS *theDefclass; INSTANCE_TYPE *theInstance; INSTANCE_SLOT *sp; unsigned instanceSlotIndex; theReference = (HANDLER_SLOT_REFERENCE *) ValueToBitMap(theValue); theInstance = (INSTANCE_TYPE *) ProceduralPrimitiveData(theEnv)->ProcParamArray[0].value; theDefclass = DefclassData(theEnv)->ClassIDMap[theReference->classID]; if (theInstance->garbage) { StaleInstanceAddress(theEnv,"for slot get",0); theResult->type = SYMBOL; theResult->value = EnvFalseSymbol(theEnv); SetEvaluationError(theEnv,TRUE); return(FALSE); } if (theInstance->cls == theDefclass) { instanceSlotIndex = theInstance->cls->slotNameMap[theReference->slotID]; sp = theInstance->slotAddresses[instanceSlotIndex - 1]; } else { if (theReference->slotID > theInstance->cls->maxSlotNameID) goto HandlerGetError; instanceSlotIndex = theInstance->cls->slotNameMap[theReference->slotID]; if (instanceSlotIndex == 0) goto HandlerGetError; instanceSlotIndex--; sp = theInstance->slotAddresses[instanceSlotIndex]; if (sp->desc->cls != theDefclass) goto HandlerGetError; } theResult->type = (unsigned short) sp->type; theResult->value = sp->value; if (sp->type == MULTIFIELD) { theResult->begin = 0; SetpDOEnd(theResult,GetInstanceSlotLength(sp)); } return(TRUE);HandlerGetError: EarlySlotBindError(theEnv,theInstance,theDefclass,theReference->slotID); theResult->type = SYMBOL; theResult->value = EnvFalseSymbol(theEnv); SetEvaluationError(theEnv,TRUE); return(FALSE); }/*************************************************** NAME : PrintHandlerSlotPutFunction DESCRIPTION : Developer access function for printing direct slot bindings in message-handlers INPUTS : 1) The logical name of the output 2) The bitmap expression RETURNS : Nothing useful SIDE EFFECTS : Expression printed NOTES : None ***************************************************/#if IBM_TBC && (! DEVELOPER)#pragma argsused#endifgloble void PrintHandlerSlotPutFunction( void *theEnv, char *logicalName, void *theValue) {#if DEVELOPER HANDLER_SLOT_REFERENCE *theReference; DEFCLASS *theDefclass; SLOT_DESC *sd; theReference = (HANDLER_SLOT_REFERENCE *) ValueToBitMap(theValue); EnvPrintRouter(theEnv,logicalName,"(bind ?self:["); theDefclass = DefclassData(theEnv)->ClassIDMap[theReference->classID]; EnvPrintRouter(theEnv,logicalName,ValueToString(theDefclass->header.name)); EnvPrintRouter(theEnv,logicalName,"]"); sd = theDefclass->instanceTemplate[theDefclass->slotNameMap[theReference->slotID] - 1]; EnvPrintRouter(theEnv,logicalName,ValueToString(sd->slotName->name)); if (GetFirstArgument() != NULL) { EnvPrintRouter(theEnv,logicalName," "); PrintExpression(theEnv,logicalName,GetFirstArgument()); } EnvPrintRouter(theEnv,logicalName,")");#else#if MAC_MCW || IBM_MCW || MAC_XCD#pragma unused(theEnv)#pragma unused(logicalName)#pragma unused(theValue)#endif#endif }/*************************************************** NAME : HandlerSlotPutFunction
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -