--- parser3/src/classes/Attic/root.C 2001/03/08 13:42:30 1.2 +++ parser3/src/classes/Attic/root.C 2001/03/11 09:24:41 1.14 @@ -1,31 +1,29 @@ /* -$Id: root.C,v 1.2 2001/03/08 13:42:30 paf Exp $ + Parser + Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) + Author: Alexander Petrosyan (http://design.ru/paf) + + $Id: root.C,v 1.14 2001/03/11 09:24:41 paf Exp $ */ #include "pa_request.h" +#include "_root.h" -static void _if(Request& r, Array& params) { +static void _if(Request& r, Array *params) { bool condition= r.autocalc( - *static_cast(params.get(0)), - false/*don't make it string*/).get_bool(); - Value& value=r.autocalc( - *static_cast(params.get(condition?1:2)), - true/*make it string*/); - r.write(value); + *static_cast(params->get(0)), + 0/*no name*/, + false/*don't intercept string*/).get_bool(); + if(condition) { + Value& value=r.autocalc(*static_cast(params->get(1))); + r.wcontext->write(value, String::Untaint_lang::PASS_APPENDED); + } else if(params->size()==3) { + Value& value=r.autocalc(*static_cast(params->get(2))); + r.wcontext->write(value, String::Untaint_lang::PASS_APPENDED); + } } -void construct_root_class(Request& request) { - Pool& pool=request.pool(); - String& IF_NAME=*new(pool) String(pool); - IF_NAME.APPEND_CONST("if"); - - Method& IF_METHOD=*new(pool) Method(pool, - IF_NAME, - 3/*numbered_params_count*/, - 0/*params_names*/, 0/*locals_names*/, - 0/*parser_code*/, _if - ); - - request.root_class.add_method(IF_NAME, IF_METHOD); +void initialize_root_class(Pool& pool, VClass& vclass) { + vclass.add_native_method("if", _if, 2, 3); // ^if(c){t} ^if(c){t}{f} }