|
|
| version 1.40, 2005/08/09 08:14:48 | version 1.42, 2006/11/01 17:43:43 |
|---|---|
| Line 164 static inline int _random(uint top) { | Line 164 static inline int _random(uint top) { |
| } | } |
| static void _random(Request& r, MethodParams& params) { | static void _random(Request& r, MethodParams& params) { |
| Value& range=params.as_junction(0, "range must be expression"); | double top=params.as_double(0, "range must be expression", r); |
| double top=r.process_to_value(range).as_double(); | |
| if(top<=0 || top>MAX_UINT) | if(top<=0 || top>MAX_UINT) |
| throw Exception("parser.runtime", | throw Exception("parser.runtime", |
| 0, | 0, |
| Line 181 static double degrees(double param) { re | Line 180 static double degrees(double param) { re |
| static double radians(double param) { return param /180 *PI; } | static double radians(double param) { return param /180 *PI; } |
| static void math1(Request& r, MethodParams& params, math1_func_ptr func) { | static void math1(Request& r, MethodParams& params, math1_func_ptr func) { |
| Value& param=params.as_junction(0, "parameter must be expression"); | double param=params.as_double(0, "parameter must be expression", r); |
| double result=func(param); | |
| double result=func(r.process_to_value(param).as_double()); | |
| r.write_no_lang(*new VDouble(result)); | r.write_no_lang(*new VDouble(result)); |
| } | } |
| Line 208 MATH1(sqrt); | Line 206 MATH1(sqrt); |
| typedef double (*math2_func_ptr)(double, double); | typedef double (*math2_func_ptr)(double, double); |
| static void math2(Request& r, MethodParams& params, math2_func_ptr func) { | static void math2(Request& r, MethodParams& params, math2_func_ptr func) { |
| Value& a=params.as_junction(0, "parameter must be expression"); | double a=params.as_double(0, "parameter must be expression", r); |
| Value& b=params.as_junction(1, "parameter must be expression"); | double b=params.as_double(1, "parameter must be expression", r); |
| double result=func(a, b); | |
| double result=func( | |
| r.process_to_value(a).as_double(), | |
| r.process_to_value(b).as_double()); | |
| r.write_no_lang(*new VDouble(result)); | r.write_no_lang(*new VDouble(result)); |
| } | } |
| Line 292 static const char* hex_string(unsigned c | Line 287 static const char* hex_string(unsigned c |
| unsigned char *end=bytes+size; | unsigned char *end=bytes+size; |
| char *dest=bytes_hex; | char *dest=bytes_hex; |
| static const char *hex=upcase?"0123456789ABCDEF":"0123456789abcdef"; | const char *hex=upcase?"0123456789ABCDEF":"0123456789abcdef"; |
| for(; src<end; src++) { | for(; src<end; src++) { |
| *dest++=hex[*src/0x10]; | *dest++=hex[*src/0x10]; |