--- parser3/src/classes/reflection.C 2016/12/05 23:52:49 1.76 +++ parser3/src/classes/reflection.C 2017/01/23 20:13:18 1.80 @@ -10,7 +10,7 @@ #include "pa_vbool.h" #include "pa_vobject.h" -volatile const char * IDENT_REFLECTION_C="$Id: reflection.C,v 1.76 2016/12/05 23:52:49 moko Exp $"; +volatile const char * IDENT_REFLECTION_C="$Id: reflection.C,v 1.80 2017/01/23 20:13:18 moko Exp $"; static const String class_type_methoded("methoded"); @@ -436,24 +436,25 @@ static void _mixin(Request& r, MethodPar if(params.count()>1) if(HashStringValue* options=params.as_hash(1, "mixin options")) { int valid_options=0; - if(vtarget=options->get("to")) { - valid_options++; - } - if(Value* vname=options->get("name")) { - name=&vname->as_string(); - valid_options++; - } - if(Value* vmethods=options->get("methods")) { - copy_methods=r.process(*vmethods).as_bool(); - valid_options++; - } - if(Value* vfields=options->get("fields")) { - copy_fields=r.process(*vfields).as_bool(); - valid_options++; - } - if(Value* voverwrite=options->get("overwrite")) { - overwrite=r.process(*voverwrite).as_bool(); - valid_options++; + for(HashStringValue::Iterator i(*options); i; i.next() ){ + String::Body key=i.key(); + Value* value=i.value(); + if(key == "to") { + vtarget=value; + valid_options++; + } else if(key == "name") { + name=&value->as_string(); + valid_options++; + } else if(key == "methods") { + copy_methods=r.process(*value).as_bool(); + valid_options++; + } else if(key == "fields") { + copy_fields=r.process(*value).as_bool(); + valid_options++; + } else if(key == "overwrite") { + overwrite=r.process(*value).as_bool(); + valid_options++; + } } if(valid_options!=options->count()) throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION); @@ -500,12 +501,12 @@ static void _mixin(Request& r, MethodPar String::Language get_untaint_lang(const String& lang_name); // op.C static void _tainting(Request& r, MethodParams& params) { - const String& str=params.as_string(0, "param must be string"); + const String& str=params.as_string(params.count()-1, "param must be string"); String::Language lang = String::L_UNSPECIFIED; bool optimized=false; if(params.count()==2){ - const String& slang=params.as_string(1, "language name must be string"); + const String& slang=params.as_string(0, "language name must be string"); if(slang == "optimized") optimized=true; else if(slang == "tainted") @@ -569,7 +570,7 @@ MReflection::MReflection(): Methoded("re // ^reflection:method_info[junction] add_native_method("method_info", Method::CT_STATIC, _method_info, 1, 2); - // ^reflection:filename[object or class] + // ^reflection:filename[object or class or method] add_native_method("filename", Method::CT_STATIC, _filename, 1, 1); // ^reflection:fields[object or class] @@ -599,7 +600,7 @@ MReflection::MReflection(): Methoded("re // ^reflection:mixin[object or class or junction;options] add_native_method("mixin", Method::CT_STATIC, _mixin, 1, 2); - // ^reflection:tainting[string;optional lang] + // ^reflection:tainting[[language or 'tainted' or 'optimized';]string] add_native_method("tainting", Method::CT_STATIC, _tainting, 1, 2); }