static DaoCdata* DaoCdata_MakeObject( DaoCdata *self, DaoValue *param, DaoProcess *proc ) { DaoValue *value; DaoRoutine *routine = DaoType_FindFunction( self->ctype, self->ctype->name ); if( DaoProcess_PushCallable( proc, routine, NULL, & param, 1 ) ) return NULL; proc->topFrame->active = proc->firstFrame; DaoProcess_SetActiveFrame( proc, proc->firstFrame ); /* return value in stackValues[0] */ if( DaoProcess_Execute( proc ) == 0 ) return NULL; value = proc->stackValues[0]; if( value && (value->type == DAO_CDATA || value->type == DAO_CSTRUCT) ) return & value->xCdata; return NULL; }
static DaoObject* DaoClass_MakeObject( DaoClass *self, DaoValue *param, DaoProcess *proc ) { DaoObject *object = DaoObject_New( self ); DaoProcess_CacheValue( proc, (DaoValue*) object ); if( DaoProcess_PushCallable( proc, self->classRoutines, (DaoValue*)object, & param, 1 ) ==0 ){ GC_ShiftRC( object, proc->topFrame->object ); proc->topFrame->object = object; proc->topFrame->returning = -1; if( DaoProcess_Execute( proc ) ) return object; } return NULL; }
int DaoObject_InvokeMethod( DaoObject *self, DaoObject *othis, DaoProcess *proc, DString *name, DaoValue *P[], int N, int ignore_return, int execute ) { DaoValue *V = NULL; DaoValue *O = (DaoValue*)self; int errcode = DaoObject_GetData( self, name, &V, othis ); if( errcode ) return errcode; if( V == NULL || V->type != DAO_ROUTINE ) return DAO_ERROR_TYPE; if( DaoProcess_PushCallable( proc, (DaoRoutine*) V, O, P, N ) ) goto InvalidParam; if( ignore_return ) DaoProcess_InterceptReturnValue( proc ); if( execute ) DaoProcess_Execute( proc ); return 0; InvalidParam: DaoProcess_ShowCallError( proc, (DaoRoutine*)V, O, P, N, DVM_CALL ); return DAO_ERROR_PARAM; }