Annotation of parser3/src/types/pa_vobject.h, revision 1.1

1.1     ! paf         1: /*
        !             2:        Parser
        !             3:        Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
        !             4:        Author: Alexander Petrosyan <paf@design.ru>
        !             5: 
        !             6:        $Id: pa_vobject.h,v 1.17 2001/03/10 16:34:37 paf Exp $
        !             7: */
        !             8: 
        !             9: #ifndef PA_VOBJECT_H
        !            10: #define PA_VOBJECT_H
        !            11: 
        !            12: #include "pa_valiased.h"
        !            13: #include "pa_vjunction.h"
        !            14: #include "pa_vclass.h"
        !            15: 
        !            16: class Temp_class_alias;
        !            17: 
        !            18: class VObject : public VAliased {
        !            19:        friend Temp_class_alias;
        !            20: public: // Value
        !            21:        
        !            22:        // all: for error reporting after fail(), etc
        !            23:        const char *type() const { return "object"; }
        !            24: 
        !            25:        // object_instance: (field)=value;(CLASS)=vclass;(method)=method_ref
        !            26:        Value *get_element(const String& name) {
        !            27:                // $CLASS=my class
        !            28:                if(name==CLASS_NAME)
        !            29:                        return fclass_alias;
        !            30:                // $BASE=my parent
        !            31:                if(name==BASE_NAME)
        !            32:                        return fclass_alias->base();
        !            33:                // $method=junction(self+class+method)
        !            34:                if(Junction *junction=fclass_real.get_junction(*this, name))
        !            35:                        return NEW VJunction(*junction);;
        !            36:                // $field=ffields.field
        !            37:                return static_cast<Value *>(ffields.get(name));
        !            38:        }
        !            39: 
        !            40:        // object_instance: (field)=value
        !            41:        void put_element(const String& name, Value *value) {
        !            42:                // speed1:
        !            43:                //   will not check for '$CLASS(subst)' trick
        !            44:                //   will hope that user ain't THAT self-hating person
        !            45:                // speed2:
        !            46:                //   will not check for '$method_name(subst)' trick
        !            47:                //   -same-
        !            48: 
        !            49:                ffields.put(name, value);
        !            50:        }
        !            51: 
        !            52:        // object_class, object_instance: object_class
        !            53:        VClass *get_class() { return &fclass_real; }
        !            54: 
        !            55: public: // creation
        !            56: 
        !            57:        VObject(Pool& apool, VClass& aclass_real) : VAliased(apool, aclass_real), 
        !            58:                fclass_real(aclass_real),
        !            59:                ffields(apool) {
        !            60:        }
        !            61: 
        !            62: private:
        !            63: 
        !            64:        VClass& fclass_real;
        !            65:        Hash ffields;
        !            66: };
        !            67: 
        !            68: #endif

E-mail: