Annotation of parser3/src/classes/reflection.C, revision 1.73

1.1       misha       1: /** @file
                      2:        Parser: @b reflection parser class.
                      3: 
1.38      moko        4:        Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com)
1.1       misha       5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
                      6: */
                      7: 
                      8: #include "pa_vmethod_frame.h"
                      9: #include "pa_request.h"
                     10: #include "pa_vbool.h"
1.50      moko       11: #include "pa_vobject.h"
1.1       misha      12: 
1.73    ! moko       13: volatile const char * IDENT_REFLECTION_C="$Id: reflection.C,v 1.72 2016/12/01 21:49:02 moko Exp $";
1.24      moko       14: 
1.3       misha      15: static const String class_type_methoded("methoded");
1.2       misha      16: 
1.3       misha      17: static const String method_type_native("native");
                     18: static const String method_type_parser("parser");
1.2       misha      19: 
1.59      moko       20: static const String method_name("name");
1.71      moko       21: static const String method_class_name("class");
1.5       misha      22: static const String method_call_type("call_type");
1.8       misha      23: static const String method_inherited("inherited");
1.23      misha      24: static const String method_overridden("overridden");
1.2       misha      25: 
1.3       misha      26: static const String method_min_params("min_params");
                     27: static const String method_max_params("max_params");
1.29      misha      28: static const String method_extra_param("extra_param");
1.2       misha      29: 
1.30      misha      30: static const String def_class("class");
                     31: 
1.1       misha      32: // class
                     33: 
                     34: class MReflection: public Methoded {
                     35: public:
                     36:        MReflection();
                     37: };
                     38: 
                     39: // global variable
                     40: 
1.40      moko       41: DECLARE_CLASS_VAR(reflection, new MReflection);
1.1       misha      42: 
                     43: // methods
                     44: 
1.73    ! moko       45: const int MAX_CREATE_PARAMS = 100;
1.2       misha      46: 
                     47: static void _create(Request& r, MethodParams& params) {
1.73    ! moko       48:        int params_offset;
        !            49:        HashStringValue* params_hash=0;
        !            50: 
        !            51:        const String* class_name=0;
        !            52:        const String* constructor_name=0;
        !            53: 
        !            54:        Value& voptions=params.as_no_junction(0, "params must not be code");
        !            55:        if(HashStringValue* options=voptions.get_hash()) {
        !            56:                int valid_options=0;
        !            57:                if(Value* vclass_name=options->get("class")) {
        !            58:                        valid_options++;
        !            59:                        class_name=&vclass_name->as_string();
        !            60:                }
        !            61:                if(Value* vconstructor_name=options->get("constructor")) {
        !            62:                        valid_options++;
        !            63:                        constructor_name=&vconstructor_name->as_string();
        !            64:                }
        !            65:                if(Value* vparams_hash=options->get("arguments")) {
        !            66:                        valid_options++;
        !            67:                        params_hash=vparams_hash->as_hash("arguments");
        !            68:                        if(params.count()>1)
        !            69:                                throw Exception(PARSER_RUNTIME, 0, "agruments should not be specified as hash and as create params");
        !            70:                }
        !            71:                if(valid_options!=options->count())
        !            72:                        throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION);
        !            73: 
        !            74:                if(!class_name)
        !            75:                        throw Exception(PARSER_RUNTIME, 0, "class name must be specified");
        !            76:                if(!constructor_name)
        !            77:                        throw Exception(PARSER_RUNTIME, 0, "constructor name must be specified");
        !            78: 
        !            79:                params_offset=1;
        !            80:        } else {
        !            81:                class_name=&params.as_string(0, "param must be string or hash");
        !            82: 
        !            83:                if(params.count()==1)
        !            84:                        throw Exception(PARSER_RUNTIME, 0, "constructor name must be specified");
        !            85: 
        !            86:                constructor_name=&params.as_string(1, "constructor name must be string");
        !            87: 
        !            88:                params_offset=2;
        !            89:        }
1.1       misha      90: 
1.73    ! moko       91:        VStateless_class* vclass=r.get_class(*class_name);
1.48      moko       92:        if(!vclass)
1.73    ! moko       93:                throw Exception(PARSER_RUNTIME, class_name, "class is undefined");
1.1       misha      94: 
1.73    ! moko       95:        const Method* method=vclass->get_method(*constructor_name);
        !            96:        if(!method)
        !            97:                throw Exception(PARSER_RUNTIME, constructor_name, "constructor not found in class '%s'", vclass->type());
1.1       misha      98: 
1.72      moko       99:        Value &object = r.construct(*vclass, *method);
1.2       misha     100: 
1.73    ! moko      101:        int nparams=params_hash ? params_hash->count() : (params.count()-params_offset);
        !           102:        if(nparams>MAX_CREATE_PARAMS)
        !           103:                throw Exception(PARSER_RUNTIME, 0, "arguments count should not exceed %d", MAX_CREATE_PARAMS);
1.1       misha     104: 
1.65      moko      105:        CONSTRUCTOR_FRAME_ACTION(*method, r.get_method_frame(), object, {
1.73    ! moko      106:                Value* v[MAX_CREATE_PARAMS];
1.65      moko      107:                if(nparams>0){
1.73    ! moko      108:                        if(params_hash){
        !           109:                                for(HashStringValue::Iterator i(*params_hash); i; i.next() )
        !           110:                                        v[i]=i.value();
        !           111:                        } else {
        !           112:                                for(int i=0; i<nparams; i++)
        !           113:                                        v[i]=&r.process(params[i+params_offset]);
        !           114:                        }
1.65      moko      115:                        frame.store_params((Value**)&v, nparams);
                    116:                } else {
                    117:                        frame.empty_params();
                    118:                }
                    119:                r.call(frame);
                    120:                object.enable_default_setter();
                    121:                r.write(frame.result());
                    122:        });
1.1       misha     123: }
                    124: 
1.2       misha     125: 
1.3       misha     126: static void _classes(Request& r, MethodParams&) {
                    127:        VHash& result=*new VHash;
1.47      moko      128:        for(HashString<VStateless_class*>::Iterator i(r.classes()); i; i.next()){
                    129:                result.hash().put(i.key(), i.value()->get_methods().count()>0 ? new VString(class_type_methoded) : VVoid::get() );
                    130:        }
1.64      moko      131:        r.write(result);
1.3       misha     132: }
                    133: 
                    134: 
1.53      moko      135: static Value& get_class(Value& value){
                    136:        if(VStateless_class* result=value.get_class())
                    137:                return *result;
                    138:        else {
                    139:                // we can't return code junction to outside as it's stack value
                    140:                if(Junction *j=value.get_junction())
                    141:                        if(j->code)
                    142:                                throw Exception(PARSER_RUNTIME, 0, "param must not be code junction");
                    143:                // method junction
1.3       misha     144:                return value;
1.53      moko      145:        }
1.3       misha     146: }
                    147: 
1.53      moko      148: static const String& get_class_name(Value& value){
                    149:        return *new String(get_class(value).type());
1.3       misha     150: }
                    151: 
                    152: 
1.1       misha     153: static void _class(Request& r, MethodParams& params) {
1.64      moko      154:        r.write(get_class(params[0]));
1.1       misha     155: }
                    156: 
1.2       misha     157: 
1.1       misha     158: static void _class_name(Request& r, MethodParams& params) {
1.64      moko      159:        r.write(get_class_name(params[0]));
1.1       misha     160: }
                    161: 
1.34      moko      162: static void _class_by_name(Request& r, MethodParams& params) {
                    163:        const String& class_name=params.as_string(0, "class_name must be string");
                    164:        Value* class_value=r.get_class(class_name);
                    165:        if(!class_value)
                    166:                throw Exception(PARSER_RUNTIME, &class_name, "class is undefined");
1.64      moko      167:        r.write(*class_value);
1.34      moko      168: }
1.1       misha     169: 
1.2       misha     170: static void _base(Request& r, MethodParams& params) {
1.49      moko      171:        if(VStateless_class* vclass=params[0].get_class())
                    172:                if(Value* base=vclass->base()){
1.64      moko      173:                        r.write(get_class(*base));
1.3       misha     174:                        return;
                    175:                }
                    176: 
                    177:        // classes with fields only, like env & console or without base
1.52      moko      178:        r.write_value(*VVoid::get());
1.2       misha     179: }
1.1       misha     180: 
                    181: 
1.2       misha     182: static void _base_name(Request& r, MethodParams& params) {
1.49      moko      183:        if(VStateless_class* vclass=params[0].get_class())
                    184:                if(Value* base=vclass->base())
1.64      moko      185:                        r.write(get_class_name(*base));
1.2       misha     186: }
1.1       misha     187: 
1.30      misha     188: static void _def(Request& r, MethodParams& params) {
                    189:        const String& type=params.as_string(0, "type must be string");
                    190:        if(type == def_class) {
                    191:                const String& name=params.as_string(1, "name must be string");
1.47      moko      192:                // can't use get_class because it will call @autouse[] if the class wasn't loaded
1.64      moko      193:                r.write(VBool::get(r.classes().get(name)!=0));
1.30      misha     194:        } else {
1.31      misha     195:                throw Exception(PARSER_RUNTIME, &type, "is invalid type, must be '%s'", def_class.cstr());
1.30      misha     196:        }
                    197: }
                    198: 
1.1       misha     199: static void _methods(Request& r, MethodParams& params) {
                    200:        const String& class_name=params.as_string(0, "class_name must be string");
1.49      moko      201:        VStateless_class* vclass=r.get_class(class_name);
                    202:        if(!vclass)
                    203:                throw Exception(PARSER_RUNTIME, &class_name, "class is undefined");
1.1       misha     204: 
                    205:        VHash& result=*new VHash;
1.49      moko      206:        for(HashStringMethod::Iterator i(vclass->get_methods()); i; i.next()){
                    207:                result.hash().put(i.key(), new VString(i.value()->native_code ? method_type_native : method_type_parser));
1.1       misha     208:        }
1.49      moko      209: 
1.64      moko      210:        r.write(result);
1.1       misha     211: }
                    212: 
1.57      moko      213: static VJunction &method_junction(Value &self, Method &method){
1.50      moko      214:        if(method.native_code)
1.57      moko      215:                throw Exception(PARSER_RUNTIME, method.name, "method must not be native");
1.50      moko      216: 
1.51      moko      217:        if(!(dynamic_cast<VObject*>(&self) || dynamic_cast<VClass*>(&self)))
                    218:                throw Exception(PARSER_RUNTIME, 0, "self must be parser object or class");
1.50      moko      219: 
                    220:        return *method.get_vjunction(self);
                    221: }
                    222: 
1.28      misha     223: static void _method(Request& r, MethodParams& params) {
1.62      moko      224:        Value &source=params[0];
1.50      moko      225: 
                    226:        if(Junction *j=source.get_junction()){
                    227:                if(Method* method=const_cast<Method*>(j->method)){
                    228:                        Value& self=params.count()>1 ? params.as_no_junction(1, "self must be object, not junction") : r.get_method_frame()->caller()->self();
1.64      moko      229:                        r.write(method_junction(self, *method));
1.50      moko      230:                        return;
                    231:                }
1.51      moko      232:                throw Exception(PARSER_RUNTIME, 0, "param must be method junction");
1.50      moko      233:        }
                    234: 
                    235:        if(params.count()==1)
1.51      moko      236:                throw Exception(PARSER_RUNTIME, 0, "method name must be specified");
1.50      moko      237: 
1.28      misha     238:        const String& name=params.as_string(1, "method name must be string");
                    239: 
1.50      moko      240:        if(VStateless_class* vclass=source.get_class()) {
                    241:                if(Method* method=vclass->get_method(name)){
1.64      moko      242:                        r.write( params.count()>2 ? method_junction(params.as_no_junction(2, "self must be object, not junction"), *method) : *method->get_vjunction(source) );
1.50      moko      243:                        return;
                    244:                }
1.28      misha     245:        }
1.52      moko      246:        r.write_value(*VVoid::get());
1.28      misha     247: }
                    248: 
1.13      misha     249: static void _fields(Request& r, MethodParams& params) {
1.28      misha     250:        Value& o=params.as_no_junction(0, "param must be object or class, not junction");
                    251: 
1.44      moko      252:        if(HashStringValue* fields=o.get_fields())
1.64      moko      253:                r.write(*new VHash(*fields));
1.44      moko      254:        else
1.64      moko      255:                r.write(*new VHash());
1.13      misha     256: }
1.2       misha     257: 
1.44      moko      258: static void _fields_reference(Request& r, MethodParams& params) {
1.46      moko      259:        Value& o=params.as_no_junction(0, "param must be object or hash, not junction");
1.44      moko      260: 
1.45      moko      261:        if(HashStringValue* fields=o.get_fields_reference())
1.64      moko      262:                r.write(*new VHashReference(*fields));
1.44      moko      263:        else
1.46      moko      264:                throw Exception(PARSER_RUNTIME, 0, "param must be object or hash");
1.44      moko      265: }
                    266: 
1.28      misha     267: static void _field(Request& r, MethodParams& params) {
                    268:        Value& o=params.as_no_junction(0, "first param must be object or class, not junction");
                    269:        const String& name=params.as_string(1, "field name must be string");
                    270: 
                    271:        if(HashStringValue* fields=o.get_fields())
                    272:                if(Value* value=fields->get(name))
1.64      moko      273:                        r.write(*value);
1.28      misha     274: }
                    275: 
1.8       misha     276: static void _method_info(Request& r, MethodParams& params) {
1.59      moko      277:        const Method* method;
1.66      moko      278: 
                    279:        VHash& result=*new VHash;
                    280:        HashStringValue* hash=result.get_hash();
1.2       misha     281: 
1.62      moko      282:        if(Junction *j=params[0].get_junction()){
1.59      moko      283:                if(!(method=j->method))
                    284:                        throw Exception(PARSER_RUNTIME, 0, "param must be class name or method junction");
1.66      moko      285: 
                    286:                hash->put(method_name, new VString(*method->name));
1.71      moko      287:                hash->put(method_class_name, new VString(*new String(j->self.type())));
                    288: 
1.59      moko      289:        } else {
                    290:                const String& class_name=params.as_string(0, "param must be class name or method junction");
1.66      moko      291:                VStateless_class* vclass=r.get_class(class_name);
                    292: 
                    293:                if(!vclass)
1.59      moko      294:                        throw Exception(PARSER_RUNTIME, &class_name, "class is undefined");
                    295: 
                    296:                if(params.count()==1)
                    297:                        throw Exception(PARSER_RUNTIME, 0, "method name must be specified");
                    298: 
                    299:                const String& method_name=params.as_string(1, "method name must be string");
                    300:                if(!(method=vclass->get_method(method_name)))
                    301:                        throw Exception(PARSER_RUNTIME, &method_name, "method not found in class '%s'", vclass->type());
1.2       misha     302: 
1.66      moko      303:                Method* base_method;
                    304:                if(vclass && vclass->base() && (base_method=vclass->base()->get_method(*method->name))){
                    305:                        VStateless_class* c=vclass->base()->get_class();
                    306:                        while(c->base() && base_method==c->base()->get_method(*method->name))
                    307:                                c=c->base()->get_class();
                    308:                        hash->put((base_method==method) ? method_inherited : method_overridden, new VString(*new String(c->type())));
                    309:                }
1.23      misha     310:        }
1.8       misha     311: 
1.29      misha     312:        Value* call_type=0;
                    313:        switch(method->call_type){
                    314:                case Method::CT_DYNAMIC:
1.42      moko      315:                        call_type=new VString(Symbols::DYNAMIC_SYMBOL);
1.29      misha     316:                        break;
                    317:                case Method::CT_STATIC:
1.42      moko      318:                        call_type=new VString(Symbols::STATIC_SYMBOL);
1.29      misha     319:                        break;
1.32      moko      320:                case Method::CT_ANY:
                    321:                        break;
1.29      misha     322:        }
                    323:        if(call_type)
                    324:                hash->put(method_call_type, call_type);
                    325: 
1.2       misha     326:        if(method->native_code){
                    327:                // native code
                    328:                hash->put(method_min_params, new VInt(method->min_numbered_params_count));
                    329:                hash->put(method_max_params, new VInt(method->max_numbered_params_count));
                    330:        } else {
                    331:                // parser code
1.68      moko      332:                const String* filespec = r.get_method_filespec(method);
1.16      misha     333:                if( filespec )
                    334:                        hash->put("file", new VString(*filespec));
1.29      misha     335: 
                    336:                hash->put(method_max_params, new VInt(method->params_names ? method->params_names->count() : 0));
                    337: 
1.2       misha     338:                if(method->params_names)
                    339:                        for(size_t i=0; i<method->params_names->count(); i++)
                    340:                                hash->put(String::Body::Format(i), new VString(*method->params_names->get(i)));
1.29      misha     341: 
                    342:                if(method->extra_params)
                    343:                        hash->put(method_extra_param, new VString(*method->extra_params));
1.2       misha     344:        }
                    345: 
1.64      moko      346:        r.write(result);
1.2       misha     347: }
                    348: 
1.67      moko      349: static void _filename(Request& r, MethodParams& params) {
1.68      moko      350:        if(Junction *j=params[0].get_junction()){
                    351:                if(const Method* method=j->method){
                    352:                        if(!method->native_code)
                    353:                                if(const String* filespec = r.get_method_filespec(method))
                    354:                                        r.write(*new VString(*filespec));
                    355:                        return;
                    356:                }
                    357:                throw Exception(PARSER_RUNTIME, 0, "param must be object, class or method junction");
                    358:        }
1.67      moko      359: 
1.68      moko      360:        if(VClass* vclass = dynamic_cast<VClass*>(params[0].get_class())){
                    361:                r.write(*new VString(vclass->get_filespec()));
1.67      moko      362:        }
                    363: }
                    364: 
1.9       misha     365: static void _dynamical(Request& r, MethodParams& params) {
                    366:        if(params.count()){
1.64      moko      367:                r.write(VBool::get(params[0].get_class() != &params[0]));
1.9       misha     368:        } else {
                    369:                VMethodFrame* caller=r.get_method_frame()->caller();
1.64      moko      370:                r.write(VBool::get(caller && caller->get_class() != &caller->self()));
1.9       misha     371:        }
                    372: }
                    373: 
1.35      moko      374: static void _is(Request& r, MethodParams& params) {
1.39      moko      375:        const String& name=params.as_string(0, "element name must be string");
                    376:        const String& type=params.as_string(1, "class name must be string");
                    377:        Value *context=params.count()==3 ? &(params.as_no_junction(2, "context must not be code")) : r.get_method_frame()->caller();
1.37      moko      378:        Value *value=context ? context->get_element(name) : 0;
1.35      moko      379: 
                    380:        if(value) {
                    381:                if(type == "code" || type == "method") {
                    382:                        Junction *junction=value->get_junction();
1.64      moko      383:                        r.write(VBool::get(junction && ((junction->code==0) ^ (type == "code"))) );
1.35      moko      384:                } else {
1.64      moko      385:                        r.write(VBool::get( value->is(type.cstr()) ));
1.35      moko      386:                }
                    387:        } else
1.64      moko      388:                r.write(VBool::get(type == "void"));
1.35      moko      389: }
                    390: 
1.19      moko      391: static void _copy(Request& r, MethodParams& params) {
                    392:        HashStringValue* src=params.as_no_junction(0, "source must not be code").get_hash();
                    393: 
1.44      moko      394:        if(src==NULL)
1.19      moko      395:                throw Exception(PARSER_RUNTIME, 0, "source must have hash representation");
                    396: 
                    397:        Value& dst=params.as_no_junction(1, "destination must not be code");
                    398: 
                    399:        for(HashStringValue::Iterator i(*src); i; i.next())
1.20      moko      400:                r.put_element(dst, *new String(i.key(), String::L_TAINTED), i.value());
1.19      moko      401: }
                    402: 
1.25      moko      403: static void _uid(Request& r, MethodParams& params) {
                    404:        Value& obj=params.as_no_junction(0, "object must not be code");
                    405: 
                    406:        char local_buf[MAX_NUMBER];
                    407:        int size=snprintf(local_buf, sizeof(local_buf), "%p", &obj);
                    408: 
1.64      moko      409:        r.write(*new String(String::C(pa_strdup(local_buf, (size_t)size), size)));
1.25      moko      410: }
                    411: 
1.27      moko      412: static void _delete(Request&, MethodParams& params) {
1.58      moko      413:        Value* v=&params.as_no_junction(0, "param must be object or class, not junction");
1.26      misha     414:        const String& key=params.as_string(1, "field name must be string");
1.58      moko      415: 
                    416:        if(VObject* o=dynamic_cast<VObject*>(v)){
                    417:                o->get_fields()->remove(key);
                    418:        } else if(VClass* c=dynamic_cast<VClass*>(v)){
                    419:                HashStringProperty &p=*c->get_properties();
                    420:                if(Property* property=p.get(key))
                    421:                        if(property->value)
                    422:                                p.remove(key);
1.26      misha     423:        }
                    424: }
                    425: 
1.55      moko      426: static void _mixin(Request& r, MethodParams& params) {
                    427:        Value& vsource=params.as_no_junction(0, "source must not be code");
                    428: 
                    429:        Value* vtarget=0;
                    430:        const String *name=0;
                    431:        bool copy_methods=true;
                    432:        bool copy_fields=true;
1.60      moko      433:        bool overwrite=false;
1.55      moko      434: 
                    435:        if(params.count()>1)
                    436:                if(HashStringValue* options=params.as_hash(1, "mixin options")) {
                    437:                        int valid_options=0;
                    438:                        if(vtarget=options->get("to")) {
                    439:                                valid_options++;
                    440:                        }
                    441:                        if(Value* vname=options->get("name")) {
                    442:                                name=&vname->as_string();
                    443:                                valid_options++;
                    444:                        }
                    445:                        if(Value* vmethods=options->get("methods")) {
1.61      moko      446:                                copy_methods=r.process(*vmethods).as_bool();
1.55      moko      447:                                valid_options++;
                    448:                        }
                    449:                        if(Value* vfields=options->get("fields")) {
1.61      moko      450:                                copy_fields=r.process(*vfields).as_bool();
1.55      moko      451:                                valid_options++;
                    452:                        }
                    453:                        if(Value* voverwrite=options->get("overwrite")) {
1.61      moko      454:                                overwrite=r.process(*voverwrite).as_bool();
1.55      moko      455:                                valid_options++;
                    456:                        }
                    457:                        if(valid_options!=options->count())
                    458:                                throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION);
                    459:                }
                    460: 
                    461:        if(!vtarget)
                    462:                vtarget=&r.get_method_frame()->caller()->self();
                    463: 
                    464:        VClass* source=dynamic_cast<VClass*>(vsource.get_class());
                    465:        VClass* target=dynamic_cast<VClass*>(vtarget->get_class());
                    466: 
                    467:        if(!source)
                    468:                throw Exception(PARSER_RUNTIME, 0, "source must be parser object or class");
                    469:        if(!target)
                    470:                throw Exception(PARSER_RUNTIME, 0, "destination must be parser object or class");
                    471: 
                    472:        if(name){
                    473:                if(copy_methods)
                    474:                        if(Method* method=source->get_method(*name))
                    475:                                if(overwrite || !target->get_method(*name)){
1.59      moko      476:                                        target->set_method(*name, new Method(*method));
1.55      moko      477:                                }
                    478: 
                    479:                if(copy_fields)
                    480:                        if(Property* property=source->get_properties()->get(*name))
                    481:                                if(property->value && (overwrite || !target->get_properties()->get(*name))){
                    482:                                        target->put_element(*target, *name, property->value);
                    483:                                }
                    484: 
                    485:        } else {
                    486:                if(copy_methods)
                    487:                        for(HashStringMethod::Iterator i(source->get_methods()); i; i.next()){
                    488:                                if(overwrite || !target->get_method(i.key()))
1.59      moko      489:                                        target->set_method(*i.value()->name, new Method(*i.value()));
1.55      moko      490:                        }
                    491:                if(copy_fields)
                    492:                        for(HashStringProperty::Iterator i(*source->get_properties()); i; i.next()){
                    493:                                if(i.value()->value && ( overwrite || !target->get_properties()->get(i.key()) ))
                    494:                                        target->put_element(*target, *new String(i.key(), String::L_TAINTED), i.value()->value);
                    495:                        }
                    496:        }
                    497: }
                    498: 
