--- parser3/src/include/pa_request.h 2003/03/21 14:27:51 1.160.2.37.2.4 +++ parser3/src/include/pa_request.h 2003/04/02 09:32:11 1.160.2.37.2.15 @@ -8,9 +8,8 @@ #ifndef PA_REQUEST_H #define PA_REQUEST_H -static const char* IDENT_REQUEST_H="$Date: 2003/03/21 14:27:51 $"; +static const char* IDENT_REQUEST_H="$Date: 2003/04/02 09:32:11 $"; -#include "pa_request_info.h" #include "pa_hash.h" #include "pa_wcontext.h" #include "pa_value.h" @@ -33,11 +32,11 @@ class Temp_lang; class Methoded; class VMethodFrame; class GdomeDOMString_auto_ptr; -class VMail; DECLARE_OBJECT_PTR(VMail); -class VForm; DECLARE_OBJECT_PTR(VForm); -class VResponse; DECLARE_OBJECT_PTR(VResponse); -class VCookie; DECLARE_OBJECT_PTR(VCookie); -class VStateless_class; DECLARE_OBJECT_PTR(VStateless_class); +class VMail; +class VForm; +class VResponse; +class VCookie; +class VStateless_class; /// Main workhorse. class Request: public PA_Object { @@ -52,7 +51,7 @@ class Request: public PA_Object { HashStringValue fclasses; /// already used files to avoid cyclic uses - Hash used_files; + Hash used_files; /** endless execute(execute(... preventing counter @see ANTI_ENDLESS_EXECUTE_RECOURSION @@ -61,26 +60,36 @@ class Request: public PA_Object { ///@} -public: - union StackItem { - const String* string() const { return value->get_string(); } - Value* value; - ArrayOperation* ops; - VMethodFrame* method_frame; + private: + Value* fvalue; + ArrayOperation* fops; + 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 StackItem() {} - StackItem(Value* avalue): value(avalue) {} - StackItem(ArrayOperation* aops): ops(aops) {} - StackItem(VMethodFrame* amethod_frame): method_frame(amethod_frame) {} + StackItem(Value& avalue): fvalue(&avalue) {} + StackItem(ArrayOperation& aops): fops(&aops) {} + StackItem(VMethodFrame& amethod_frame): fmethod_frame(&amethod_frame) {} }; - //@{ request processing status - /// exception stack trace - Stack exception_trace; /// execution stack Stack stack; + +public: + + //@{ request processing status + /// exception stack trace + //Stack exception_trace; /// contexts VMethodFrame* method_frame; Value* rcontext; @@ -94,6 +103,11 @@ public: bool finterrupted; public: + + /// @see Stack::wipe_unused + void wipe_unused_execution_stack() { + stack.wipe_unused(); + } #ifdef RESOURCES_DEBUG /// measures @@ -146,12 +160,12 @@ public: const String& filespec, const char* filespec_cstr); // 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 + StringOrValue process(Value& input_value, bool intercept_string=true); // execute.C //@{ 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(); } - 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(); } //@} @@ -209,10 +223,10 @@ public: const String& mime_type_of(const char* user_file_name_cstr); /// returns current SQL connection if any - SQL_Connection* connection(const String* source) { - if(!fconnection && source) + SQL_Connection* connection(bool fail_on_error=true) { + if(fail_on_error && !fconnection) throw Exception("parser.runtime", - source, + 0, "outside of 'connect' operator"); return fconnection; @@ -250,7 +264,7 @@ public: // status read methods VMethodFrame *get_method_frame() { return method_frame; } Value& get_self(); -#define GET_SELF(request, type) (*static_cast(request.get_self())) +#define GET_SELF(request, type) (static_cast(request.get_self())) /* for strange reason call to this: r.get_self() refuses to compile @@ -266,17 +280,11 @@ public: // charset helpers /// @see Charset::transcode GdomeDOMString_auto_ptr transcode(const String& s); /// @see Charset::transcode - const String& transcode(GdomeDOMString* s -#ifndef NO_STRING_ORIGIN - , const String& origin -#endif - ); + GdomeDOMString_auto_ptr transcode(const StringBody s); /// @see Charset::transcode - const String& transcode(xmlChar* s -#ifndef NO_STRING_ORIGIN - , const String& origin -#endif - ); + const String& transcode(GdomeDOMString* s); + /// @see Charset::transcode + const String& transcode(xmlChar* s); #endif @@ -285,11 +293,11 @@ private: /// already executed some @conf method bool configure_admin_done; - void configure_admin(VStateless_class& conf_class, const String* source); + void configure_admin(VStateless_class& conf_class); 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 @@ -311,7 +319,7 @@ private: // execute.C /// for @main[] const String* execute_virtual_method(Value& aself, const String& method_name); - Value* get_element(bool can_call_operator); + Value& get_element(bool can_call_operator); private: // defaults @@ -368,7 +376,7 @@ class Request_context_saver { public: Request_context_saver(Request& ar) : - exception_trace(ar.exception_trace.top_index()), + //exception_trace(ar.exception_trace.top_index()), stack(ar.stack.top_index()), method_frame(ar.method_frame), rcontext(ar.rcontext), @@ -377,7 +385,7 @@ public: fconnection(ar.fconnection), fr(ar) {} void restore() { - fr.exception_trace.top_index(exception_trace); + //fr.exception_trace.top_index(exception_trace); fr.stack.top_index(stack); fr.method_frame=method_frame, fr.rcontext=rcontext; fr.wcontext=wcontext; fr.flang=flang; @@ -422,12 +430,12 @@ public: // externs -extern const String& main_method_name; -extern const String& auto_method_name; -extern const String& body_name; -extern const String& content_disposition_name; -extern const String& content_disposition_value; -extern const String& content_disposition_filename_name; +extern const String main_method_name; +extern const String auto_method_name; +extern const String body_name; +extern const String content_disposition_name; +extern const String content_disposition_value; +extern const String content_disposition_filename_name; // defines for statics