--- parser3/src/classes/op.C 2026/01/07 14:48:54 1.276 +++ parser3/src/classes/op.C 2026/09/24 02:40:10 1.281 @@ -1,7 +1,7 @@ /** @file Parser: parser @b operators. - Copyright (c) 2001-2024 Art. Lebedev Studio (http://www.artlebedev.com) + Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com) Authors: Konstantin Morshnev , Alexandr Petrosian */ @@ -17,12 +17,13 @@ #include "pa_vmethod_frame.h" #include "pa_vclass.h" #include "pa_charset.h" +#include "pa_varray.h" #ifdef HAVE_SYSLOG #include "syslog.h" #endif -volatile const char * IDENT_OP_C="$Id: op.C,v 1.276 2026/01/07 14:48:54 moko Exp $"; +volatile const char * IDENT_OP_C="$Id: op.C,v 1.281 2026/09/24 02:40:10 moko Exp $"; // defines @@ -549,18 +550,18 @@ static Try_catch_result try_catch(Reques } catch(const Exception& e) { Request_context_saver throw_context(r); // remembering exception stack trace - Request::Exception_details details=r.get_details(e); + VException& details=*new VException(r, e); try_context.restore(); // restoring try-context for code after try and catch-code { - Temp_value_element temp(r, *catch_code->get_junction()->method_frame, exception_var_name, &details.vhash); + Temp_value_element temp(r, *catch_code->get_junction()->method_frame, exception_var_name, &details); Temp_skip temp_skip(r); result.processed_code=r.process(*catch_code); } // retriving $exception.handled - Value* vhandled=details.vhash.hash().get(exception_handled_part_name); + Value* vhandled=details.handled(); bool bhandled=false; if(vhandled) { @@ -646,7 +647,7 @@ static void locked_process_and_cache_put } else throw Exception(PARSER_RUNTIME, result.exception_should_be_handled, - "$" EXCEPTION_VAR_NAME "." EXCEPTION_HANDLED_PART_NAME " value must be " + "$" EXCEPTION_VAR_NAME ".handled value must be " "either boolean or string '" CACHE_EXCEPTION_HANDLED_CACHE_NAME "'"); } else info.processed_code=&((Value &)result.processed_code).as_string(); @@ -858,13 +859,13 @@ static void _throw_operator(Request&, Me if(params.count()==1 && !params[0].is_string()) { if(HashStringValue *hash=params[0].get_hash()) { const char* type=0; - if(Value* value=hash->get(exception_type_part_name)) + if(Value* value=hash->get(Symbols::TYPE_SYMBOL)) type=value->as_string().cstr(); const String* source=0; - if(Value* value=hash->get(exception_source_part_name)) + if(Value* value=hash->get(Symbols::SOURCE_SYMBOL)) source=&value->as_string(); const char* comment=0; - if(Value* value=hash->get(exception_comment_part_name)) + if(Value* value=hash->get(Symbols::COMMENT_SYMBOL)) comment=value->as_string().cstr(); throw Exception(type, source, "%s", comment); // to avoid MAX_STRING limit @@ -884,6 +885,18 @@ static void _sleep_operator(Request& r, pa_sleep((int)trunc(seconds), (int)trunc((seconds-trunc(seconds))*1000000)); } +static void _a_operator(Request& r, MethodParams& params) { + VArray& result=*new VArray; + ArrayValue& array=result.array(); + + int count=params.count(); + for(int i=0; i2 ? log_level(params.as_string(2, "level must be string")) : LOG_INFO; openlog(*ident ? ident : "parser3", LOG_PID, LOG_USER); syslog(level, "%s", message); closelog(); + (void)r; #else SAPI::log(r.sapi_info, "syslog: %s", message); #endif @@ -1000,6 +1014,9 @@ VClassMAIN::VClassMAIN(): VClass(MAIN_CL add_native_method("sleep", Method::CT_ANY, _sleep_operator, 1, 1); + // equivalent to ^array::create[...] + add_native_method("A", Method::CT_ANY, _a_operator, 0, 10000, Method::CO_WITHOUT_FRAME); + // ^syslog[ident;message[;info|warning|error|debug]] add_native_method("syslog", Method::CT_ANY, _syslog_operator, 2, 3); }