|
|
| version 1.41, 2016/04/01 16:27:31 | version 1.45, 2016/07/20 14:51:16 |
|---|---|
| Line 19 static const String method_type_parser(" | Line 19 static const String method_type_parser(" |
| static const String method_call_type("call_type"); | static const String method_call_type("call_type"); |
| static const String method_inherited("inherited"); | static const String method_inherited("inherited"); |
| static const String method_overridden("overridden"); | 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_min_params("min_params"); |
| static const String method_max_params("max_params"); | static const String method_max_params("max_params"); |
| Line 195 static void _def(Request& r, MethodParam | Line 193 static void _def(Request& r, MethodParam |
| const String& type=params.as_string(0, "type must be string"); | const String& type=params.as_string(0, "type must be string"); |
| if(type == def_class) { | if(type == def_class) { |
| const String& name=params.as_string(1, "name must be string"); | 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 { | } else { |
| throw Exception(PARSER_RUNTIME, &type, "is invalid type, must be '%s'", def_class.cstr()); | throw Exception(PARSER_RUNTIME, &type, "is invalid type, must be '%s'", def_class.cstr()); |
| } | } |
| Line 234 static void _method(Request& r, MethodPa | Line 232 static void _method(Request& r, MethodPa |
| static void _fields(Request& r, MethodParams& params) { | static void _fields(Request& r, MethodParams& params) { |
| Value& o=params.as_no_junction(0, "param must be object or class, not junction"); | Value& o=params.as_no_junction(0, "param must be object or class, not junction"); |
| if(HashStringValue* fields=o.get_fields()) { | if(HashStringValue* fields=o.get_fields()) |
| VHash& result=*new VHash(*fields); | r.write_no_lang(*new VHash(*fields)); |
| r.write_no_lang(result); | else |
| } else | |
| r.write_no_lang(*new VHash()); | r.write_no_lang(*new VHash()); |
| } | } |
| static void _fields_reference(Request& r, MethodParams& params) { | |
| Value& o=params.as_no_junction(0, "param must be object or class, not junction"); | |
| if(HashStringValue* fields=o.get_fields_reference()) | |
| r.write_no_lang(*new VHashReference(*fields)); | |
| else | |
| throw Exception(PARSER_RUNTIME, 0, "param must be object or class"); | |
| } | |
| static void _field(Request& r, MethodParams& params) { | static void _field(Request& r, MethodParams& params) { |
| Value& o=params.as_no_junction(0, "first param must be object or class, not junction"); | Value& o=params.as_no_junction(0, "first param must be object or class, not junction"); |
| const String& name=params.as_string(1, "field name must be string"); | const String& name=params.as_string(1, "field name must be string"); |
| Line 254 static void _method_info(Request& r, Met | Line 260 static void _method_info(Request& r, Met |
| const String& class_name=params.as_string(0, "class_name must be string"); | const String& class_name=params.as_string(0, "class_name must be string"); |
| Value* class_value=r.get_class(class_name); | Value* class_value=r.get_class(class_name); |
| if(!class_value) | if(!class_value) |
| throw Exception(PARSER_RUNTIME, | throw Exception(PARSER_RUNTIME, &class_name, "class is undefined"); |
| &class_name, | |
| "class is undefined"); | |
| VStateless_class* lclass=class_value->get_class(); | VStateless_class* lclass=class_value->get_class(); |
| if(!lclass) | if(!lclass) |
| throw Exception(PARSER_RUNTIME, | throw Exception(PARSER_RUNTIME, &class_name, "class does not have methods"); |
| &class_name, | |
| "class does not have methods"); | |
| const String& method_name=params.as_string(1, "method_name must be string"); | const String& method_name=params.as_string(1, "method_name must be string"); |
| Method* method=lclass->get_method(method_name); | Method* method=lclass->get_method(method_name); |
| if(!method) | if(!method) |
| throw Exception(PARSER_RUNTIME, | throw Exception(PARSER_RUNTIME, &method_name, "method not found in class %s", class_name.cstr()); |
| &method_name, | |
| "method not found in class %s", | |
| class_name.cstr()); | |
| VHash& result=*new VHash; | VHash& result=*new VHash; |
| HashStringValue* hash=result.get_hash(); | HashStringValue* hash=result.get_hash(); |
| Line 287 static void _method_info(Request& r, Met | Line 286 static void _method_info(Request& r, Met |
| Value* call_type=0; | Value* call_type=0; |
| switch(method->call_type){ | switch(method->call_type){ |
| case Method::CT_DYNAMIC: | case Method::CT_DYNAMIC: |
| call_type=new VString(method_call_type_dynamic); | call_type=new VString(Symbols::DYNAMIC_SYMBOL); |
| break; | break; |
| case Method::CT_STATIC: | case Method::CT_STATIC: |
| call_type=new VString(method_call_type_static); | call_type=new VString(Symbols::STATIC_SYMBOL); |
| break; | break; |
| case Method::CT_ANY: | case Method::CT_ANY: |
| break; | break; |
| Line 350 static void _is(Request& r, MethodParams | Line 349 static void _is(Request& r, MethodParams |
| static void _copy(Request& r, MethodParams& params) { | static void _copy(Request& r, MethodParams& params) { |
| HashStringValue* src=params.as_no_junction(0, "source must not be code").get_hash(); | HashStringValue* src=params.as_no_junction(0, "source must not be code").get_hash(); |
| if(src==NULL) | if(src==NULL) |
| throw Exception(PARSER_RUNTIME, 0, "source must have hash representation"); | throw Exception(PARSER_RUNTIME, 0, "source must have hash representation"); |
| Value& dst=params.as_no_junction(1, "destination must not be code"); | Value& dst=params.as_no_junction(1, "destination must not be code"); |
| Line 414 MReflection::MReflection(): Methoded("re | Line 413 MReflection::MReflection(): Methoded("re |
| // ^reflection:fields[object or class] | // ^reflection:fields[object or class] |
| add_native_method("fields", Method::CT_STATIC, _fields, 1, 1); | add_native_method("fields", Method::CT_STATIC, _fields, 1, 1); |
| // ^reflection:fields_reference[object] | |
| add_native_method("fields_reference", Method::CT_STATIC, _fields_reference, 1, 1); | |
| // ^reflection:field[object or class;field_name] | // ^reflection:field[object or class;field_name] |
| add_native_method("field", Method::CT_STATIC, _field, 2, 2); | add_native_method("field", Method::CT_STATIC, _field, 2, 2); |