Annotation of parser3/src/classes/double.C, revision 1.3
1.1 paf 1: /*
1.3 ! paf 2: $Id: double.C,v 1.2 2001/03/10 11:03:46 paf Exp $
1.1 paf 3: */
4:
5: #include "pa_request.h"
6: #include "_double.h"
7: #include "pa_vdouble.h"
8: #include "pa_vint.h"
9:
10: // global var
11:
12: VClass *double_class;
13:
14: // methods
15:
16: static void _int(Request& r, Array *) {
17: Pool& pool=r.pool();
18: VDouble *vdouble=static_cast<VDouble *>(r.self);
19: Value& value=*new(pool) VInt(pool, static_cast<int>(vdouble->get_double()));
1.3 ! paf 20: r.wcontext->write(value, String::Untaint_lang::NO /*always object, not string*/);
1.1 paf 21: }
22:
23: static void _double(Request& r, Array *) {
24: Pool& pool=r.pool();
25: VDouble *vdouble=static_cast<VDouble *>(r.self);
26: Value& value=*new(pool) VDouble(pool, vdouble->get_double());
1.3 ! paf 27: r.wcontext->write(value, String::Untaint_lang::NO /*always object, not string*/);
1.1 paf 28: }
29:
30: static void _inc(Request& r, Array *params) {
31: VDouble *vdouble=static_cast<VDouble *>(r.self);
32: double increment=params->size()?static_cast<Value *>(params->get(0))->get_double():1;
33: vdouble->inc(increment);
34: }
35:
1.2 paf 36: void initialize_double_class(Pool& pool, VClass& vclass) {
1.1 paf 37: // ^double.int[]
38: String& INT_NAME=*new(pool) String(pool);
39: INT_NAME.APPEND_CONST("int");
40:
41: Method& INT_METHOD=*new(pool) Method(pool,
42: INT_NAME,
43: 0, 0, // min,max numbered_params_count
44: 0/*params_names*/, 0/*locals_names*/,
45: 0/*parser_code*/, _int
46: );
1.2 paf 47: vclass.add_method(INT_NAME, INT_METHOD);
1.1 paf 48:
49: // ^double.double[]
50: String& DOUBLE_NAME=*new(pool) String(pool);
51: DOUBLE_NAME.APPEND_CONST("double");
52:
53: Method& DOUBLE_METHOD=*new(pool) Method(pool,
54: DOUBLE_NAME,
55: 0, 0, // min,max numbered_params_count
56: 0/*params_names*/, 0/*locals_names*/,
57: 0/*parser_code*/, _double
58: );
1.2 paf 59: vclass.add_method(DOUBLE_NAME, DOUBLE_METHOD);
1.1 paf 60:
61: // ^double.inc[] ^double.inc[offset]
62: String& INC_NAME=*new(pool) String(pool);
63: INC_NAME.APPEND_CONST("inc");
64:
65: Method& INC_METHOD=*new(pool) Method(pool,
66: INC_NAME,
67: 0, 1, // min,max numbered_params_count
68: 0/*params_names*/, 0/*locals_names*/,
69: 0/*parser_code*/, _inc
70: );
1.2 paf 71: vclass.add_method(INC_NAME, INC_METHOD);
1.1 paf 72: }
73:
E-mail: