--- parser3/src/classes/op.C 2005/11/18 11:44:04 1.152.4.4 +++ parser3/src/classes/op.C 2005/07/15 06:16:41 1.153 @@ -1,11 +1,11 @@ /** @file Parser: parser @b operators. - Copyright (c) 2001-2005 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: 2005/11/18 11:44:04 $"; +static const char * const IDENT_OP_C="$Date: 2005/07/15 06:16:41 $"; #include "classes.h" #include "pa_vmethod_frame.h" @@ -83,11 +83,14 @@ public: // methods static void _if(Request& r, MethodParams& params) { - bool condition=params.as_bool(0, "condition must be expression", r); + Value& condition_code=params.as_junction(0, "condition must be expression"); + + bool condition=r.process_to_value(condition_code, + false/*don't intercept string*/).as_bool(); if(condition) - r.write_pass_lang(r.process(*params.get(1))); + r.write_pass_lang(r.process(params.as_junction(1, "'then' parameter must be code"))); else if(params.count()>2) - r.write_pass_lang(r.process(*params.get(2))); + r.write_pass_lang(r.process(params.as_junction(2, "'else' parameter must be code"))); } static void _untaint(Request& r, MethodParams& params) { @@ -379,7 +382,7 @@ static void _case(Request& r, MethodPara for(int i=0; i_default=&code; break; } @@ -495,7 +498,7 @@ struct Locked_process_and_cache_put_acti static StringOrValue process_cache_body_code(Request& r, Value* body_code) { - return StringOrValue(&r.process_to_string(*body_code), 0); + return StringOrValue(r.process_to_string(*body_code)); } /* @todo maybe network order worth spending some effort? @@ -608,18 +611,6 @@ static const String& as_file_spec(Reques return r.absolute(params.as_string(index, "filespec must be string")); } static void _cache(Request& r, MethodParams& params) { - if(params.count()==0) - { - // return current expiration time - Cache_scope* scope=static_cast(r.classes_conf.get(cache_data_name)); - if(!scope) - throw Exception("parser.runtime", - 0, - "expire-time get without cache"); - r.write_no_lang(*new VDate(scope->expires)); - return; - } - time_t now=time(0); // ^cache[filename] ^cache(seconds) ^cache[expires date] @@ -823,8 +814,7 @@ VClassMAIN::VClassMAIN(): VClass() { // ^cache[file_spec](time){code}[{catch code}] time=0 no cache // ^cache[file_spec] delete cache - // ^cache[] get current expiration time - add_native_method("cache", Method::CT_ANY, _cache, 0, 4); + add_native_method("cache", Method::CT_ANY, _cache, 1, 4); // switch