Annotation of parser3/src/classes/string.C, revision 1.4

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

E-mail: