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

1.8       paf         1: /**    @file
                      2:        Parser: stateless class.
                      3: 
1.22      paf         4:        Copyright (c) 2001-2004 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.27    ! paf         8: static const char * const IDENT_VSTATELESS_CLASS_C="$Date: 2005/07/28 11:23:02 $";
1.2       paf         9: 
                     10: #include "pa_vstateless_class.h"
1.24      paf        11: #include "pa_vproperty.h"
1.17      paf        12: 
1.24      paf        13: /// @TODO why?! request must be different ptr from global [used in VStateless_class.add_method]
1.17      paf        14: void VStateless_class::add_method(const String& name, Method& method) {
1.20      paf        15:        if(flocked)
1.17      paf        16:                throw Exception("parser.runtime",
                     17:                        &name,
                     18:                        "can not add method to system class (maybe you have forgotten .CLASS in ^process[$caller.CLASS]{...}?)");
1.20      paf        19: 
1.17      paf        20:        put_method(name, &method);
                     21: }
1.2       paf        22: 
                     23: void VStateless_class::add_native_method(
1.20      paf        24:        const char* cstr_name,
1.7       paf        25:        Method::Call_type call_type,
1.20      paf        26:        NativeCodePtr native_code,
1.2       paf        27:        int min_numbered_params_count, int max_numbered_params_count) {
                     28: 
1.20      paf        29:        const String& name=*new String(cstr_name);
1.2       paf        30:        
1.20      paf        31:        Method& method=*new Method(
1.7       paf        32:                call_type,
1.2       paf        33:                min_numbered_params_count, max_numbered_params_count,
                     34:                0/*params_names*/, 0/*locals_names*/,
                     35:                0/*parser_code*/, native_code
                     36:                );
                     37:        add_method(name, method);
1.16      paf        38: }
                     39: 
                     40: /// VStateless_class: $CLASS, $method
1.20      paf        41: Value* VStateless_class::get_element(const String& aname, Value& aself, bool looking_up) {
1.16      paf        42:        // $CLASS
                     43:        if(aname==CLASS_NAME)
                     44:                return this;
                     45:        // $method=junction(self+class+method)
1.20      paf        46:        if(Method* method=get_method(aname))
1.27    ! paf        47:                return new VJunction(aself, method);
1.18      paf        48: 
                     49:        // base monkey
1.26      paf        50:        if(fbase) {
                     51:                if(Value* obase=aself.base()) // MXdoc has fbase but does not have object_base[ base() ]
                     52:                        return fbase->get_element(aname, *obase, looking_up);
                     53:        }
1.18      paf        54: 
1.16      paf        55:        return 0;
1.23      paf        56: }
                     57: 
                     58: void VStateless_class::put_method(const String& aname, Method* amethod) {
1.25      paf        59:        fmethods.put(aname, amethod); 
1.2       paf        60: }

E-mail: