--- parser3/src/include/pa_request.h 2017/02/07 22:00:35 1.249 +++ parser3/src/include/pa_request.h 2023/11/17 19:12:34 1.263 @@ -1,14 +1,14 @@ /** @file Parser: request class decl. - Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com) - Author: Alexandr Petrosian (http://paf.design.ru) + Copyright (c) 2001-2023 Art. Lebedev Studio (http://www.artlebedev.com) + Authors: Konstantin Morshnev , Alexandr Petrosian */ #ifndef PA_REQUEST_H #define PA_REQUEST_H -#define IDENT_PA_REQUEST_H "$Id: pa_request.h,v 1.249 2017/02/07 22:00:35 moko Exp $" +#define IDENT_PA_REQUEST_H "$Id: pa_request.h,v 1.263 2023/11/17 19:12:34 moko Exp $" #include "pa_pool.h" #include "pa_hash.h" @@ -19,6 +19,26 @@ #include "pa_request_charsets.h" #include "pa_sapi.h" +// defines for externs + +#define EXCEPTION_HANDLED_PART_NAME "handled" + + +// externs + +extern const String main_method_name; +extern const String auto_method_name; + +extern const String exception_type_part_name; +extern const String exception_source_part_name; +extern const String exception_comment_part_name; +extern const String exception_handled_part_name; + +// defines for statics + +#define MAIN_CLASS_NAME "MAIN" +#define AUTO_FILE_NAME "auto.p" + // consts const size_t pseudo_file_no__process=1; @@ -37,6 +57,7 @@ class VConsole; extern int pa_loop_limit; extern int pa_execute_recoursion_limit; +extern int pa_httpd_timeout; extern size_t pa_file_size_limit; /// Main workhorse. @@ -89,8 +110,6 @@ private: ArrayOperation& ops() const { return *fops; } VMethodFrame& method_frame() const { return *fmethod_frame; } - /// needed to fill unused Array entries - StackItem() {} StackItem(Value& avalue): fvalue(&avalue) {} StackItem(ArrayOperation& aops): fops(&aops) {} StackItem(VMethodFrame& amethod_frame): fmethod_frame(&amethod_frame) {} @@ -112,6 +131,8 @@ private: bool is_empty() { return fused==fbottom; } + + Table &table(Request &r); }; ///@{ core data @@ -187,13 +208,14 @@ public: /// global classes HashString& classes() { return fclasses; } VStateless_class* get_class(const String& name); + VStateless_class& get_class_ref(const String& name); void put_class(VStateless_class *aclass){ classes().put(aclass->type(), aclass); } /** core request processing BEWARE: may throw exception to you: catch it! */ - void core(const char* config_filespec, bool config_fail_on_read_problem, bool header_only); + void core(const char* config_filespec, bool header_only, const String& amain_method_name = main_method_name, const String* amain_class_name = NULL); /// executes ops void execute(ArrayOperation& ops); // execute.C @@ -237,10 +259,10 @@ public: } /// - void use_file_directly(VStateless_class& aclass, const String& file_spec, bool fail_on_read_problem=true, bool fail_on_file_absence=true); + void use_file_directly(const String& file_spec, bool fail_on_file_absence=true, bool with_auto_p=false); - /// compiles the file, maybe forcing it's class @a name and @a base_class. - void use_file(VStateless_class& aclass, const String& file_name, const String* use_filespec); + /// compiles the file in main class context by default + void use_file(const String& file_name, const String* use_filespec, bool with_auto_p=false); /// for @USE only, calls ^use (which may be user-defined) void use_file(const String& file_name, const String* use_filespec, Operation::Origin origin); @@ -281,8 +303,7 @@ public: /// returns relative to @a path path to @a file const String& relative(const char* apath, const String& relative_name); - /// returns an absolute @a path to relative @a name - const String& absolute(const String& relative_name); + const String& full_disk_path(const String& relative_name); /// returns the mime type of 'user_file_name' const String& mime_type_of(const String* file_name); @@ -343,19 +364,13 @@ public: // status read methods /// public for ^reflection:copy[] void put_element(Value& ncontext, const String& name, Value* value); - /// for @main[] - const String* execute_virtual_method(Value& aself, const String& method_name); + /// for @main[] and parser://method/call + const String* execute_method(VStateless_class& aclass, const String& method_name, Value* optional_param = 0); - //{ for @conf[filespec] and @auto[filespec] and parser://method/call - const String* execute_method(Value& aself, const Method& method, Value* optional_param, bool do_return_string); + //{ for @conf[filespec] and @auto[filespec] + bool execute_method_if_exists(VStateless_class& aclass, const String& method_name, Value* optional_param); + bool execute_auto_method_if_exists(VStateless_class& aclass, const String& method_name, Value* optional_param); - struct Execute_nonvirtual_method_result { - const String* string; - Method* method; - Execute_nonvirtual_method_result(): string(0), method(0) {} - }; - - Execute_nonvirtual_method_result execute_nonvirtual_method(VStateless_class& aclass, const String& method_name, VString* optional_param, bool do_return_string); //} #ifdef XML @@ -523,24 +538,4 @@ public: ~Temp_value_element(); }; -// defines for externs - -#define EXCEPTION_HANDLED_PART_NAME "handled" - - -// externs - -extern const String main_method_name; -extern const String auto_method_name; - -extern const String exception_type_part_name; -extern const String exception_source_part_name; -extern const String exception_comment_part_name; -extern const String exception_handled_part_name; - -// defines for statics - -#define MAIN_CLASS_NAME "MAIN" -#define AUTO_FILE_NAME "auto.p" - #endif