DaoCstruct* DaoValue_CastCstruct( DaoValue *self, DaoType *type ) { if( self == NULL || type == NULL ) return (DaoCstruct*) self; if( self->type == DAO_OBJECT ){ self = (DaoValue*) DaoObject_CastCstruct( (DaoObject*) self, type ); if( self == NULL ) return NULL; } if( self->type != DAO_CSTRUCT && self->type != DAO_CDATA ) return NULL; if( DaoType_ChildOf( self->xCstruct.ctype, type ) ) return (DaoCstruct*) self; return NULL; }
DaoCstruct* DaoValue_CastCstructTC( DaoValue *self, DaoTypeCore *core ) { DaoType *type = NULL; if( self == NULL || core == NULL ) return (DaoCstruct*) self; if( self->type == DAO_OBJECT ){ type = DaoVmSpace_GetType( self->xObject.defClass->nameSpace->vmSpace, core ); self = (DaoValue*) DaoObject_CastCstruct( (DaoObject*) self, type ); if( self == NULL ) return NULL; } if( self->type != DAO_CSTRUCT && self->type != DAO_CDATA ) return NULL; type = DaoVmSpace_GetType( self->xCstruct.ctype->aux->xCtype.nameSpace->vmSpace, core ); if( DaoType_ChildOf( self->xCstruct.ctype, type ) ) return (DaoCstruct*) self; return NULL; }
DaoCstruct* DaoxResource_CallMethod( DaoxResource *self, const char *method, DaoType *ctype ) { DaoValue *res = NULL; DaoObject *obj = NULL; DaoRoutine *rout = Dao_Get_Object_Method( (DaoCstruct*) self, & obj, method ); DaoProcess *proc; if( rout == NULL || obj == NULL ) return NULL; proc = DaoVmSpace_AcquireProcess( dao_vmspace_graphics ); rout = DaoRoutine_Resolve( rout, (DaoValue*) obj, NULL, NULL, NULL, 0, 0 ); if( rout == NULL ) goto Finalize; DaoProcess_Call( proc, rout, (DaoValue*) obj, NULL, 0 ); res = DaoProcess_GetReturned( proc ); if( res == NULL || res->type != DAO_OBJECT ) return NULL; return DaoObject_CastCstruct( (DaoObject*)res, ctype ); Finalize: DaoVmSpace_ReleaseProcess( dao_vmspace_graphics, proc ); return NULL; }
DaoCdata* DaoObject_CastCdata( DaoObject *self, DaoType *type ) { DaoCstruct *p = DaoObject_CastCstruct( self, type ); if( p && p->type == DAO_CDATA ) return (DaoCdata*) p; return NULL; }