Annotation of parser3/src/types/pa_vstateless_class.C, revision 1.22.12.2
1.8 paf 1: /** @file
2: Parser: stateless class.
3:
1.22.12.1 paf 4: Copyright (c) 2001-2005 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.22.12.2! paf 8: static const char * const IDENT_VSTATELESS_CLASS_C="$Date: 2005/08/05 13:03:05 $";
1.2 paf 9:
10: #include "pa_vstateless_class.h"
1.17 paf 11:
1.20 paf 12: /// @TODO why? request must be different ptr from global [used in VStateless_class.add_method]
1.17 paf 13: void VStateless_class::add_method(const String& name, Method& method) {
1.20 paf 14: if(flocked)
1.17 paf 15: throw Exception("parser.runtime",
16: &name,
17: "can not add method to system class (maybe you have forgotten .CLASS in ^process[$caller.CLASS]{...}?)");
1.20 paf 18:
1.17 paf 19: put_method(name, &method);
20: }
1.2 paf 21:
22: void VStateless_class::add_native_method(
1.20 paf 23: const char* cstr_name,
1.7 paf 24: Method::Call_type call_type,
1.20 paf 25: NativeCodePtr native_code,
1.2 paf 26: int min_numbered_params_count, int max_numbered_params_count) {
27:
1.20 paf 28: const String& name=*new String(cstr_name);
1.2 paf 29:
1.20 paf 30: Method& method=*new Method(
1.7 paf 31: call_type,
1.2 paf 32: min_numbered_params_count, max_numbered_params_count,
33: 0/*params_names*/, 0/*locals_names*/,
34: 0/*parser_code*/, native_code
35: );
36: add_method(name, method);
1.16 paf 37: }
38:
39: /// VStateless_class: $CLASS, $method
1.20 paf 40: Value* VStateless_class::get_element(const String& aname, Value& aself, bool looking_up) {
1.16 paf 41: // $CLASS
42: if(aname==CLASS_NAME)
43: return this;
44: // $method=junction(self+class+method)
1.20 paf 45: if(Method* method=get_method(aname))
1.22.12.2! paf 46: return new VJunction(aself, method, 0, 0, 0, 0);
1.18 paf 47:
48: // base monkey
1.16 paf 49: if(fbase)
1.20 paf 50: if(Value* lbase=aself.base()) // one check would be enough...
1.18 paf 51: return fbase->get_element(aname, *lbase, looking_up);
52:
1.16 paf 53: return 0;
1.2 paf 54: }
E-mail: