static void DaoObject_Print( DaoValue *self0, DaoProcess *proc, DaoStream *stream, DMap *cycData ) { int ec; char buf[50]; DaoObject *self = & self0->xObject; sprintf( buf, "[%p]", self ); if( self0 == self->defClass->objType->value ){ DaoStream_WriteString( stream, self->defClass->className ); DaoStream_WriteChars( stream, "[null]" ); return; } if( cycData != NULL && DMap_Find( cycData, self ) != NULL ){ DaoStream_WriteString( stream, self->defClass->className ); DaoStream_WriteChars( stream, buf ); return; } if( cycData ) MAP_Insert( cycData, self, self ); DString_SetChars( proc->mbstring, "serialize" ); DaoValue_Clear( & proc->stackValues[0] ); ec = DaoObject_InvokeMethod( self, proc->activeObject, proc, proc->mbstring, NULL,0,1,1 ); if( ec && ec != DAO_ERROR_FIELD_NOTEXIST ){ DaoProcess_RaiseException( proc, daoExceptionNames[ec], proc->mbstring->chars, NULL ); }else if( ec == DAO_ERROR_FIELD_NOTEXIST || proc->stackValues[0] == NULL ){ DaoStream_WriteString( stream, self->defClass->className ); DaoStream_WriteChars( stream, buf ); }else{ DaoValue_Print( proc->stackValues[0], proc, stream, cycData ); } }
static void DaoObject_GetItem( DaoValue *self0, DaoProcess *proc, DaoValue *ids[], int N ) { DaoObject *self = & self0->xObject; int rc = 0; DString_SetChars( proc->string, "[]" ); rc = DaoObject_InvokeMethod( self, proc->activeObject, proc, proc->string, ids, N,0,0 ); if( rc ) DaoProcess_RaiseException( proc, daoExceptionNames[rc], proc->string->chars, NULL ); }
static void DaoObject_SetItem( DaoValue *self0, DaoProcess *proc, DaoValue *ids[], int N, DaoValue *value ) { DaoObject *self = & self0->xObject; DaoValue *ps[ DAO_MAX_PARAM ]; int rc; memcpy( ps+1, ids, N*sizeof(DaoValue*) ); ps[0] = value; DString_SetChars( proc->string, "[]=" ); rc = DaoObject_InvokeMethod( self, proc->activeObject, proc, proc->string, ps, N+1,1,0 ); if( rc ) DaoProcess_RaiseException( proc, daoExceptionNames[rc], proc->string->chars, NULL ); }
static void DaoObject_Core_GetField( DaoValue *self0, DaoProcess *proc, DString *name ) { DaoObject *self = & self0->xObject; DaoValue *value = NULL; int rc = DaoObject_GetData( self, name, & value, proc->activeObject ); if( rc ){ DString *field = proc->string; DString_SetChars( field, "." ); DString_Append( field, name ); rc = DaoObject_InvokeMethod( self, proc->activeObject, proc, field, NULL,0,0,0 ); if( rc == DAO_ERROR_FIELD_NOTEXIST ){ DaoString str = {DAO_STRING,0,0,0,1,NULL}; DaoValue *pars = (DaoValue*) & str; str.value = name; DString_SetChars( field, "." ); rc = DaoObject_InvokeMethod( self, proc->activeObject, proc, field, &pars,1,0,0 ); } }else{ DaoProcess_PutValue( proc, value ); } if( rc ) DaoProcess_RaiseException( proc, daoExceptionNames[rc], name->chars, NULL ); }
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 ); }