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

1.1       paf         1: /*
1.2     ! paf         2: $Id: int.C,v 1.1 2001/03/09 08:19:46 paf Exp $
1.1       paf         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: 
1.2     ! paf        37: void initialize_int_class(Pool& pool, VClass& vclass) {
1.1       paf        38:        // ^int.int[]
                     39:        String& INT_NAME=*new(pool) String(pool);
                     40:        INT_NAME.APPEND_CONST("int");
                     41: 
                     42:        Method& INT_METHOD=*new(pool) Method(pool,
                     43:                INT_NAME,
                     44:                0, 0, // min,max numbered_params_count
                     45:                0/*params_names*/, 0/*locals_names*/,
                     46:                0/*parser_code*/, _int
                     47:        );
1.2     ! paf        48:        vclass.add_method(INT_NAME, INT_METHOD);
1.1       paf        49: 
                     50:        // ^int.int[]
                     51:        String& DOUBLE_NAME=*new(pool) String(pool);
                     52:        DOUBLE_NAME.APPEND_CONST("int");
                     53: 
                     54:        Method& DOUBLE_METHOD=*new(pool) Method(pool,
                     55:                DOUBLE_NAME,
                     56:                0, 0, // min,max numbered_params_count
                     57:                0/*params_names*/, 0/*locals_names*/,
                     58:                0/*parser_code*/, _int
                     59:        );
1.2     ! paf        60:        vclass.add_method(DOUBLE_NAME, DOUBLE_METHOD);
1.1       paf        61: 
                     62:        // ^int.inc[] ^int.inc[offset]
                     63:        String& INC_NAME=*new(pool) String(pool);
                     64:        INC_NAME.APPEND_CONST("inc");
                     65: 
                     66:        Method& INC_METHOD=*new(pool) Method(pool,
                     67:                INC_NAME,
                     68:                0, 1, // min,max numbered_params_count
                     69:                0/*params_names*/, 0/*locals_names*/,
                     70:                0/*parser_code*/, _inc
                     71:        );
1.2     ! paf        72:        vclass.add_method(INC_NAME, INC_METHOD);
1.1       paf        73: }
                     74: 

E-mail: