Annotation of parser3/src/classes/double.C, revision 1.5

1.1       paf         1: /*
1.4       paf         2:        Parser
                      3:        Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.5     ! paf         4:        Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.4       paf         5: 
1.5     ! paf         6:        $Id: double.C,v 1.4 2001/03/10 16:34:33 paf Exp $
1.1       paf         7: */
                      8: 
                      9: #include "pa_request.h"
                     10: #include "_double.h"
                     11: #include "pa_vdouble.h"
                     12: #include "pa_vint.h"
                     13: 
                     14: // global var
                     15: 
                     16: VClass *double_class;
                     17: 
                     18: // methods
                     19: 
                     20: static void _int(Request& r, Array *) {
                     21:        Pool& pool=r.pool();
                     22:        VDouble *vdouble=static_cast<VDouble *>(r.self);
                     23:        Value& value=*new(pool) VInt(pool, static_cast<int>(vdouble->get_double()));
1.3       paf        24:        r.wcontext->write(value, String::Untaint_lang::NO /*always object, not string*/);
1.1       paf        25: }
                     26: 
                     27: static void _double(Request& r, Array *) {
                     28:        Pool& pool=r.pool();
                     29:        VDouble *vdouble=static_cast<VDouble *>(r.self);
                     30:        Value& value=*new(pool) VDouble(pool, vdouble->get_double());
1.3       paf        31:        r.wcontext->write(value, String::Untaint_lang::NO /*always object, not string*/);
1.1       paf        32: }
                     33: 
                     34: static void _inc(Request& r, Array *params) {
                     35:        VDouble *vdouble=static_cast<VDouble *>(r.self);
                     36:        double increment=params->size()?static_cast<Value *>(params->get(0))->get_double():1;
                     37:        vdouble->inc(increment);
                     38: }
                     39: 
1.2       paf        40: void initialize_double_class(Pool& pool, VClass& vclass) {
1.1       paf        41:        // ^double.int[]
                     42:        String& INT_NAME=*new(pool) String(pool);
                     43:        INT_NAME.APPEND_CONST("int");
                     44: 
                     45:        Method& INT_METHOD=*new(pool) Method(pool,
                     46:                INT_NAME,
                     47:                0, 0, // min,max numbered_params_count
                     48:                0/*params_names*/, 0/*locals_names*/,
                     49:                0/*parser_code*/, _int
                     50:        );
1.2       paf        51:        vclass.add_method(INT_NAME, INT_METHOD);
1.1       paf        52: 
                     53:        // ^double.double[]
                     54:        String& DOUBLE_NAME=*new(pool) String(pool);
                     55:        DOUBLE_NAME.APPEND_CONST("double");
                     56: 
                     57:        Method& DOUBLE_METHOD=*new(pool) Method(pool,
                     58:                DOUBLE_NAME,
                     59:                0, 0, // min,max numbered_params_count
                     60:                0/*params_names*/, 0/*locals_names*/,
                     61:                0/*parser_code*/, _double
                     62:        );
1.2       paf        63:        vclass.add_method(DOUBLE_NAME, DOUBLE_METHOD);
1.1       paf        64: 
                     65:        // ^double.inc[] ^double.inc[offset]
                     66:        String& INC_NAME=*new(pool) String(pool);
                     67:        INC_NAME.APPEND_CONST("inc");
                     68: 
                     69:        Method& INC_METHOD=*new(pool) Method(pool,
                     70:                INC_NAME,
                     71:                0, 1, // min,max numbered_params_count
                     72:                0/*params_names*/, 0/*locals_names*/,
                     73:                0/*parser_code*/, _inc
                     74:        );
1.2       paf        75:        vclass.add_method(INC_NAME, INC_METHOD);
1.1       paf        76: }
                     77: 

E-mail: