--- parser3/src/classes/reflection.C 2015/10/26 13:47:12 1.39 +++ parser3/src/classes/reflection.C 2016/07/13 15:03:51 1.43 @@ -9,7 +9,7 @@ #include "pa_request.h" #include "pa_vbool.h" -volatile const char * IDENT_REFLECTION_C="$Id: reflection.C,v 1.39 2015/10/26 13:47:12 moko Exp $"; +volatile const char * IDENT_REFLECTION_C="$Id: reflection.C,v 1.43 2016/07/13 15:03:51 moko Exp $"; static const String class_type_methoded("methoded"); @@ -19,8 +19,6 @@ static const String method_type_parser(" static const String method_call_type("call_type"); static const String method_inherited("inherited"); static const String method_overridden("overridden"); -static const String method_call_type_static("static"); -static const String method_call_type_dynamic("dynamic"); static const String method_min_params("min_params"); static const String method_max_params("max_params"); @@ -37,7 +35,7 @@ public: // global variable -DECLARE_CLASS_VAR(reflection, new MReflection, 0); +DECLARE_CLASS_VAR(reflection, new MReflection); // methods @@ -58,7 +56,7 @@ static void _create(Request& r, MethodPa throw Exception(PARSER_RUNTIME, &constructor_name, "constructor must be declared in class '%s'", - class_value->get_class()->name_cstr()); + class_value->type()); Junction* junction=constructor_value->get_junction(); const Method* method=junction->method; @@ -70,15 +68,13 @@ static void _create(Request& r, MethodPa if(method->call_type==Method::CT_STATIC) throw Exception(PARSER_RUNTIME, &constructor_name, - "native method of class '%s' (%s) is not allowed to be called dynamically", - class_value->get_class()->name_cstr(), + "native method of class '%s' is not allowed to be called dynamically", class_value->type()); if(nparamsmin_numbered_params_count) throw Exception(PARSER_RUNTIME, &constructor_name, - "native method of class '%s' (%s) accepts minimum %d parameter(s) (%d passed)", - class_value->get_class()->name_cstr(), + "native method of class '%s' accepts minimum %d parameter(s) (%d passed)", class_value->type(), method->min_numbered_params_count, nparams); @@ -91,8 +87,7 @@ static void _create(Request& r, MethodPa if(nparams>max_params_count) throw Exception(PARSER_RUNTIME, &constructor_name, - "method of class '%s' (%s) accepts maximum %d parameter(s) (%d passed)", - class_value->get_class()->name_cstr(), + "method of class '%s' accepts maximum %d parameter(s) (%d passed)", class_value->type(), max_params_count, nparams); @@ -144,7 +139,7 @@ static Value* get_class(Value* value){ static const String* get_class_name(Value* value){ if(VStateless_class* lclass=value->get_class()) - return &lclass->name(); + return new String(lclass->type()); else // classes with fields only, like env & console return new String(value->type()); @@ -198,7 +193,7 @@ static void _def(Request& r, MethodParam const String& type=params.as_string(0, "type must be string"); if(type == def_class) { const String& name=params.as_string(1, "name must be string"); - r.write_no_lang(VBool::get(r.get_class(name)!=0)); + r.write_no_lang(VBool::get(r.classes().get(name)!=0)); } else { throw Exception(PARSER_RUNTIME, &type, "is invalid type, must be '%s'", def_class.cstr()); } @@ -284,16 +279,16 @@ static void _method_info(Request& r, Met c=c->base()->get_class(); while(c->base() && base_method==c->base()->get_method(method_name)) c=c->base()->get_class(); - hash->put((base_method==method) ? method_inherited : method_overridden, new VString(c->name())); + hash->put((base_method==method) ? method_inherited : method_overridden, new VString(*new String(c->type()))); } Value* call_type=0; switch(method->call_type){ case Method::CT_DYNAMIC: - call_type=new VString(method_call_type_dynamic); + call_type=new VString(Symbols::DYNAMIC_SYMBOL); break; case Method::CT_STATIC: - call_type=new VString(method_call_type_static); + call_type=new VString(Symbols::STATIC_SYMBOL); break; case Method::CT_ANY: break;