1.26      misha     499: 
1.1       misha     500: // constructor
                    501: MReflection::MReflection(): Methoded("reflection") {
1.2       misha     502:        // ^reflection:create[class_name;constructor_name[;param1[;param2[;...]]]]
1.73    ! moko      503:        // ^reflection:create[ $.class[name] $.constructor[name] $.arguments[ $.1[param1] $.2[param2] ...] ]
        !           504:        add_native_method("create", Method::CT_STATIC, _create, 1, MAX_CREATE_PARAMS + 2);
1.1       misha     505: 
1.3       misha     506:        // ^reflection:classes[]
                    507:        add_native_method("classes", Method::CT_STATIC, _classes, 0, 0);
                    508: 
1.1       misha     509:        // ^reflection:class[object]
                    510:        add_native_method("class", Method::CT_STATIC, _class, 1, 1);
                    511: 
                    512:        // ^reflection:class_name[object]
                    513:        add_native_method("class_name", Method::CT_STATIC, _class_name, 1, 1);
                    514: 
1.34      moko      515:        // ^reflection:class_by_name[class_name]
                    516:        add_native_method("class_by_name", Method::CT_STATIC, _class_by_name, 1, 1);
                    517: 
1.2       misha     518:        // ^reflection:base_class[object]
                    519:        add_native_method("base", Method::CT_STATIC, _base, 1, 1);
                    520: 
                    521:        // ^reflection:base_class_name[object]
                    522:        add_native_method("base_name", Method::CT_STATIC, _base_name, 1, 1);
                    523: 
1.30      misha     524:        // ^reflection:def[class|...;name]
                    525:        add_native_method("def", Method::CT_STATIC, _def, 2, 2);
                    526: 
1.2       misha     527:        // ^reflection:methods[class_name]
1.1       misha     528:        add_native_method("methods", Method::CT_STATIC, _methods, 1, 1);
1.2       misha     529: 
1.54      moko      530:        // ^reflection:method[object or class;method_name[;self]]
                    531:        // ^reflection:method[junction[;self]]
1.50      moko      532:        add_native_method("method", Method::CT_STATIC, _method, 1, 3);
1.28      misha     533: 
                    534:        // ^reflection:method_info[class_name;method_name]
1.59      moko      535:        // ^reflection:method_info[junction]
                    536:        add_native_method("method_info", Method::CT_STATIC, _method_info, 1, 2);
1.28      misha     537: 
1.67      moko      538:        // ^reflection:filename[object or class]
                    539:        add_native_method("filename", Method::CT_STATIC, _filename, 1, 1);
                    540: 
1.13      misha     541:        // ^reflection:fields[object or class]
                    542:        add_native_method("fields", Method::CT_STATIC, _fields, 1, 1);
                    543: 
1.44      moko      544:        // ^reflection:fields_reference[object]
                    545:        add_native_method("fields_reference", Method::CT_STATIC, _fields_reference, 1, 1);
                    546: 
1.28      misha     547:        // ^reflection:field[object or class;field_name]
                    548:        add_native_method("field", Method::CT_STATIC, _field, 2, 2);
1.9       misha     549: 
                    550:        // ^reflection:dynamical[[object or class, caller if absent]]
                    551:        add_native_method("dynamical", Method::CT_STATIC, _dynamical, 0, 1);
1.19      moko      552: 
1.39      moko      553:        // ^reflection:is[element_name;class_name|code|method[;context]]
1.35      moko      554:        add_native_method("is", Method::CT_STATIC, _is, 2, 3);
                    555: 
1.19      moko      556:        // ^reflection:copy[src;dst]
                    557:        add_native_method("copy", Method::CT_STATIC, _copy, 2, 2);
1.25      moko      558: 
                    559:        // ^reflection:uid[object or class]
                    560:        add_native_method("uid", Method::CT_STATIC, _uid, 1, 1);
1.26      misha     561: 
                    562:        // ^reflection:delete[object or class;field_name]
                    563:        add_native_method("delete", Method::CT_STATIC, _delete, 2, 2);
1.54      moko      564: 
                    565:        // ^reflection:mixin[object or class or junction;options]
1.55      moko      566:        add_native_method("mixin", Method::CT_STATIC, _mixin, 1, 2);
1.54      moko      567: 
1.1       misha     568: }

E-mail: