Annotation of parser3/src/types/pa_vstateless_class.C, revision 1.2
1.2 ! paf 1: /*
! 2: Parser
! 3: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
! 4: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
! 5:
! 6: $Id: pa_vstateless_class.C,v 1.1.2.1 2001/03/13 13:40:02 paf Exp $
! 7: */
! 8:
! 9: #include "pa_vstateless_class.h"
! 10: #include "pa_vstring.h"
! 11:
! 12: Value *VStateless_class::get_element(const String& aname) {
! 13: // $NAME=my name
! 14: if(aname==NAME_NAME)
! 15: return NEW VString(fclass_alias->name());
! 16: // $CLASS=my class=myself
! 17: if(aname==CLASS_NAME)
! 18: return fclass_alias;
! 19: // $BASE=my parent
! 20: if(aname==BASE_NAME)
! 21: return fclass_alias->base();
! 22: // $method=junction(self+class+method)
! 23: if(Junction *junction=get_junction(*this, aname))
! 24: return NEW VJunction(*junction);
! 25:
! 26: return 0;
! 27: }
! 28:
! 29: void VStateless_class::add_native_method(
! 30: const char *cstr_name,
! 31: Native_code_ptr native_code,
! 32: int min_numbered_params_count, int max_numbered_params_count) {
! 33:
! 34: String& name=*NEW String(pool()); name.APPEND_CONST(cstr_name);
! 35:
! 36: Method& method=*NEW Method(pool(),
! 37: name,
! 38: min_numbered_params_count, max_numbered_params_count,
! 39: 0/*params_names*/, 0/*locals_names*/,
! 40: 0/*parser_code*/, native_code
! 41: );
! 42: add_method(name, method);
! 43: }
! 44:
! 45: void VStateless_class::put_method(const String& aname, Method *amethod) {
! 46: if(read_only)
! 47: THROW(0, 0,
! 48: &aname,
! 49: "can not add method to read-only '%s' class",
! 50: name().cstr());
! 51:
! 52: fmethods.put(aname, amethod);
! 53: }
E-mail: