|
|
| version 1.160.2.37.2.3, 2003/03/21 13:42:29 | version 1.160.2.37.2.15, 2003/04/02 09:32:11 |
|---|---|
| Line 10 | Line 10 |
| static const char* IDENT_REQUEST_H="$Date$"; | static const char* IDENT_REQUEST_H="$Date$"; |
| #include "pa_request_info.h" | |
| #include "pa_hash.h" | #include "pa_hash.h" |
| #include "pa_wcontext.h" | #include "pa_wcontext.h" |
| #include "pa_value.h" | #include "pa_value.h" |
| Line 33 class Temp_lang; | Line 32 class Temp_lang; |
| class Methoded; | class Methoded; |
| class VMethodFrame; | class VMethodFrame; |
| class GdomeDOMString_auto_ptr; | class GdomeDOMString_auto_ptr; |
| class VMail; DECLARE_OBJECT_PTR(VMail); | class VMail; |
| class VForm; DECLARE_OBJECT_PTR(VForm); | class VForm; |
| class VResponse; DECLARE_OBJECT_PTR(VResponse); | class VResponse; |
| class VCookie; DECLARE_OBJECT_PTR(VCookie); | class VCookie; |
| class VStateless_class; DECLARE_OBJECT_PTR(VStateless_class); | class VStateless_class; |
| /// Main workhorse. | /// Main workhorse. |
| class Request: public PA_Object { | class Request: public PA_Object { |
| Line 52 class Request: public PA_Object { | Line 51 class Request: public PA_Object { |
| HashStringValue fclasses; | HashStringValue fclasses; |
| /// already used files to avoid cyclic uses | /// already used files to avoid cyclic uses |
| Hash<String* , bool> used_files; | Hash<const StringBody, bool> used_files; |
| /** endless execute(execute(... preventing counter | /** endless execute(execute(... preventing counter |
| @see ANTI_ENDLESS_EXECUTE_RECOURSION | @see ANTI_ENDLESS_EXECUTE_RECOURSION |
| Line 61 class Request: public PA_Object { | Line 60 class Request: public PA_Object { |
| ///@} | ///@} |
| public: | |
| union StackItem { | union StackItem { |
| const String& string() const { return *value->get_string(); } | private: |
| Value* value; | Value* fvalue; |
| ArrayOperation* ops; | ArrayOperation* fops; |
| // void *ptr; | VMethodFrame* fmethod_frame; |
| public: | |
| Value& value() const { return *fvalue; } | |
| const String& string() const { | |
| const String* result=fvalue->get_string(); | |
| assert(result); | |
| return *result; | |
| } | |
| ArrayOperation& ops() const { return *fops; } | |
| VMethodFrame& method_frame() const { return *fmethod_frame; } | |
| /// needed to fill unused Array entries | /// needed to fill unused Array entries |
| StackItem() {} | StackItem() {} |
| StackItem(Value* avalue): value(avalue) {} | StackItem(Value& avalue): fvalue(&avalue) {} |
| StackItem(ArrayOperation* aops): ops(aops) {} | StackItem(ArrayOperation& aops): fops(&aops) {} |
| // StackItem(void *aptr): ptr(aptr) {} | StackItem(VMethodFrame& amethod_frame): fmethod_frame(&amethod_frame) {} |
| }; | }; |
| //@{ request processing status | |
| /// exception stack trace | |
| Stack<String*> exception_trace; | |
| /// execution stack | /// execution stack |
| Stack<StackItem> stack; | Stack<StackItem> stack; |
| public: | |
| //@{ request processing status | |
| /// exception stack trace | |
| //Stack<String*> exception_trace; | |
| /// contexts | /// contexts |
| VMethodFrame* method_frame; | VMethodFrame* method_frame; |
| Value* rcontext; | Value* rcontext; |
| Line 94 public: | Line 103 public: |
| bool finterrupted; | bool finterrupted; |
| public: | public: |
| /// @see Stack::wipe_unused | |
| void wipe_unused_execution_stack() { | |
| stack.wipe_unused(); | |
| } | |
| #ifdef RESOURCES_DEBUG | #ifdef RESOURCES_DEBUG |
| /// measures | /// measures |
| Line 123 public: | Line 137 public: |
| /// executes ops | /// executes ops |
| void execute(ArrayOperation& ops); // execute.C | void execute(ArrayOperation& ops); // execute.C |
| /// execute ops with anti-recoursion check | /// execute ops with anti-recoursion check |
| void recoursion_checked_execute(const String& name, ArrayOperation& ops) { | void recoursion_checked_execute(/*const String& name, */ArrayOperation& ops) { |
| // anti_endless_execute_recoursion | // anti_endless_execute_recoursion |
| if(++anti_endless_execute_recoursion==ANTI_ENDLESS_EXECUTE_RECOURSION) { | if(++anti_endless_execute_recoursion==ANTI_ENDLESS_EXECUTE_RECOURSION) { |
| anti_endless_execute_recoursion=0; // give @exception a chance | anti_endless_execute_recoursion=0; // give @exception a chance |
| throw Exception("parser.runtime", | throw Exception("parser.runtime", |
| &name, | 0, //&name, |
| "call canceled - endless recursion detected"); | "call canceled - endless recursion detected"); |
| } | } |
| execute(ops); // execute it | execute(ops); // execute it |
| Line 146 public: | Line 160 public: |
| const String& filespec, const char* filespec_cstr); // pa_request.C | const String& filespec, const char* filespec_cstr); // pa_request.C |
| /// processes any code-junction there may be inside of @a value | /// processes any code-junction there may be inside of @a value |
| StringOrValue process(Value* input_value, bool intercept_string=true); // execute.C | StringOrValue process(Value& input_value, bool intercept_string=true); // execute.C |
| //@{ convinient helpers | //@{ convinient helpers |
| const String& process_to_string(Value* input_value) { | const String& process_to_string(Value& input_value) { |
| return process(input_value, true/*intercept_string*/).as_string(); | return process(input_value, true/*intercept_string*/).as_string(); |
| } | } |
| Value& process_to_value(Value* input_value, bool intercept_string=true) { | Value& process_to_value(Value& input_value, bool intercept_string=true) { |
| return process(input_value, intercept_string).as_value(); | return process(input_value, intercept_string).as_value(); |
| } | } |
| //@} | //@} |
| Line 209 public: | Line 223 public: |
| const String& mime_type_of(const char* user_file_name_cstr); | const String& mime_type_of(const char* user_file_name_cstr); |
| /// returns current SQL connection if any | /// returns current SQL connection if any |
| SQL_Connection* connection(const String* source) { | SQL_Connection* connection(bool fail_on_error=true) { |
| if(!fconnection && source) | if(fail_on_error && !fconnection) |
| throw Exception("parser.runtime", | throw Exception("parser.runtime", |
| source, | 0, |
| "outside of 'connect' operator"); | "outside of 'connect' operator"); |
| return fconnection; | return fconnection; |
| Line 249 public: | Line 263 public: |
| public: // status read methods | public: // status read methods |
| VMethodFrame *get_method_frame() { return method_frame; } | VMethodFrame *get_method_frame() { return method_frame; } |
| Value* get_self(); | Value& get_self(); |
| #define GET_SELF(request, type) (*static_cast<type *>(request.get_self().get())) | #define GET_SELF(request, type) (static_cast<type &>(request.get_self())) |
| /* for strange reason call to this: | /* for strange reason call to this: |
| r.get_self<VHash>() | r.get_self<VHash>() |
| refuses to compile | refuses to compile |
| Line 266 public: // charset helpers | Line 280 public: // charset helpers |
| /// @see Charset::transcode | /// @see Charset::transcode |
| GdomeDOMString_auto_ptr transcode(const String& s); | GdomeDOMString_auto_ptr transcode(const String& s); |
| /// @see Charset::transcode | /// @see Charset::transcode |
| const String& transcode(GdomeDOMString* s | GdomeDOMString_auto_ptr transcode(const StringBody s); |
| #ifndef NO_STRING_ORIGIN | |
| , const String& origin | |
| #endif | |
| ); | |
| /// @see Charset::transcode | /// @see Charset::transcode |
| const String& transcode(xmlChar* s | const String& transcode(GdomeDOMString* s); |
| #ifndef NO_STRING_ORIGIN | /// @see Charset::transcode |
| , const String& origin | const String& transcode(xmlChar* s); |
| #endif | |
| ); | |
| #endif | #endif |
| Line 285 private: | Line 293 private: |
| /// already executed some @conf method | /// already executed some @conf method |
| bool configure_admin_done; | bool configure_admin_done; |
| void configure_admin(VStateless_class& conf_class, const String* source); | void configure_admin(VStateless_class& conf_class); |
| private: // compile.C | private: // compile.C |
| VStateless_class& real_compile(VStateless_class* aclass, const char* source, const char* file); | VStateless_class& compile(VStateless_class* aclass, const char* source, const char* file); |
| private: // execute.C | private: // execute.C |
| /// for @postprocess[body] | /// for @postprocess[body] |
| const String& execute_method(VMethodFrame& amethodFrame, const Method& method); | const String& execute_method(VMethodFrame& amethodFrame, const Method& method); |
| //{ for @conf[filespec] and @auto[filespec] | //{ for @conf[filespec] and @auto[filespec] |
| const String& execute_method(Value* aself, | const String* execute_method(Value& aself, |
| const Method& method, const VString& optional_param, | const Method& method, VString* optional_param, |
| bool do_return_string); | bool do_return_string); |
| struct Execute_nonvirtual_method_result { | struct Execute_nonvirtual_method_result { |
| const String& string; | const String* string; |
| Method* method; | Method* method; |
| Execute_nonvirtual_method_result(): string(0), method(0) {} | |
| }; | }; |
| Execute_nonvirtual_method_result execute_nonvirtual_method(VStateless_class& aclass, | Execute_nonvirtual_method_result execute_nonvirtual_method(VStateless_class& aclass, |
| const String& method_name, const VString& optional_param, | const String& method_name, VString* optional_param, |
| bool do_return_string); | bool do_return_string); |
| //} | //} |
| /// for @main[] | /// for @main[] |
| const String& execute_virtual_method(Value* aself, const String& method_name); | const String* execute_virtual_method(Value& aself, const String& method_name); |
| Value* get_element(String* & remember_name, bool can_call_operator); | Value& get_element(bool can_call_operator); |
| private: // defaults | private: // defaults |
| Line 367 class Request_context_saver { | Line 376 class Request_context_saver { |
| public: | public: |
| Request_context_saver(Request& ar) : | Request_context_saver(Request& ar) : |
| exception_trace(ar.exception_trace.top_index()), | //exception_trace(ar.exception_trace.top_index()), |
| stack(ar.stack.top_index()), | stack(ar.stack.top_index()), |
| method_frame(ar.method_frame), | method_frame(ar.method_frame), |
| rcontext(ar.rcontext), | rcontext(ar.rcontext), |
| Line 376 public: | Line 385 public: |
| fconnection(ar.fconnection), | fconnection(ar.fconnection), |
| fr(ar) {} | fr(ar) {} |
| void restore() { | void restore() { |
| fr.exception_trace.top_index(exception_trace); | //fr.exception_trace.top_index(exception_trace); |
| fr.stack.top_index(stack); | fr.stack.top_index(stack); |
| fr.method_frame=method_frame, fr.rcontext=rcontext; fr.wcontext=wcontext; | fr.method_frame=method_frame, fr.rcontext=rcontext; fr.wcontext=wcontext; |
| fr.flang=flang; | fr.flang=flang; |
| Line 421 public: | Line 430 public: |
| // externs | // externs |
| extern const String& main_method_name; | extern const String main_method_name; |
| extern const String& auto_method_name; | extern const String auto_method_name; |
| extern const String& body_name; | extern const String body_name; |
| extern const String& content_disposition_name; | extern const String content_disposition_name; |
| extern const String& content_disposition_value; | extern const String content_disposition_value; |
| extern const String& content_disposition_filename_name; | extern const String content_disposition_filename_name; |
| // defines for statics | // defines for statics |