⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classexm.c

📁 clips源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
   if (EnvRtnArgCount(theEnv) == 3)     {      if (EnvArgTypeCheck(theEnv,"slot-existp",3,SYMBOL,&dobj) == FALSE)        return(FALSE);      if (strcmp(DOToString(dobj),"inherit") != 0)        {         ExpectedTypeError1(theEnv,"slot-existp",3,"keyword \"inherit\"");         SetEvaluationError(theEnv,TRUE);         return(FALSE);        }      inheritFlag = TRUE;     }   return((sd->cls == cls) ? TRUE : inheritFlag);  }/***************************************************  NAME         : EnvSlotExistP  DESCRIPTION  : Determines if a slot exists  INPUTS       : 1) The class                 2) The slot name                 3) A flag indicating if the slot                    can be inherited or not  RETURNS      : TRUE if slot exists,                 FALSE otherwise  SIDE EFFECTS : None  NOTES        : None ***************************************************/globle intBool EnvSlotExistP(  void *theEnv,  void *theDefclass,  char *slotName,  intBool inheritFlag)  {   return((LookupSlot(theEnv,(DEFCLASS *) theDefclass,slotName,inheritFlag) != NULL)           ? TRUE : FALSE);  }/************************************************************************************  NAME         : MessageHandlerExistPCommand  DESCRIPTION  : Determines if a message-handler is present in a class  INPUTS       : None  RETURNS      : TRUE if the message header is present, FALSE otherwise  SIDE EFFECTS : None  NOTES        : H/L Syntax : (message-handler-existp <class> <hnd> [<type>]) ************************************************************************************/globle int MessageHandlerExistPCommand(  void *theEnv)  {   DEFCLASS *cls;   SYMBOL_HN *mname;   DATA_OBJECT temp;   unsigned mtype = MPRIMARY;      if (EnvArgTypeCheck(theEnv,"message-handler-existp",1,SYMBOL,&temp) == FALSE)     return(FALSE);   cls = LookupDefclassByMdlOrScope(theEnv,DOToString(temp));   if (cls == NULL)     {      ClassExistError(theEnv,"message-handler-existp",DOToString(temp));      return(FALSE);     }   if (EnvArgTypeCheck(theEnv,"message-handler-existp",2,SYMBOL,&temp) == FALSE)     return(FALSE);   mname = (SYMBOL_HN *) GetValue(temp);   if (EnvRtnArgCount(theEnv) == 3)     {      if (EnvArgTypeCheck(theEnv,"message-handler-existp",3,SYMBOL,&temp) == FALSE)        return(FALSE);      mtype = HandlerType(theEnv,"message-handler-existp",DOToString(temp));      if (mtype == MERROR)        {         SetEvaluationError(theEnv,TRUE);         return(FALSE);        }     }   if (FindHandlerByAddress(cls,mname,mtype) != NULL)     return(TRUE);   return(FALSE);  }/**********************************************************************  NAME         : SlotWritablePCommand  DESCRIPTION  : Determines if an existing slot can be written to  INPUTS       : None  RETURNS      : TRUE if the slot is writable, FALSE otherwise  SIDE EFFECTS : None  NOTES        : H/L Syntax : (slot-writablep <class> <slot>) **********************************************************************/globle intBool SlotWritablePCommand(  void *theEnv)  {   DEFCLASS *theDefclass;   SLOT_DESC *sd;      sd = CheckSlotExists(theEnv,"slot-writablep",&theDefclass,TRUE,TRUE);   if (sd == NULL)     return(FALSE);   return((sd->noWrite || sd->initializeOnly) ? FALSE : TRUE);  }/***************************************************  NAME         : EnvSlotWritableP  DESCRIPTION  : Determines if a slot is writable  INPUTS       : 1) The class                 2) The slot name  RETURNS      : TRUE if slot is writable,                 FALSE otherwise  SIDE EFFECTS : None  NOTES        : None ***************************************************/globle intBool EnvSlotWritableP(  void *theEnv,  void *theDefclass,  char *slotName)  {   SLOT_DESC *sd;   if ((sd = LookupSlot(theEnv,(DEFCLASS *) theDefclass,slotName,TRUE)) == NULL)     return(FALSE);   return((sd->noWrite || sd->initializeOnly) ? FALSE : TRUE);  }/**********************************************************************  NAME         : SlotInitablePCommand  DESCRIPTION  : Determines if an existing slot can be initialized                   via an init message-handler or slot-override  INPUTS       : None  RETURNS      : TRUE if the slot is writable, FALSE otherwise  SIDE EFFECTS : None  NOTES        : H/L Syntax : (slot-initablep <class> <slot>) **********************************************************************/globle intBool SlotInitablePCommand(  void *theEnv)  {   DEFCLASS *theDefclass;   SLOT_DESC *sd;      sd = CheckSlotExists(theEnv,"slot-initablep",&theDefclass,TRUE,TRUE);   if (sd == NULL)     return(FALSE);   return((sd->noWrite && (sd->initializeOnly == 0)) ? FALSE : TRUE);  }/***************************************************  NAME         : EnvSlotInitableP  DESCRIPTION  : Determines if a slot is initable  INPUTS       : 1) The class                 2) The slot name  RETURNS      : TRUE if slot is initable,                 FALSE otherwise  SIDE EFFECTS : None  NOTES        : None ***************************************************/globle intBool EnvSlotInitableP(  void *theEnv,  void *theDefclass,  char *slotName)  {   SLOT_DESC *sd;   if ((sd = LookupSlot(theEnv,(DEFCLASS *) theDefclass,slotName,TRUE)) == NULL)     return(FALSE);   return((sd->noWrite && (sd->initializeOnly == 0)) ? FALSE : TRUE);  }/**********************************************************************  NAME         : SlotPublicPCommand  DESCRIPTION  : Determines if an existing slot is publicly visible                   for direct reference by subclasses  INPUTS       : None  RETURNS      : TRUE if the slot is public, FALSE otherwise  SIDE EFFECTS : None  NOTES        : H/L Syntax : (slot-publicp <class> <slot>) **********************************************************************/globle intBool SlotPublicPCommand(  void *theEnv)  {   DEFCLASS *theDefclass;   SLOT_DESC *sd;      sd = CheckSlotExists(theEnv,"slot-publicp",&theDefclass,TRUE,FALSE);   if (sd == NULL)     return(FALSE);   return(sd->publicVisibility ? TRUE : FALSE);  }/***************************************************  NAME         : EnvSlotPublicP  DESCRIPTION  : Determines if a slot is public  INPUTS       : 1) The class                 2) The slot name  RETURNS      : TRUE if slot is public,                 FALSE otherwise  SIDE EFFECTS : None  NOTES        : None ***************************************************/globle intBool EnvSlotPublicP(  void *theEnv,  void *theDefclass,  char *slotName)  {   SLOT_DESC *sd;   if ((sd = LookupSlot(theEnv,(DEFCLASS *) theDefclass,slotName,FALSE)) == NULL)     return(FALSE);   return(sd->publicVisibility ? TRUE : FALSE);  }/**********************************************************************  NAME         : SlotDirectAccessPCommand  DESCRIPTION  : Determines if an existing slot can be directly                   referenced by the class - i.e., if the slot is                   private, is the slot defined in the class  INPUTS       : None  RETURNS      : TRUE if the slot is private,                    FALSE otherwise  SIDE EFFECTS : None  NOTES        : H/L Syntax : (slot-direct-accessp <class> <slot>) **********************************************************************/globle intBool SlotDirectAccessPCommand(  void *theEnv)  {   DEFCLASS *theDefclass;   SLOT_DESC *sd;      sd = CheckSlotExists(theEnv,"slot-direct-accessp",&theDefclass,TRUE,TRUE);   if (sd == NULL)     return(FALSE);   return((sd->publicVisibility || (sd->cls == theDefclass)) ? TRUE : FALSE);  }/***************************************************  NAME         : EnvSlotDirectAccessP  DESCRIPTION  : Determines if a slot is directly                 accessible from message-handlers                 on class  INPUTS       : 1) The class                 2) The slot name  RETURNS      : TRUE if slot is directly                 accessible, FALSE otherwise  SIDE EFFECTS : None  NOTES        : None ***************************************************/globle intBool EnvSlotDirectAccessP(  void *theEnv,  void *theDefclass,  char *slotName)  {   SLOT_DESC *sd;   if ((sd = LookupSlot(theEnv,(DEFCLASS *) theDefclass,slotName,TRUE)) == NULL)     return(FALSE);   return((sd->publicVisibility || (sd->cls == (DEFCLASS *) theDefclass)) ?           TRUE : FALSE);  }/**********************************************************************  NAME         : SlotDefaultValueCommand  DESCRIPTION  : Determines the default avlue for the specified slot                 of the specified class  INPUTS       : None  RETURNS      : Nothing useful  SIDE EFFECTS : None  NOTES        : H/L Syntax : (slot-default-value <class> <slot>) **********************************************************************/globle void SlotDefaultValueCommand(  void *theEnv,  DATA_OBJECT_PTR theValue)  {   DEFCLASS *theDefclass;   SLOT_DESC *sd;   SetpType(theValue,SYMBOL);   SetpValue(theValue,EnvFalseSymbol(theEnv));   sd = CheckSlotExists(theEnv,"slot-default-value",&theDefclass,TRUE,TRUE);   if (sd == NULL)     return;      if (sd->noDefault)     {      SetpType(theValue,SYMBOL);      SetpValue(theValue,EnvAddSymbol(theEnv,"?NONE"));      return;      }        if (sd->dynamicDefault)     EvaluateAndStoreInDataObject(theEnv,(int) sd->multiple,                                  (EXPRESSION *) sd->defaultValue,                                  theValue,TRUE);   else     GenCopyMemory(DATA_OBJECT,1,theValue,sd->defaultValue);  }/*********************************************************  NAME         : SlotDefaultValue  DESCRIPTION  : Determines the default value for                 the specified slot of the specified class  INPUTS       : 1) The class                 2) The slot name  RETURNS      : TRUE if slot default value is set,                 FALSE otherwise  SIDE EFFECTS : Slot default value evaluated - dynamic                 defaults will cause any side effects  NOTES        : None *********************************************************/globle intBool EnvSlotDefaultValue(  void *theEnv,  void *theDefclass,  char *slotName,  DATA_OBJECT_PTR theValue)  {   SLOT_DESC *sd;   SetpType(theValue,SYMBOL);   SetpValue(theValue,EnvFalseSymbol(theEnv));   if ((sd = LookupSlot(theEnv,(DEFCLASS *) theDefclass,slotName,TRUE)) == NULL)     return(FALSE);      if (sd->noDefault)     {      SetpType(theValue,SYMBOL);      SetpValue(theValue,EnvAddSymbol(theEnv,"?NONE"));      return(TRUE);      }        if (sd->dynamicDefault)     return(EvaluateAndStoreInDataObject(theEnv,(int) sd->multiple,                                         (EXPRESSION *) sd->defaultValue,                                         theValue,TRUE));   GenCopyMemory(DATA_OBJECT,1,theValue,sd->defaultValue);   return(TRUE);  }/********************************************************  NAME         : ClassExistPCommand  DESCRIPTION  : Determines if a class exists  INPUTS       : None  RETURNS      : TRUE if class exists, FALSE otherwise  SIDE EFFECTS : None  NOTES        : H/L Syntax : (class-existp <arg>) ********************************************************/globle intBool ClassExistPCommand(  void *theEnv)  {   DATA_OBJECT temp;      if (EnvArgTypeCheck(theEnv,"class-existp",1,SYMBOL,&temp) == FALSE)     return(FALSE);   return((LookupDefclassByMdlOrScope(theEnv,DOToString(temp)) != NULL) ? TRUE : FALSE);  }/* =========================================   *****************************************          INTERNALLY VISIBLE FUNCTIONS   =========================================   ***************************************** *//******************************************************  NAME         : CheckTwoClasses  DESCRIPTION  : Checks for exactly two class arguments                    for a H/L function  INPUTS       : 1) The function name                 2) Caller's buffer for first class                 3) Caller's buffer for second class  RETURNS      : TRUE if both found, FALSE otherwise  SIDE EFFECTS : Caller's buffers set  NOTES        : Assumes exactly 2 arguments ******************************************************/static int CheckTwoClasses(  void *theEnv,  char *func,  DEFCLASS **c1,  DEFCLASS **c2)  {   DATA_OBJECT temp;   if (EnvArgTypeCheck(theEnv,func,1,SYMBOL,&temp) == FALSE)     return(FALSE);   *c1 = LookupDefclassByMdlOrScope(theEnv,DOToString(temp));   if (*c1 == NULL)     {      ClassExistError(theEnv,func,ValueToString(temp.value));      return(FALSE);     }   if (EnvArgTypeCheck(theEnv,func,2,SYMBOL,&temp) == FALSE)     return(FALSE);   *c2 = LookupDefclassByMdlOrScope(theEnv,DOToString(temp));   if (*c2 == NULL)     {      ClassExistError(theEnv,func,ValueToString(temp.value));      return(FALSE);     }   return(TRUE);  }/***************************************************  NAME         : CheckSlotExists  DESCRIPTION  : Checks first two arguments of                 a function for a valid class                 and (inherited) slot  INPUTS       : 1) The name of the function                 2) A buffer to hold the found class                 3) A flag indicating whether the                    non-existence of the slot should                    be an error                 4) A flag indicating if the slot                    can be inherited or not  RETURNS      : NULL if slot not found, slot                 descriptor otherwise  SIDE EFFECTS : Class buffer set if no errors,                 NULL on errors  NOTES        : None ***************************************************/static SLOT_DESC *CheckSlotExists(  void *theEnv,  char *func,  DEFCLASS **classBuffer,  intBool existsErrorFlag,  intBool inheritFlag)  {   SYMBOL_HN *ssym;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -