--- parser3/src/classes/double.C 2003/02/04 14:04:45 1.53.2.2 +++ parser3/src/classes/double.C 2003/02/04 14:23:44 1.53.2.4 @@ -5,48 +5,50 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_DOUBLE_C="$Date: 2003/02/04 14:04:45 $"; +static const char* IDENT_DOUBLE_C="$Date: 2003/02/04 14:23:44 $"; #include "classes.h" +#include "pa_vmethod_frame.h" + #include "pa_request.h" #include "pa_vdouble.h" #include "pa_vint.h" // externs -void _string_format(Request& r, StringPtr method_name, MethodParams& ); +void _string_format(Request& r, StringPtr method_name, MethodParams& /*params*/); // class class MDouble : public Methoded { public: - MDouble(Pool& pool); + MDouble(); public: // Methoded bool used_directly() { return true; } }; +// global variable + +MethodedPtr double_class(new MDouble); + // methods static void _int(Request& r, StringPtr method_name, MethodParams& params) { - Pool& pool=r.pool(); // just checking (default) syntax validity, never really using it here, just for string.int compatibility if(params.count()>0) params.as_junction(0, "default must be int"); - VDouble *vdouble=static_cast(r.get_self()); - Value& result=*new(pool) VInt(pool, vdouble->as_int()); - r.write_no_lang(result); + VDouble& vdouble=*static_cast(r.get_self().get()); + r.write_no_lang(ValuePtr(new VInt(vdouble.as_int()))); } static void _double(Request& r, StringPtr method_name, MethodParams& params) { - Pool& pool=r.pool(); // just checking (default) syntax validity, never really using it here, just for string.doube compatibility if(params.count()>0) params.as_junction(0, "default must be double"); - VDouble *vdouble=static_cast(r.get_self()); - Value& result=*new(pool) VDouble(pool, vdouble->as_double()); - r.write_no_lang(result); + VDouble& vdouble=*static_cast(r.get_self().get()); + r.write_no_lang(ValuePtr(new VDouble(vdouble.as_double()))); } typedef void (*vdouble_op_func_ptr)(VDouble& vdouble, double param); @@ -57,12 +59,12 @@ static void __mul(VDouble& vdouble, doub static void __div(VDouble& vdouble, double param) { vdouble.div(param); } static void __mod(VDouble& vdouble, double param) { vdouble.mod((int)param); } -static void vdouble_op(Request& r, MethodParams *params, +static void vdouble_op(Request& r, MethodParams& params, vdouble_op_func_ptr func) { - VDouble *vdouble=static_cast(r.get_self()); + VDouble& vdouble=*static_cast(r.get_self().get()); double param=params.count()? params.as_double(0, "param must be double", r):1/*used in inc/dec*/; - (*func)(*vdouble, param); + (*func)(vdouble, param); } static void _inc(Request& r, StringPtr /*method_name*/, MethodParams& params) { vdouble_op(r, params, &__inc); } @@ -73,33 +75,30 @@ static void _mod(Request& r, StringPtr / // from string.C extern -const String* sql_result_string(Request& r, StringPtr method_name, MethodParams& params, - Hash *& options, Value *& default_code); +StringPtr sql_result_string(Request& r, StringPtr method_name, MethodParams& params, + HashStringValuePtr& options, ValuePtr& default_code); static void _sql(Request& r, StringPtr method_name, MethodParams& params) { - Pool& pool=r.pool(); - double val; - Hash *options; - Value *default_code; - if(const String *string=sql_result_string(r, method_name, params, options, default_code)) + HashStringValuePtr options; + ValuePtr default_code; + if(StringPtr string=sql_result_string(r, method_name, params, options, default_code)) val=string->as_double(); else if(default_code) - val=r.process_to_value(*default_code).as_double(); + val=r.process_to_value(default_code)->as_double(); else { throw Exception("parser.runtime", - &method_name, + method_name, "produced no result, but no default option specified"); val=0; //calm, compiler } - VDouble& result=*new(pool) VDouble(pool, val); - r.write_no_lang(result); + r.write_no_lang(ValuePtr(new VDouble(val))); } // constructor -MDouble::MDouble(Pool& apool) : Methoded(apool, "double") { +MDouble::MDouble(): Methoded("double") { // ^double.int[] add_native_method("int", Method::CT_DYNAMIC, _int, 0, 1); @@ -126,12 +125,3 @@ MDouble::MDouble(Pool& apool) : Methoded // ^sql[query][$.limit(1) $.offset(2) $.default(0.0)] add_native_method("sql", Method::CT_STATIC, _sql, 1, 2); } -// global variable - -Methoded *double_class; - -// creator - -Methoded *MDouble_create(Pool& pool) { - return double_class=new(pool) MDouble(pool); -}