Annotation of parser3/src/classes/int.C, revision 1.12
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.12 ! paf 6: $Id: int.C,v 1.11 2001/03/12 21:17:59 paf Exp $
1.1 paf 7: */
8:
9: #include "pa_request.h"
10: #include "_int.h"
11: #include "pa_vdouble.h"
12: #include "pa_vint.h"
1.12 ! paf 13: #include "_string.h"
1.1 paf 14:
15: // global var
16:
17: VClass *int_class;
18:
19: // methods
20:
1.10 paf 21: static void _int(Request& r, const String&, Array *) {
1.1 paf 22: Pool& pool=r.pool();
23: VInt *vint=static_cast<VInt *>(r.self);
24: Value& value=*new(pool) VInt(pool, vint->get_int());
1.3 paf 25: r.wcontext->write(value, String::Untaint_lang::NO /*always object, not string*/);
1.1 paf 26: }
27:
1.10 paf 28: static void _double(Request& r, const String&, Array *) {
1.1 paf 29: Pool& pool=r.pool();
30: VInt *vint=static_cast<VInt *>(r.self);
31: Value& value=*new(pool) VDouble(pool, vint->get_double());
1.3 paf 32: r.wcontext->write(value, String::Untaint_lang::NO /*always object, not string*/);
1.1 paf 33: }
34:
1.10 paf 35: static void _inc(Request& r, const String&, Array *params) {
1.1 paf 36: VInt *vint=static_cast<VInt *>(r.self);
37: int increment=params->size()?
1.11 paf 38: (int)r.process(
1.6 paf 39: *static_cast<Value *>(params->get(0)),
40: 0/*no name*/,
1.11 paf 41: false/*don't intercept string*/).get_double():1;
1.1 paf 42: vint->inc(increment);
43: }
44:
1.2 paf 45: void initialize_int_class(Pool& pool, VClass& vclass) {
1.9 paf 46: // ^int.int[]
47: vclass.add_native_method("int", _int, 0, 0);
48:
49: // ^int.double[]
50: vclass.add_native_method("double", _double, 0, 0);
51:
52: // ^int.inc[]
53: // ^int.inc[offset]
54: vclass.add_native_method("inc", _inc, 0, 1);
1.12 ! paf 55:
! 56: // ^int.format[]
! 57: vclass.add_native_method("format", _string_format, 1, 1);
1.1 paf 58: }
E-mail: