Changeset 171
- Timestamp:
- 03/13/14 01:00:33 (11 years ago)
- Location:
- cpp/frams
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/_demos/serial_test.cpp
r121 r171 44 44 return; 45 45 } 46 VectorObject *vec=VectorObject::fromObject(v->getObject() );46 VectorObject *vec=VectorObject::fromObject(v->getObject(),false); 47 47 if (vec) 48 48 { … … 52 52 return; 53 53 } 54 DictionaryObject *dict=DictionaryObject::fromObject(v->getObject() );54 DictionaryObject *dict=DictionaryObject::fromObject(v->getObject(),false); 55 55 if (dict) 56 56 { -
cpp/frams/util/extvalue.cpp
r144 r171 56 56 if (!(subtype&1)) return false; 57 57 if (dbobject->refcount==1) return false; 58 VectorObject* v=VectorObject::fromObject(*this );58 VectorObject* v=VectorObject::fromObject(*this,false); 59 59 if (v) 60 60 { … … 72 72 } 73 73 74 void* ExtObject::getTarget(const char* classname, bool through_barrier ) const74 void* ExtObject::getTarget(const char* classname, bool through_barrier, bool warn) const 75 75 { 76 76 if (!strcmp(interfaceName(),classname)) … … 81 81 BarrierObject *bo=BarrierObject::fromObject(*this); 82 82 if (bo) 83 return bo->getSourceObject().getTarget(classname );83 return bo->getSourceObject().getTarget(classname,true,warn); 84 84 } 85 85 #endif 86 87 if (warn) 88 { 89 FMprintf("ExtValue","getObjectTarget",FMLV_WARN,"%s object expected, %s found",classname,interfaceName()); 90 } 91 86 92 return NULL; 87 93 } … … 173 179 174 180 if (isEmpty()) return SString(); 175 VectorObject *vec=VectorObject::fromObject(*this );181 VectorObject *vec=VectorObject::fromObject(*this,false); 176 182 if (vec) 177 183 return vec->serialize(); 178 DictionaryObject *dic=DictionaryObject::fromObject(*this );184 DictionaryObject *dic=DictionaryObject::fromObject(*this,false); 179 185 if (dic) 180 186 return dic->serialize(); … … 215 221 /////////////////////////////////////// 216 222 223 void *ExtValue::getObjectTarget(const char* classname,bool warn) const 224 { 225 if (type!=TObj) 226 { 227 if (warn) 228 { 229 SString tmp=getString(); 230 if (tmp.len()>30) tmp=tmp.substr(0,30)+"..."; 231 if (type==TString) tmp=SString("\"")+tmp+SString("\""); 232 FMprintf("ExtValue","getObjectTarget",FMLV_WARN,"%s object expected, %s found",classname,(const char*)tmp); 233 } 234 return NULL; 235 } 236 237 return getObject().getTarget(classname,true,warn); 238 } 239 217 240 void ExtValue::set(const ExtValue& src) 218 241 { … … 326 349 case TObj: 327 350 { 328 VectorObject *vec=VectorObject::fromObject(getObject() );329 VectorObject *vec2=VectorObject::fromObject(src.getObject() );351 VectorObject *vec=VectorObject::fromObject(getObject(),false); 352 VectorObject *vec2=VectorObject::fromObject(src.getObject(),false); 330 353 if (vec && vec2) 331 354 { … … 368 391 case TObj: 369 392 { 370 VectorObject *vec=VectorObject::fromObject(getObject() );393 VectorObject *vec=VectorObject::fromObject(getObject(),false); 371 394 if (vec) 372 395 { … … 532 555 case TString: 533 556 { 534 VectorObject *vec=VectorObject::fromObject(src.getObject() );557 VectorObject *vec=VectorObject::fromObject(src.getObject(),false); 535 558 if (vec) 536 559 sdata()=format(sdata(),(const ExtValue**)&vec->data.getref(0),vec->data.size()); … … 815 838 if (cls && (tmp.getType()!=TUnknown) && (tmp.getType()!=TInvalid)) 816 839 { 817 VectorObject *vec=VectorObject::fromObject(tmp.getObject() );840 VectorObject *vec=VectorObject::fromObject(tmp.getObject(),false); 818 841 if (vec) 819 842 { … … 826 849 } 827 850 } 828 DictionaryObject *dic=DictionaryObject::fromObject(tmp.getObject() );851 DictionaryObject *dic=DictionaryObject::fromObject(tmp.getObject(),false); 829 852 if (dic) 830 853 { -
cpp/frams/util/extvalue.h
r144 r171 58 58 bool matchesInterfaceName(ParamInterface* pi) const {return !strcmp(interfaceName(),pi->getName());} 59 59 void* getTarget() const {return (subtype&1)?dbobject:object;} 60 void* getTarget(const char* classname, bool through_barrier=true ) const;60 void* getTarget(const char* classname, bool through_barrier=true, bool warn=true) const; 61 61 void setEmpty() {decref();subtype=0;param=NULL;object=NULL;} 62 62 int isEmpty() const {return !param;} … … 142 142 bool makeUnique() {return (type==TObj) && odata().makeUnique();} //< @return false if nothing has changed 143 143 ExtPType getType() {return type;} 144 void *getObjectTarget(const char* classname ) {return (type==TObj)?getObject().getTarget(classname):0;}144 void *getObjectTarget(const char* classname,bool warn=true) const; 145 145 void setInt(long v) {if (type!=TInt) setri(v); else idata()=v;} 146 146 void setDouble(double v) {if (type!=TDouble) setrd(v); else ddata()=v;} -
cpp/frams/vm/classes/3dobject.cpp
r156 r171 193 193 Pt3D_Ext* Pt3D_Ext::fromObject(const ExtValue& v) 194 194 { 195 if (v.type!=TObj) return 0; 196 const ExtObject& o=v.getObject(); 197 return (Pt3D_Ext*)o.getTarget(getStaticParam().getName()); 195 return (Pt3D_Ext*)v.getObjectTarget(getStaticParam().getName()); 198 196 } 199 197 … … 444 442 Orient_Ext* Orient_Ext::fromObject(const ExtValue& v) 445 443 { 446 if (v.type!=TObj) return 0; 447 const ExtObject& o=v.getObject(); 448 return (Orient_Ext*)o.getTarget(getStaticParam().getName()); 444 return (Orient_Ext*)v.getObjectTarget(getStaticParam().getName()); 449 445 } 450 446 … … 573 569 ReferenceObj* ReferenceObj::fromObject(const ExtValue& v) 574 570 { 575 if (v.type!=TObj) return 0; 576 const ExtObject& o=v.getObject(); 577 return (ReferenceObj*)o.getTarget(getStaticParam().getName()); 578 } 571 return (ReferenceObj*)v.getObjectTarget(getStaticParam().getName()); 572 } -
cpp/frams/vm/classes/collectionobj.cpp
r164 r171 266 266 } 267 267 268 VectorObject* VectorObject::fromObject(const ExtObject& o )269 { 270 return (VectorObject*)o.getTarget(par.getName() );268 VectorObject* VectorObject::fromObject(const ExtObject& o, bool warn) 269 { 270 return (VectorObject*)o.getTarget(par.getName(),true,warn); 271 271 } 272 272 … … 424 424 } 425 425 426 DictionaryObject* DictionaryObject::fromObject(const ExtObject& o )427 { 428 return (DictionaryObject*)o.getTarget(par.getName() );426 DictionaryObject* DictionaryObject::fromObject(const ExtObject& o, bool warn) 427 { 428 return (DictionaryObject*)o.getTarget(par.getName(), true, warn); 429 429 } 430 430 -
cpp/frams/vm/classes/collectionobj.h
r121 r171 44 44 ExtObject makeObject() {return ExtObject(&par,this);} 45 45 46 static VectorObject* fromObject(const ExtObject& o );46 static VectorObject* fromObject(const ExtObject& o, bool warn=true); 47 47 }; 48 48 … … 74 74 static void p_new(void*,ExtValue*args,ExtValue*ret) 75 75 {ret->setObject(ExtObject(&par,new DictionaryObject));} 76 static DictionaryObject* fromObject(const ExtObject& v );76 static DictionaryObject* fromObject(const ExtObject& v, bool warn=true); 77 77 ExtObject makeObject() {return ExtObject(&par,this);} 78 78 }; -
cpp/frams/vm/classes/genoobj.cpp
r138 r171 107 107 } 108 108 109 Geno* GenoObj::fromObject(const ExtValue& v )109 Geno* GenoObj::fromObject(const ExtValue& v, bool warn) 110 110 { 111 if (v.type!=TObj) return 0; 112 const ExtObject& o=v.getObject(); 113 //if ((o.param!=&getStaticParam())&&(o.param!=&getDynamicParam())) return 0; 114 return (Geno*)o.getTarget(getStaticParam().getName()); 111 return (Geno*)v.getObjectTarget(getStaticParam().getName(), warn); 115 112 } -
cpp/frams/vm/classes/genoobj.h
r138 r171 33 33 static ExtObject makeDynamicObject(Geno* g); 34 34 static ExtObject makeDynamicObjectAndDecRef(Geno* g); 35 static Geno* fromObject(const ExtValue& v );35 static Geno* fromObject(const ExtValue& v, bool warn=true); 36 36 static ParamInterface* getInterface(); 37 37
Note: See TracChangeset
for help on using the changeset viewer.