--- parser3/src/classes/op.C 2003/12/11 09:25:50 1.142 +++ parser3/src/classes/op.C 2004/03/23 09:43:44 1.147 @@ -1,11 +1,11 @@ /** @file Parser: parser @b operators. - Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2004 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_OP_C="$Date: 2003/12/11 09:25:50 $"; +static const char * const IDENT_OP_C="$Date: 2004/03/23 09:43:44 $"; #include "classes.h" #include "pa_vmethod_frame.h" @@ -18,6 +18,7 @@ static const char * const IDENT_OP_C="$D #include "pa_vdate.h" #include "pa_vmethod_frame.h" #include "pa_vclass.h" +#include "pa_charset.h" // limits @@ -26,6 +27,9 @@ static const char * const IDENT_OP_C="$D // defines #define CASE_DEFAULT_VALUE "DEFAULT" +#define PROCESS_MAIN_OPTION_NAME "main" +#define PROCESS_FILE_OPTION_NAME "file" +#define PROCESS_LINENO_OPTION_NAME "lineno" // class @@ -162,23 +166,54 @@ static void _process(Request& r, MethodP // temporary zero @auto so it wouldn't be auto-called in Request::use_buf Temp_method temp_method_auto(*target_class, auto_method_name, 0); - size_t main_alias_index=index+1; - const String* main_alias=0; - if(main_alias_indexget(PROCESS_MAIN_OPTION_NAME)) { + valid_options++; + main_alias=&vmain_alias->as_string(); + } + if(Value* vfile_alias=options->get(PROCESS_FILE_OPTION_NAME)) { + valid_options++; + file_alias=&vfile_alias->as_string(); + } + if(Value* vline_no_alias_offset=options->get(PROCESS_LINENO_OPTION_NAME)) { + valid_options++; + line_no_alias_offset=vline_no_alias_offset->as_int(); + } + + if(valid_options!=options->count()) + throw Exception("parser.runtime", + 0, + "called with invalid option"); } + uint processe_file_no=file_alias? + r.register_file(r.absolute(*file_alias)) + : pseudo_file_no__process; + // process...{string} + Value& vjunction=params.as_junction(index, "body must be code"); + // evaluate source to process + const String& source=r.process_to_string(vjunction); + r.use_buf(*target_class, + source.cstr(String::L_UNSPECIFIED, r.connection(false)), + main_alias, + processe_file_no, + line_no_alias_offset); + // main_method main_method=target_class->get_method(main_method_name); } @@ -284,7 +319,8 @@ gettimeofday(&mt[0],NULL); #endif // connect SQL_Connection* connection=SQL_driver_manager->get_connection(url.as_string(), - protocol2driver_and_client); + protocol2driver_and_client, + r.charsets.source().NAME().cstr()); #ifdef RESOURCES_DEBUG //measure:after connect @@ -330,11 +366,8 @@ static void _switch(Request& r, MethodPa // execution of found ^case[...]{code} must be in context of ^switch[...]{code} // because of stacked WWrapper used there as wcontext r.process(cases_code, true/*intercept_string*/); - if(Value* selected_code=data->found? data->found: data->_default) { - // setting code context, would execute in ^switch[...]{>>context<<} - //selected_code->get_junction()->change_context(cases_code.get_junction()); + if(Value* selected_code=data->found? data->found: data->_default) r.write_pass_lang(r.process(*selected_code)); - } } static void _case(Request& r, MethodParams& params) { @@ -347,10 +380,6 @@ static void _case(Request& r, MethodPara int count=params.count(); Value& code=params.as_junction(--count, "case result must be code"); - // killing context for safety, would execute in ^switch[...]{>>context<<} - // reason: context is stacked, and it would become invalid afterwards - //code->get_junction()->change_context(0); - for(int i=0; i