Diff for /parser3/src/classes/reflection.C between versions 1.94 and 1.97

version 1.94, 2024/11/04 03:53:25 version 1.97, 2024/12/23 16:59:17
Line 8 Line 8
 #include "pa_vmethod_frame.h"  #include "pa_vmethod_frame.h"
 #include "pa_request.h"  #include "pa_request.h"
 #include "pa_vbool.h"  #include "pa_vbool.h"
   #include "pa_varray.h"
 #include "pa_vobject.h"  #include "pa_vobject.h"
   
 volatile const char * IDENT_REFLECTION_C="$Id$";  volatile const char * IDENT_REFLECTION_C="$Id$";
Line 26  static const String method_overridden("o Line 27  static const String method_overridden("o
 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");
 static const String method_extra_param("extra_param");  static const String method_extra_param("extra_param");
   static const String method_named_params("named_params");
   
 static const String def_class("class");  static const String def_class("class");
   
Line 256  static void _method(Request& r, MethodPa Line 258  static void _method(Request& r, MethodPa
   
         if(Junction *j=source.get_junction()){          if(Junction *j=source.get_junction()){
                 if(Method* method=const_cast<Method*>(j->method)){                  if(Method* method=const_cast<Method*>(j->method)){
                         Value& self=params.count()>1 ? params.as_no_junction(1, "self must be object, not junction") : r.get_method_frame()->caller()->self();                          Value& self=params.count()>1 ? params.as_no_junction(1, "self must be object") : r.get_method_frame()->caller()->self();
                         r.write(method_junction(self, *method));                          r.write(method_junction(self, *method));
                         return;                          return;
                 }                  }
Line 270  static void _method(Request& r, MethodPa Line 272  static void _method(Request& r, MethodPa
   
         if(VStateless_class* vclass=source.get_class()) {          if(VStateless_class* vclass=source.get_class()) {
                 if(Method* method=vclass->get_method(name)){                  if(Method* method=vclass->get_method(name)){
                         r.write( params.count()>2 ? method_junction(params.as_no_junction(2, "self must be object, not junction"), *method) : *method->get_vjunction(source) );                          r.write( params.count()>2 ? method_junction(params.as_no_junction(2, "self must be object"), *method) : *method->get_vjunction(source) );
                         return;                          return;
                 }                  }
         }          }
Line 278  static void _method(Request& r, MethodPa Line 280  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");
   
         if(HashStringValue* fields=o.get_fields())          if(HashStringValue* fields=o.get_fields())
                 r.write(*new VHash(*fields));                  r.write(*new VHash(*fields));
Line 287  static void _fields(Request& r, MethodPa Line 289  static void _fields(Request& r, MethodPa
 }  }
   
 static void _fields_reference(Request& r, MethodParams& params) {  static void _fields_reference(Request& r, MethodParams& params) {
         Value& o=params.as_no_junction(0, "param must be object or hash, not junction");          Value& o=params.as_no_junction(0, "param must be object or hash");
   
         if(HashStringValue* fields=o.get_fields_reference())          if(HashStringValue* fields=o.get_fields_reference())
                 r.write(*new VHashReference(*fields));                  r.write(*new VHashReference(*fields));
Line 296  static void _fields_reference(Request& r Line 298  static void _fields_reference(Request& r
 }  }
   
 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");
         const String& name=params.as_string(1, "field name must be string");          const String& name=params.as_string(1, "field name must be string");
   
         if(HashStringValue* fields=o.get_fields())          if(HashStringValue* fields=o.get_fields())
Line 361  static void _method_info(Request& r, Met Line 363  static void _method_info(Request& r, Met
                 if( filespec )                  if( filespec )
                         hash->put("file", new VString(*filespec));                          hash->put("file", new VString(*filespec));
   
                 hash->put(method_max_params, new VInt(method->params_names ? method->params_names->count() : 0));                  hash->put(method_max_params, new VInt(method->params_count + (method->named_params ? 1 : 0)));
   
                 if(method->params_names)                  if(method->params_names)
                         for(size_t i=0; i<method->params_names->count(); i++)                          for(size_t i=0; i<method->params_names->count(); i++)
Line 369  static void _method_info(Request& r, Met Line 371  static void _method_info(Request& r, Met
   
                 if(method->extra_params)                  if(method->extra_params)
                         hash->put(method_extra_param, new VString(*method->extra_params));                          hash->put(method_extra_param, new VString(*method->extra_params));
                   if(method->named_params){
                           size_t named_count=method->named_params->count();
                           VArray& named_params=*new VArray(named_count);
                           ArrayValue &array=named_params.array();
   
                           for(size_t i=0; i<named_count; i++) {
                                   const String& fname=*(*method->named_params)[i];
                                   array+=new VString(fname);
                           }
                           hash->put(method_named_params, &named_params);
                   }
         }          }
   
         r.write(result);          r.write(result);
Line 438  static void _uid(Request& r, MethodParam Line 451  static void _uid(Request& r, MethodParam
 }  }
   
 static void _delete(Request&, MethodParams& params) {  static void _delete(Request&, MethodParams& params) {
         Value* v=&params.as_no_junction(0, "param must be object or class, not junction");          Value* v=&params.as_no_junction(0, "param must be object or class");
         const String& key=params.as_string(1, "field name must be string");          const String& key=params.as_string(1, "field name must be string");
   
         if(VObject* o=dynamic_cast<VObject*>(v)){          if(VObject* o=dynamic_cast<VObject*>(v)){

Removed from v.1.94  
changed lines
  Added in v.1.97


E-mail: