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