Annotation of parser3/src/classes/double.C, revision 1.13
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.13 ! paf 6: $Id: double.C,v 1.12 2001/03/12 21:54:18 paf Exp $
1.1 paf 7: */
8:
9: #include "pa_request.h"
10: #include "_double.h"
11: #include "pa_vdouble.h"
12: #include "pa_vint.h"
1.13 ! paf 13: #include "_string.h"
1.1 paf 14:
15: // global var
16:
17: VClass *double_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: VDouble *vdouble=static_cast<VDouble *>(r.self);
1.11 paf 24: Value& value=*new(pool) VInt(pool, (int)vdouble->get_double());
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: VDouble *vdouble=static_cast<VDouble *>(r.self);
31: Value& value=*new(pool) VDouble(pool, vdouble->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: VDouble *vdouble=static_cast<VDouble *>(r.self);
1.6 paf 37: double increment=params->size()?
1.10 paf 38: r.process(
1.6 paf 39: *static_cast<Value *>(params->get(0)),
40: 0/*no name*/,
1.8 paf 41: false/*don't intercept string*/).get_double():1;
1.1 paf 42: vdouble->inc(increment);
43: }
44:
1.2 paf 45: void initialize_double_class(Pool& pool, VClass& vclass) {
1.9 paf 46: // ^double.int[]
47: vclass.add_native_method("int", _int, 0, 0);
48:
49: // ^double.double[]
50: vclass.add_native_method("double", _double, 0, 0);
51:
52: // ^double.inc[]
53: // ^double.inc[offset]
54: vclass.add_native_method("inc", _inc, 0, 1);
1.12 paf 55:
1.13 ! paf 56: // ^double.format[]
! 57: vclass.add_native_method("format", _string_format, 1, 1);
1.1 paf 58: }
E-mail: