diff -r 0b1d6c529eda472e7a5359013cc5bfa0eb3c5f23 -r 8176df6732447125986de97a4b5c14907d5f3012 include/ptypes.h --- a/include/ptypes.h Sun May 12 22:56:10 2013 -0500 +++ b/include/ptypes.h Tue May 14 23:38:36 2013 -0500 @@ -990,6 +990,7 @@ ptpublic friend void ptdecl apack(variant&); ptpublic friend bool ptdecl anext(const variant& a, int&, variant& item); ptpublic friend bool ptdecl anext(const variant& a, int&, variant& item, string& key); + ptpublic friend bool ptdecl anext(const variant& array, int& index, variant& item, variant & key); ptpublic friend int ptdecl aadd(variant&, const variant& item); ptpublic friend void ptdecl aput(variant&, int index, const variant& item); ptpublic friend void ptdecl ains(variant&, int index, const variant& item); @@ -1104,7 +1105,8 @@ //tpodlist _keys; //tpodlist _vals; public: - tparray() { tag = ARR_NULL; } + static const void * TYPE; //declared in ptparray.cxx - http://stackoverflow.com/questions/1639154/how-to-declare-a-static-const-char-in-your-header-file + tparray() { typeinfo = const_cast(TYPE); tag = ARR_NULL; } //anext function acts similar for variants and loops through elements // This is allowed for both types diff -r 0b1d6c529eda472e7a5359013cc5bfa0eb3c5f23 -r 8176df6732447125986de97a4b5c14907d5f3012 src/ptparray.cxx --- a/src/ptparray.cxx Sun May 12 22:56:10 2013 -0500 +++ b/src/ptparray.cxx Tue May 14 23:38:36 2013 -0500 @@ -8,6 +8,8 @@ PTYPES_BEGIN +const void * tparray::TYPE = (void*)1; + bool ptdecl anext(const tparray& a, int& i, variant& val) { //if (a._vals.size() == i) @@ -46,11 +48,7 @@ if (t.tag == ARR_NULL || t.tag == ARR_LIST) { t.tag = ARR_LIST; - //pout.put("here1"); - //t._vals.push_back(val); add(t._vals, val); - //t._vals.add(val); - //pout.put("here2"); } //else drop it @@ -63,10 +61,6 @@ t.tag = ARR_ASSOCIATIVE; add(t._vals, val); add(t._keys, key); - //t._vals.add(val); - //t._keys.add(key); - //t._vals.push_back(val); - //t._keys.push_back(key); } } diff -r 0b1d6c529eda472e7a5359013cc5bfa0eb3c5f23 -r 8176df6732447125986de97a4b5c14907d5f3012 src/pvariant.cxx --- a/src/pvariant.cxx Sun May 12 22:56:10 2013 -0500 +++ b/src/pvariant.cxx Tue May 14 23:38:36 2013 -0500 @@ -142,10 +142,8 @@ static void vconverr(large v); -static void vfatal(int tag = -1) +static void vfatal() { - //pout.put("tag = "); - //pout.put(tag); fatal(CRIT_FIRST + 60, "Variant data corrupt"); } @@ -197,7 +195,7 @@ initialize(v.value.o); break; default: - vfatal(v.tag); + vfatal(); } } @@ -223,7 +221,7 @@ release(value.o); break; default: - vfatal(tag); + vfatal(); } } tag = VAR_NULL; @@ -297,7 +295,7 @@ assign(v.value.o); break; default: - vfatal(v.tag); + vfatal(); } } @@ -367,7 +365,7 @@ } case VAR_ARRAY: return value.a->count != 0; case VAR_OBJECT: return 0; - default: vfatal(tag); + default: vfatal(); } return 0; } @@ -384,7 +382,7 @@ case VAR_STRING: return !isempty((PTR_TO_STRING(value.s))); case VAR_ARRAY: return value.a->count != 0; case VAR_OBJECT: return value.o != nil; - default: vfatal(tag); + default: vfatal(); } return false; } @@ -409,7 +407,7 @@ } case VAR_ARRAY: return int(value.a->count != 0); case VAR_OBJECT: return 0; - default: vfatal(tag); + default: vfatal(); } return 0; } @@ -432,7 +430,7 @@ case VAR_STRING: initialize(PTR_TO_STRING(v.value.s)); break; case VAR_ARRAY: initialize(); break; case VAR_OBJECT: initialize(); break; - default: vfatal(v.tag); + default: vfatal(); } } @@ -476,7 +474,7 @@ case VAR_STRING: return strcmp(value.s, v.value.s) == 0; case VAR_ARRAY: return value.a == v.value.a; case VAR_OBJECT: return value.o == v.value.o; - default: vfatal(tag); return false; + default: vfatal(); return false; } } @@ -572,11 +570,34 @@ return anext(array, index, item, key); } +bool ptdecl anext(const variant& array, int& index, variant& item, variant & key) +{ + if (array.tag == VAR_OBJECT) + { + void * type = ((component*)array)->get_typeinfo(); + if (type == tparray::TYPE) //tparray + { + return anext(*((tparray*)(component*)array), index, item, key); + } + } + return false; +} + bool ptdecl anext(const variant& array, int& index, variant& item, string & key) { if (array.tag != VAR_ARRAY) { + if (array.tag == VAR_OBJECT) + { + void * type = ((component*)array)->get_typeinfo(); + if (type == tparray::TYPE) //tparray + { + return anext(*((tparray*)(component*)array), index, item); + } else { + return false; + } + } clear(item); return false; }