static int DaoCdata_Serialize( DaoCdata *self, DString *serial, DaoNamespace *ns, DaoProcess *proc, DString *buf, DMap *omap ) { DaoType *type; DaoRoutine *meth = DaoType_FindFunctionMBS( self->ctype, "serialize" ); if( meth == NULL ) return 0; if( DaoProcess_Call( proc, meth, (DaoValue*)self, NULL, 0 ) ) return 0; type = DaoNamespace_GetType( ns, proc->stackValues[0] ); DaoValue_Serialize2( proc->stackValues[0], serial, ns, proc, type, buf, omap ); return 1; }
static void STD_Callable( DaoProcess *proc, DaoValue *p[], int N ) { DaoValue *p0 = p[0]; daoint *res = DaoProcess_PutInteger( proc, 0 ); if( p0 == NULL || p0->type == 0 ){ *res = 0; return; } switch( p0->type ){ case DAO_CLASS : case DAO_ROUTINE : *res = 1; break; case DAO_OBJECT : { DaoObject *object = & p0->xObject; DString *mbs = DString_New(1); DString_SetMBS( mbs, "()" ); DaoObject_GetData( object, mbs, & p0, proc->activeObject ); DString_Delete( mbs ); if( p0 && p0->type == DAO_ROUTINE ) *res = 1; break; } case DAO_CTYPE : { DaoType *type = p0->xCdata.ctype; *res = DaoType_FindFunctionMBS( type, type->typer->name ) != NULL; break; } case DAO_CDATA : case DAO_CSTRUCT : { *res = DaoType_FindFunctionMBS( p0->xCdata.ctype, "()" ) != NULL; break; } default : break; } }