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

1.1.2.1   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: 
1.1.2.2 ! paf        11: static const char* IDENT_METHOD_H="$Date: 2003/02/04 09:06:59 $";
1.1.2.1   paf        12: 
                     13: #include "pa_pool.h"
                     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, 
                     27:                                                                StringPtr method_name, 
                     28:                                                                MethodParams& params);
                     29: 
                     30: 
                     31: typedef Array<StringPtr> ArrayString; DECLARE_OBJECT_PTR(ArrayString);
                     32: 
                     33: /** 
                     34:        class method.
                     35: 
                     36:        methods can have 
                     37:        - named or
                     38:        - numbered parameters
                     39: 
                     40:        methods can be
                     41:        - parser or 
                     42:        - native onces
                     43: 
                     44:        holds
                     45:        - parameter names or number limits
                     46:        - local names
                     47:        - code [parser or native]
                     48: */
                     49: class Method: public PA_Object {
                     50: public:
                     51: 
                     52:        /// allowed method call types
                     53:        enum Call_type {
                     54:                CT_ANY, ///< method can be called either statically or dynamically
                     55:                CT_STATIC, ///< method can be called only statically
                     56:                CT_DYNAMIC ///< method can be called only dynamically
                     57:        };
                     58:        
                     59:        /// name for error reporting
                     60:        StringPtr name;
                     61:        ///
                     62:        Call_type call_type;
                     63:        //@{
                     64:        /// @name either numbered params // for native-code methods = operators
                     65:        int min_numbered_params_count, max_numbered_params_count;
                     66:        //@}
                     67:        //@{
                     68:        /// @name or named params&locals // for parser-code methods
                     69:        ArrayStringPtr params_names;  ArrayStringPtr locals_names;
                     70:        //@}
                     71:        //@{
                     72:        /// @name the Code
                     73:        ArrayOperationPtr parser_code;/*OR*/NativeCodePtr native_code;
                     74:        //@}
                     75: 
                     76:        Method::Method(
                     77:                StringPtr aname,
                     78:                Call_type call_type,
                     79:                int amin_numbered_params_count, int amax_numbered_params_count,
                     80:                ArrayStringPtr aparams_names, ArrayStringPtr alocals_names,
                     81:                ArrayOperationPtr aparser_code, NativeCodePtr anative_code) : 
                     82: 
                     83:                name(aname),
                     84:                call_type(call_type),
                     85:                min_numbered_params_count(amin_numbered_params_count),
                     86:                max_numbered_params_count(amax_numbered_params_count),
                     87:                params_names(aparams_names), locals_names(alocals_names),
                     88:                parser_code(aparser_code), native_code(anative_code) {
                     89:        }
                     90: 
                     91:        /// call this before invoking to ensure proper actual numbered params count
                     92:        void check_actual_numbered_params(
                     93:                Value& self, StringPtr actual_name, MethodParams& actual_numbered_params) const;
                     94: };
                     95: 
                     96: ///    Auto-object used for temporarily substituting/removing elements
                     97: class Temp_value_element {
                     98:        Value& fwhere;
                     99:        StringPtr fname;
                    100:        ValuePtr saved;
                    101: public:
                    102:        Temp_value_element(Value& awhere, StringPtr aname, ValuePtr awhat) : 
                    103:                fwhere(awhere),
                    104:                fname(aname),
                    105:                saved(awhere.get_element(aname, awhere, false)) {
                    106:                fwhere.put_element(aname, awhat, false);
                    107:        }
                    108:        ~Temp_value_element() { 
                    109:                fwhere.put_element(fname, saved, false);
                    110:        }
                    111: };
                    112: 
                    113: 
                    114: #endif

E-mail: