Annotation of parser3/src/types/pa_method.h, revision 1.2

1.2     ! paf         1: /** @file
        !             2:        Parser: Method class decl.
        !             3: 
        !             4:        Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com)
        !             5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
        !             6: */
        !             7: 
        !             8: #ifndef PA_METHOD_H
        !             9: #define PA_METHOD_H
        !            10: 
        !            11: static const char* IDENT_METHOD_H="$Date: 2003/04/03 10:48:25 $";
        !            12: 
        !            13: 
        !            14: /*#include "pa_string.h"
        !            15: #include "pa_array.h"
        !            16: #include "pa_exception.h"
        !            17: */
        !            18: #include "pa_operation.h"
        !            19: 
        !            20: /**
        !            21:        native code method
        !            22:        params can be NULL when 
        !            23:        method min&max params (see VStateless_class::add_native_method)
        !            24:        counts are zero.        
        !            25: */
        !            26: typedef void (*NativeCodePtr)(Request& request, MethodParams& params);
        !            27: 
        !            28: 
        !            29: /** 
        !            30:        class method.
        !            31: 
        !            32:        methods can have 
        !            33:        - named or
        !            34:        - numbered parameters
        !            35: 
        !            36:        methods can be
        !            37:        - parser or 
        !            38:        - native onces
        !            39: 
        !            40:        holds
        !            41:        - parameter names or number limits
        !            42:        - local names
        !            43:        - code [parser or native]
        !            44: */
        !            45: class Method: public PA_Object {
        !            46: public:
        !            47: 
        !            48:        /// allowed method call types
        !            49:        enum Call_type {
        !            50:                CT_ANY, ///< method can be called either statically or dynamically
        !            51:                CT_STATIC, ///< method can be called only statically
        !            52:                CT_DYNAMIC ///< method can be called only dynamically
        !            53:        };
        !            54:        
        !            55:        /// name for error reporting
        !            56:        //const String& name;
        !            57:        ///
        !            58:        Call_type call_type;
        !            59:        //@{
        !            60:        /// @name either numbered params // for native-code methods = operators
        !            61:        int min_numbered_params_count, max_numbered_params_count;
        !            62:        //@}
        !            63:        //@{
        !            64:        /// @name or named params&locals // for parser-code methods
        !            65:        ArrayString* params_names;  ArrayString* locals_names;
        !            66:        //@}
        !            67:        //@{
        !            68:        /// @name the Code
        !            69:        ArrayOperation* parser_code;/*OR*/NativeCodePtr native_code;
        !            70:        //@}
        !            71: 
        !            72:        Method::Method(
        !            73:                //const String& aname,
        !            74:                Call_type call_type,
        !            75:                int amin_numbered_params_count, int amax_numbered_params_count,
        !            76:                ArrayString* aparams_names, ArrayString* alocals_names,
        !            77:                ArrayOperation* aparser_code, NativeCodePtr anative_code) : 
        !            78: 
        !            79:                //name(aname),
        !            80:                call_type(call_type),
        !            81:                min_numbered_params_count(amin_numbered_params_count),
        !            82:                max_numbered_params_count(amax_numbered_params_count),
        !            83:                params_names(aparams_names), locals_names(alocals_names),
        !            84:                parser_code(aparser_code), native_code(anative_code) {
        !            85:        }
        !            86: 
        !            87:        /// call this before invoking to ensure proper actual numbered params count
        !            88:        void check_actual_numbered_params(
        !            89:                Value& self, /*const String& actual_name, */MethodParams* actual_numbered_params) const;
        !            90: };
        !            91: 
        !            92: ///    Auto-object used for temporarily substituting/removing elements
        !            93: class Temp_value_element {
        !            94:        Value& fwhere;
        !            95:        const String& fname;
        !            96:        Value* saved;
        !            97: public:
        !            98:        Temp_value_element(Value& awhere, const String& aname, Value* awhat) : 
        !            99:                fwhere(awhere),
        !           100:                fname(aname),
        !           101:                saved(awhere.get_element(aname, awhere, false)) {
        !           102:                fwhere.put_element(aname, awhat, false);
        !           103:        }
        !           104:        ~Temp_value_element() { 
        !           105:                fwhere.put_element(fname, saved, false);
        !           106:        }
        !           107: };
        !           108: 
        !           109: 
        !           110: #endif

E-mail: