Changeset 230
- Timestamp:
- 04/25/14 16:15:30 (11 years ago)
- Location:
- cpp/frams/param
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/param/param.cpp
r197 r230 558 558 //////////////////////////////// PARAM //////////////////////////////////// 559 559 560 #ifdef DEBUG 561 void SimpleAbstractParam::sanityCheck(int i) 562 { 563 ParamEntry *pe=entry(i); 564 565 const char* t=pe->type; 566 const char* err=NULL; 567 568 if (*t=='p') 569 { 570 if (pe->fun1==NULL) 571 err="no procedure defined"; 572 } 573 else 574 { 575 if (!(pe->flags & PARAM_READONLY)) 576 { //write access 577 if ((pe->fun2==NULL)&&(pe->offset==PARAM_ILLEGAL_OFFSET)) 578 err="no field defined (GETONLY without PARAM_READONLY?)"; 579 } 580 } 581 if (err!=NULL) 582 FMprintf("SimpleAbstractParam","sanityCheck", FMLV_ERROR, 583 "Invalid ParamEntry for %s.%s (%s)", getName(), pe->id, err); 584 } 585 #endif 586 560 587 void *SimpleAbstractParam::getTarget(int i) 561 588 { … … 566 593 ///////// get 567 594 595 #ifdef DEBUG 596 #define SANITY_CHECK(i) sanityCheck(i) 597 #else 598 #define SANITY_CHECK(i) 599 #endif 600 568 601 long SimpleAbstractParam::getInt(int i) 569 602 { 603 SANITY_CHECK(i); 570 604 ExtValue v; 571 605 ParamEntry *pe = entry(i); … … 584 618 double SimpleAbstractParam::getDouble(int i) 585 619 { 620 SANITY_CHECK(i); 586 621 ExtValue v; 587 622 ParamEntry *pe = entry(i); … … 600 635 SString SimpleAbstractParam::getString(int i) 601 636 { 637 SANITY_CHECK(i); 602 638 ExtValue v; 603 639 ParamEntry *pe = entry(i); … … 616 652 ExtObject SimpleAbstractParam::getObject(int i) 617 653 { 654 SANITY_CHECK(i); 618 655 ExtValue v; 619 656 ParamEntry *pe = entry(i); … … 632 669 ExtValue SimpleAbstractParam::getExtValue(int i) 633 670 { 671 SANITY_CHECK(i); 634 672 ExtValue v; 635 673 ParamEntry *pe = entry(i); … … 651 689 int SimpleAbstractParam::setInt(int i, long x) 652 690 { 691 SANITY_CHECK(i); 653 692 ExtValue v; 654 693 ParamEntry *pe = entry(i); … … 686 725 int SimpleAbstractParam::setDouble(int i, double x) 687 726 { 727 SANITY_CHECK(i); 688 728 ExtValue v; 689 729 ParamEntry *pe = entry(i); … … 721 761 int SimpleAbstractParam::setString(int i, const SString& x) 722 762 { 763 SANITY_CHECK(i); 723 764 ExtValue v; 724 765 SString vs; … … 761 802 int SimpleAbstractParam::setObject(int i, const ExtObject& x) 762 803 { 804 SANITY_CHECK(i); 763 805 ExtValue v; 764 806 ParamEntry *pe = entry(i); … … 782 824 int SimpleAbstractParam::setExtValue(int i, const ExtValue& x) 783 825 { 826 SANITY_CHECK(i); 784 827 ParamEntry *pe = entry(i); 785 828 if (pe->flags&PARAM_READONLY) return PSET_RONLY; … … 801 844 void SimpleAbstractParam::call(int i, ExtValue *args, ExtValue *ret) 802 845 { 846 SANITY_CHECK(i); 803 847 ParamEntry *pe = entry(i); 804 848 if (!pe) return; -
cpp/frams/param/param.h
r197 r230 157 157 158 158 static const char* SERIALIZATION_PREFIX; 159 160 #ifdef DEBUG 161 virtual void sanityCheck(int i) {} 162 #endif 159 163 }; 160 164 … … 170 174 #define FIELDOFFSET(_fld_) ((long)((char*)(&((FIELDSTRUCT*)&MakeCodeGuardHappy)->_fld_)-((char*)((FIELDSTRUCT*)&MakeCodeGuardHappy)))) 171 175 176 #ifdef DEBUG 177 #define PARAM_ILLEGAL_OFFSET ((long)0xdeadbeef) 178 #else 179 #define PARAM_ILLEGAL_OFFSET 0 180 #endif 181 172 182 #define FIELD(_fld_) FIELDOFFSET(_fld_),0,0 173 183 #define LONGOFFSET(_o_) (_o_),0,0 174 #define PROCEDURE(_proc_) 0,(void*)PROCOFFSET(_proc_),0175 #define STATICPROCEDURE(_proc_) 0,(void*)STATICPROCOFFSET(_proc_),0176 #define GETSET(_proc_) 0,(void*)GETOFFSET(get_ ## _proc_),(void*)SETOFFSET(set_ ## _proc_)184 #define PROCEDURE(_proc_) PARAM_ILLEGAL_OFFSET,(void*)PROCOFFSET(_proc_),0 185 #define STATICPROCEDURE(_proc_) PARAM_ILLEGAL_OFFSET,(void*)STATICPROCOFFSET(_proc_),0 186 #define GETSET(_proc_) PARAM_ILLEGAL_OFFSET,(void*)GETOFFSET(get_ ## _proc_),(void*)SETOFFSET(set_ ## _proc_) 177 187 #define GETFIELD(_proc_) FIELDOFFSET(_proc_),(void*)GETOFFSET(get_ ## _proc_),0 178 188 #define SETFIELD(_proc_) FIELDOFFSET(_proc_),0,(void*)SETOFFSET(set_ ## _proc_) 179 #define GETONLY(_proc_) 0,(void*)GETOFFSET(get_ ## _proc_),0180 #define SETONLY(_proc_) 0,0,(void*)SETOFFSET(set_ ## _proc_)189 #define GETONLY(_proc_) PARAM_ILLEGAL_OFFSET,(void*)GETOFFSET(get_ ## _proc_),0 190 #define SETONLY(_proc_) PARAM_ILLEGAL_OFFSET,0,(void*)SETOFFSET(set_ ## _proc_) 181 191 182 192 #define PARAMPROCARGS ExtValue* args,ExtValue* ret … … 271 281 virtual void setDefault(bool numericonly = false); 272 282 virtual void setDefault(int i, bool numericonly = false); 283 284 #ifdef DEBUG 285 void sanityCheck(int i); 286 #endif 273 287 }; 274 288
Note: See TracChangeset
for help on using the changeset viewer.