Annotation of parser3/src/types/pa_vstateless_class.C, revision 1.19.2.9

1.8       paf         1: /**    @file
                      2:        Parser: stateless class.
                      3: 
1.19.2.3  paf         4:        Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com)
1.13      paf         5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)\
1.14      paf         6: */
1.8       paf         7: 
1.19.2.9! paf         8: static const char* IDENT_VSTATELESS_CLASS_C="$Date: 2003/03/11 14:58:33 $";
1.2       paf         9: 
                     10: #include "pa_vstateless_class.h"
1.17      paf        11: 
1.19.2.2  paf        12: void VStateless_class::add_method(StringPtr name, MethodPtr method) {
1.19.2.1  paf        13:        if(flocked)
1.17      paf        14:                throw Exception("parser.runtime",
1.19.2.1  paf        15:                        name,
1.17      paf        16:                        "can not add method to system class (maybe you have forgotten .CLASS in ^process[$caller.CLASS]{...}?)");
1.19.2.1  paf        17: 
1.19.2.8  paf        18:        put_method_ptr(name, method);
1.17      paf        19: }
1.2       paf        20: 
                     21: void VStateless_class::add_native_method(
1.19.2.3  paf        22:        const char* cstr_name,
1.7       paf        23:        Method::Call_type call_type,
1.19.2.1  paf        24:        NativeCodePtr native_code,
1.2       paf        25:        int min_numbered_params_count, int max_numbered_params_count) {
                     26: 
1.19.2.1  paf        27:        StringPtr name(new String(cstr_name));
1.2       paf        28:        
1.19.2.1  paf        29:        MethodPtr method(new Method(
1.2       paf        30:                name,
1.7       paf        31:                call_type,
1.2       paf        32:                min_numbered_params_count, max_numbered_params_count,
1.19.2.2  paf        33:                ArrayStringPtr(0)/*params_names*/, ArrayStringPtr(0)/*locals_names*/,
1.19.2.1  paf        34:                ArrayOperationPtr(0)/*parser_code*/, native_code
                     35:                ));
1.2       paf        36:        add_method(name, method);
1.16      paf        37: }
                     38: 
                     39: /// VStateless_class: $CLASS, $method
1.19.2.2  paf        40: ValuePtr VStateless_class::get_element(StringPtr aname, Value& aself, bool looking_up) {
1.16      paf        41:        // $CLASS
1.19.2.1  paf        42:        if(*aname==CLASS_NAME)
1.19.2.5  paf        43:                return ValuePtr(this);
1.19.2.9! paf        44:        if(&aself==(void*)0x0132bd20)
        !            45:                aname=aname;
1.16      paf        46:        // $method=junction(self+class+method)
1.19.2.7  paf        47:        if(MethodPtr method=get_method(aname))
1.19.2.4  paf        48:                return ValuePtr(new VJunction(JunctionPtr(
1.19.2.7  paf        49:                        new Junction(ValuePtr(&aself), method.get(), 0, 0, 0, ArrayOperationPtr(0)))));
1.18      paf        50: 
                     51:        // base monkey
1.16      paf        52:        if(fbase)
1.19.2.1  paf        53:                if(ValuePtr lbase=aself.base()) // one check would be enough...
1.18      paf        54:                        return fbase->get_element(aname, *lbase, looking_up);
                     55: 
1.19.2.5  paf        56:        return ValuePtr(0);
1.2       paf        57: }

E-mail: