--- parser3/src/classes/regex.C 2010/10/21 15:06:29 1.6 +++ parser3/src/classes/regex.C 2018/01/19 00:27:43 1.12 @@ -1,12 +1,10 @@ /** @file Parser: @b int parser class. - Copyright (c) 2001-2009 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_REGEX_C="$Date: 2010/10/21 15:06:29 $"; - #include "classes.h" #include "pa_vmethod_frame.h" @@ -14,6 +12,8 @@ static const char * const IDENT_REGEX_C= #include "pa_vint.h" #include "pa_vregex.h" +volatile const char * IDENT_REGEX_C="$Id: regex.C,v 1.12 2018/01/19 00:27:43 moko Exp $"; + // class class MRegex: public Methoded { @@ -25,7 +25,7 @@ public: // global variable -DECLARE_CLASS_VAR(regex, new MRegex, 0); +DECLARE_CLASS_VAR(regex, new MRegex); // methods @@ -34,9 +34,13 @@ static void _create(Request& r, MethodPa VRegex& vregex=GET_SELF(r, VRegex); - vregex.set(r.charsets.source(), - &pattern, - params.count()>1?¶ms.as_string(1, OPTIONS_MUST_NOT_BE_CODE):0); + if(VRegex* aregex = static_cast(params[0].as(VREGEX_TYPE))){ + if(params.count()>1) + throw Exception(PARSER_RUNTIME, 0, "options can't be specified"); + vregex.set(*aregex); + } else { + vregex.set(r.charsets.source(), &pattern, params.count()>1 ? ¶ms.as_string(1, OPTIONS_MUST_NOT_BE_CODE) : 0); + } vregex.compile(); @@ -46,18 +50,18 @@ static void _create(Request& r, MethodPa static void _size(Request& r, MethodParams&) { VRegex& vregex=GET_SELF(r, VRegex); - r.write_no_lang(*new VInt(vregex.get_info_size())); + r.write(*new VInt(vregex.get_info_size())); } static void _study_size(Request& r, MethodParams&) { VRegex& vregex=GET_SELF(r, VRegex); - r.write_no_lang(*new VInt(vregex.get_study_size())); + r.write(*new VInt(vregex.get_study_size())); } // constructor MRegex::MRegex(): Methoded("regex") { - // ^regex::create[string[;options]] + // ^regex::create[string|regex[;options]] add_native_method("create", Method::CT_DYNAMIC, _create, 1, 2); // ^regex.info_size[]