--- parser3/src/classes/void.C 2008/06/26 15:00:42 1.39 +++ parser3/src/classes/void.C 2009/04/16 01:10:22 1.42 @@ -1,11 +1,11 @@ /** @file Parser: @b VOID parser class. - Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2009 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_VOID_C="$Date: 2008/06/26 15:00:42 $"; +static const char * const IDENT_VOID_C="$Date: 2009/04/16 01:10:22 $"; #include "classes.h" #include "pa_vmethod_frame.h" @@ -44,6 +44,13 @@ static void _length(Request& r, MethodPa static void _pos(Request& r, MethodParams& params) { // just checking for consistency params.as_no_junction(0, "substr must not be code"); + if(params.count()>1){ + ssize_t offset=params.as_int(1, "n must be int", r); + if(offset<0) + throw Exception(PARSER_RUNTIME, + 0, + "n(%d) must be >=0", offset); + } // never found r.write_no_lang(*new VInt(-1)); } @@ -62,8 +69,7 @@ static void _double(Request& r, MethodPa static void _bool(Request& r, MethodParams& params) { VVoid& vvoid=GET_SELF(r, VVoid); - r.write_no_lang(*new VBool( - params.count()==0?vvoid.as_bool():params.as_bool(0, "default must be bool", r))); + r.write_no_lang(VBool::get(params.count()==0?vvoid.as_bool():params.as_bool(0, "default must be bool", r))); } #ifndef DOXYGEN @@ -167,7 +173,8 @@ MVoid::MVoid(): Methoded("void") { add_native_method("length", Method::CT_DYNAMIC, _length, 0, 0); // ^void.pos[substr] - add_native_method("pos", Method::CT_DYNAMIC, _pos, 1, 1); + // ^void.pos[substr](n) + add_native_method("pos", Method::CT_DYNAMIC, _pos, 1, 2); // ^void.int[] // ^void.int(default) @@ -181,7 +188,7 @@ MVoid::MVoid(): Methoded("void") { // ^void.bool(default) add_native_method("bool", Method::CT_DYNAMIC, _bool, 0, 1); - // ^sql[query] + // ^void:sql{query} add_native_method("sql", Method::CT_STATIC, _sql, 1, 2); // ^void.left() ^void.right()