Annotation of parser3/src/classes/int.C, revision 1.1

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

E-mail: