Annotation of parser3/src/classes/unknown.C, revision 1.4
1.1 paf 1: /** @file
2: Parser: @b unknown parser class.
3:
4: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
5:
6: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
7:
1.4 ! paf 8: $Id: unknown.C,v 1.3 2001/04/28 08:43:48 paf Exp $
1.1 paf 9: */
10:
1.4 ! paf 11: #include "pa_methoded.h"
1.1 paf 12: #include "pa_request.h"
13: #include "pa_vint.h"
14: #include "pa_vdouble.h"
15: #include "pa_vunknown.h"
16:
1.3 paf 17: // defines
1.1 paf 18:
1.3 paf 19: #define UNKNOWN_CLASS_NAME "UNKNOWN"
20:
21: // class
22:
23: class MUnknown : public Methoded {
24: public:
25: MUnknown(Pool& pool);
26: bool used_directly() { return false; }
27: };
1.1 paf 28:
29: // methods
30:
1.2 paf 31: static void _int(Request& r, const String&, MethodParams *) {
1.1 paf 32: Pool& pool=r.pool();
33: VInt *vunknown=static_cast<VInt *>(r.self);
34: Value& value=*new(pool) VInt(pool, (int)vunknown->as_double());
35: r.write_no_lang(value);
36: }
37:
1.2 paf 38: static void _double(Request& r, const String&, MethodParams *) {
1.1 paf 39: Pool& pool=r.pool();
40: VInt *vunknown=static_cast<VInt *>(r.self);
41: Value& value=*new(pool) VDouble(pool, vunknown->as_double());
42: r.write_no_lang(value);
43: }
44:
1.3 paf 45: // constructor
46:
47: MUnknown::MUnknown(Pool& apool) : Methoded(apool) {
48: set_name(*NEW String(pool(), UNKNOWN_CLASS_NAME));
1.1 paf 49:
50:
51: // ^unknown.int[]
1.3 paf 52: add_native_method("int", Method::CT_DYNAMIC, _int, 0, 0);
1.1 paf 53:
54: // ^unknown.double[]
1.3 paf 55: add_native_method("double", Method::CT_DYNAMIC, _double, 0, 0);
56: }
57:
58: // global variable
59:
60: Methoded *unknown_class;
61:
62: // creator
63:
64: Methoded *MUnknown_create(Pool& pool) {
65: return unknown_class=new(pool) MUnknown(pool);
1.1 paf 66: }
E-mail: