Annotation of parser3/src/classes/string.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 "_string.h"
        !             7: #include "pa_vdouble.h"
        !             8: #include "pa_vint.h"
        !             9: 
        !            10: // global var
        !            11: 
        !            12: VClass *string_class;
        !            13: 
        !            14: // methods
        !            15: 
        !            16: static void _length(Request& r, Array *) {
        !            17:        Pool& pool=r.pool();
        !            18:        Value& value=*new(pool) VDouble(pool, r.self->as_string().size());
        !            19:        r.wcontext->write(value);
        !            20: }
        !            21: 
        !            22: static void _int(Request& r, Array *) {
        !            23:        Pool& pool=r.pool();
        !            24:        Value& value=*new(pool) VInt(pool, static_cast<int>(r.self->get_double()));
        !            25:        r.wcontext->write(value);
        !            26: }
        !            27: 
        !            28: static void _double(Request& r, Array *) {
        !            29:        Pool& pool=r.pool();
        !            30:        Value& value=*new(pool) VDouble(pool, r.self->get_double());
        !            31:        r.wcontext->write(value);
        !            32: }
        !            33: 
        !            34: void initialize_string_class(Pool& pool) {
        !            35:        string_class=new(pool) VClass(pool);
        !            36: 
        !            37:        // ^string.length[]
        !            38:        String& LENGTH_NAME=*new(pool) String(pool);
        !            39:        LENGTH_NAME.APPEND_CONST("length");
        !            40: 
        !            41:        Method& LENGTH_METHOD=*new(pool) Method(pool,
        !            42:                LENGTH_NAME,
        !            43:                0, 0, // min,max numbered_params_count
        !            44:                0/*params_names*/, 0/*locals_names*/,
        !            45:                0/*parser_code*/, _length
        !            46:        );
        !            47:        string_class->add_method(LENGTH_NAME, LENGTH_METHOD);
        !            48: 
        !            49:        // ^string.int[]
        !            50:        String& INT_NAME=*new(pool) String(pool);
        !            51:        INT_NAME.APPEND_CONST("int");
        !            52: 
        !            53:        Method& INT_METHOD=*new(pool) Method(pool,
        !            54:                INT_NAME,
        !            55:                0, 0, // min,max numbered_params_count
        !            56:                0/*params_names*/, 0/*locals_names*/,
        !            57:                0/*parser_code*/, _int
        !            58:        );
        !            59:        string_class->add_method(INT_NAME, INT_METHOD);
        !            60: 
        !            61:        // ^string.double[]
        !            62:        String& DOUBLE_NAME=*new(pool) String(pool);
        !            63:        DOUBLE_NAME.APPEND_CONST("double");
        !            64: 
        !            65:        Method& DOUBLE_METHOD=*new(pool) Method(pool,
        !            66:                DOUBLE_NAME,
        !            67:                0, 0, // min,max numbered_params_count
        !            68:                0/*params_names*/, 0/*locals_names*/,
        !            69:                0/*parser_code*/, _double
        !            70:        );
        !            71:        string_class->add_method(DOUBLE_NAME, DOUBLE_METHOD);
        !            72: }
        !            73: 

E-mail: