--- parser3/src/include/pa_request.h 2003/10/21 04:45:19 1.166 +++ parser3/src/include/pa_request.h 2005/08/09 08:14:50 1.179 @@ -1,15 +1,16 @@ /** @file Parser: request class decl. - Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ #ifndef PA_REQUEST_H #define PA_REQUEST_H -static const char* IDENT_REQUEST_H="$Date: 2003/10/21 04:45:19 $"; +static const char * const IDENT_REQUEST_H="$Date: 2005/08/09 08:14:50 $"; +#include "pa_pool.h" #include "pa_hash.h" #include "pa_wcontext.h" #include "pa_value.h" @@ -63,6 +64,10 @@ public: const Operation::Origin origin() const { return forigin; } }; +private: + Pool fpool; +public: + Pool& pool() { return fpool; } private: union StackItem { @@ -72,9 +77,7 @@ private: public: Value& value() const { return *fvalue; } const String& string() const { - const String* result=fvalue->get_string(); - assert(result); - return *result; + return fvalue->as_string(); } ArrayOperation& ops() const { return *fops; } VMethodFrame& method_frame() const { return *fmethod_frame; } @@ -144,7 +147,7 @@ public: bool finterrupted; public: - size_t register_file(String::Body file_spec); + uint register_file(String::Body file_spec); struct Exception_details { const Trace trace; @@ -157,6 +160,7 @@ public: VHash& avhash): trace(atrace), problem_source(aproblem_source), vhash(avhash) {} }; Exception_details get_details(const Exception& e); + const char* get_exception_cstr(const Exception& e, Exception_details& details); /// @see Stack::wipe_unused void wipe_unused_execution_stack() { @@ -214,7 +218,8 @@ public: void use_buf(VStateless_class& aclass, const char* source, const String* main_alias, - uint file_no); // pa_request.C + uint file_no, + int line_no_offset=0); // pa_request.C /// processes any code-junction there may be inside of @a value StringOrValue process(Value& input_value, bool intercept_string=true); // execute.C @@ -315,7 +320,7 @@ public: VCookie& cookie; /// classes configured data - HashStringObject classes_conf; + Hash classes_conf; public: // status read methods @@ -331,6 +336,25 @@ public: // status read methods } */ + /// for @main[] + const String* execute_virtual_method(Value& aself, const String& method_name); + + /// for @postprocess[body] + StringOrValue execute_method(VMethodFrame& amethodFrame, const Method& method); + //{ for @conf[filespec] and @auto[filespec] and parser://method/call + const String* execute_method(Value& aself, + const Method& method, VString* optional_param, + bool do_return_string); + 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 public: // charset helpers @@ -352,32 +376,18 @@ private: void configure_admin(VStateless_class& conf_class); + void configure(); + private: // compile.C VStateless_class& compile(VStateless_class* aclass, const char* source, const String* main_alias, - uint file_no); + uint file_no, + int line_no_offset); private: // execute.C - /// for @postprocess[body] - StringOrValue execute_method(VMethodFrame& amethodFrame, const Method& method); - //{ for @conf[filespec] and @auto[filespec] - const String* execute_method(Value& aself, - const Method& method, VString* optional_param, - bool do_return_string); - 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); - //} - /// for @main[] - const String* execute_virtual_method(Value& aself, const String& method_name); - + void put_element(Value& ncontext, const String& name, Value& value); Value& get_element(Value& ncontext, const String& name, bool can_call_operator); private: // defaults @@ -437,6 +447,7 @@ class Request_context_saver { public: Request_context_saver(Request& ar) : + fr(ar), exception_trace_top(ar.exception_trace.top_index()), exception_trace_bottom(ar.exception_trace.bottom_index()), stack(ar.stack.top_index()), @@ -445,8 +456,7 @@ public: rcontext(ar.rcontext), wcontext(ar.wcontext), flang(ar.flang), - fconnection(ar.fconnection), - fr(ar) {} + fconnection(ar.fconnection) {} void restore() { fr.exception_trace.set_top_index(exception_trace_top); fr.exception_trace.set_bottom_index(exception_trace_bottom); @@ -492,6 +502,8 @@ public: #define CONTENT_DISPOSITION_NAME "content-disposition" #define CONTENT_DISPOSITION_VALUE "attachment" #define CONTENT_DISPOSITION_FILENAME_NAME "filename" +#define EXCEPTION_HANDLED_PART_NAME "handled" + // externs