static int DaoObject_DoSetField( DaoValue *self, DaoString *name, DaoValue *value, DaoProcess *proc ) { DaoObject *object = (DaoObject*) self; DaoObject *host = proc->activeObject; DaoClass *hostClass = host ? host->defClass : NULL; int ec = DaoObject_SetData( object, name->value, value, host ); if( ec != DAO_OK ){ DString *field = proc->string; DaoRoutine *rout; DString_SetChars( field, "." ); DString_Append( field, name->value ); DString_AppendChars( field, "=" ); rout = DaoClass_FindMethod( object->defClass, field->chars, hostClass ); if( rout != NULL ){ ec = DaoProcess_PushCall( proc, rout, self, & value, 1 ); }else{ DaoValue *args[2]; args[0] = (DaoValue*) name; args[1] = value; rout = DaoClass_FindMethod( object->defClass, ".=", hostClass ); if( rout == NULL ) return DAO_ERROR_FIELD_ABSENT; ec = DaoProcess_PushCall( proc, rout, self, args, 2 ); } if( rout == NULL ) return DAO_ERROR_FIELD_ABSENT; } if( ec ) DaoProcess_RaiseError( proc, daoExceptionNames[ec], name->value->chars ); return ec; }
static void DaoObject_Core_SetField( DaoValue *self0, DaoProcess *proc, DString *name, DaoValue *value ) { DaoObject *self = & self0->xObject; int ec = DaoObject_SetData( self, name, value, proc->activeObject ); int ec2 = ec; if( ec != DAO_ERROR ){ DString *mbs = proc->string; DString_SetChars( mbs, "." ); DString_Append( mbs, name ); DString_AppendChars( mbs, "=" ); ec = DaoObject_InvokeMethod( self, proc->activeObject, proc, mbs, & value, 1,1,0 ); if( ec == DAO_ERROR_FIELD_NOTEXIST ){ DaoString str = {DAO_STRING,0,0,0,1,NULL}; DaoValue *pars[2]; pars[0] = (DaoValue*) & str; pars[1] = value; str.value = name; DString_SetChars( mbs, ".=" ); ec = DaoObject_InvokeMethod( self, proc->activeObject, proc, mbs, pars,2,1,0 ); } if( ec == DAO_ERROR_FIELD_NOTEXIST ) ec = ec2; } if( ec ) DaoProcess_RaiseException( proc, daoExceptionNames[ec], name->chars, NULL ); }