--- parser3/src/classes/Attic/random.C 2001/04/02 08:49:38 1.2 +++ parser3/src/classes/Attic/random.C 2001/04/17 19:00:27 1.7 @@ -5,12 +5,9 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: random.C,v 1.2 2001/04/02 08:49:38 paf Exp $ + $Id: random.C,v 1.7 2001/04/17 19:00:27 paf Exp $ */ -#include -#include - #include "pa_config_includes.h" #include "pa_common.h" #include "_random.h" @@ -23,13 +20,14 @@ VStateless_class *random_class; // methods -static void _generate(Request& r, const String& method_name, Array *params) { +/// @test noticed series in isapi, check how initialize_random_class is called! [must be called only once] +static void _generate(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); - uint max=params->size()? - (uint)(r.process(*static_cast(params->get(0)))).as_double():0; + Value& range=params->get_junction(0, "range must be expression"); + uint max=params->size()?(uint)r.process(range).as_double():0; if(max<=1) - RTHROW(0, 0, + PTHROW(0, 0, &method_name, "bad range [0..%u]", max); @@ -44,5 +42,5 @@ void initialize_random_class(Pool& pool, // ^random.generate[] // ^random.generate(range) - vclass.add_native_method("generate", Method::CT_STATIC, _generate, 0, 1); + vclass.add_native_method("generate", Method::CT_STATIC, _generate, 1, 1); }