Annotation of parser3/src/classes/unknown.C, revision 1.6
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.6 ! paf 8: $Id: unknown.C,v 1.5 2001/04/28 15:22:39 paf Exp $
1.1 paf 9: */
10:
1.5 paf 11: #include "classes.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);
1.6 ! paf 26: public: // Methoded
1.3 paf 27: bool used_directly() { return false; }
28: };
1.1 paf 29:
30: // methods
31:
1.2 paf 32: static void _int(Request& r, const String&, MethodParams *) {
1.1 paf 33: Pool& pool=r.pool();
34: VInt *vunknown=static_cast<VInt *>(r.self);
35: Value& value=*new(pool) VInt(pool, (int)vunknown->as_double());
36: r.write_no_lang(value);
37: }
38:
1.2 paf 39: static void _double(Request& r, const String&, MethodParams *) {
1.1 paf 40: Pool& pool=r.pool();
41: VInt *vunknown=static_cast<VInt *>(r.self);
42: Value& value=*new(pool) VDouble(pool, vunknown->as_double());
43: r.write_no_lang(value);
44: }
45:
1.3 paf 46: // constructor
47:
48: MUnknown::MUnknown(Pool& apool) : Methoded(apool) {
49: set_name(*NEW String(pool(), UNKNOWN_CLASS_NAME));
1.1 paf 50:
51:
52: // ^unknown.int[]
1.3 paf 53: add_native_method("int", Method::CT_DYNAMIC, _int, 0, 0);
1.1 paf 54:
55: // ^unknown.double[]
1.3 paf 56: add_native_method("double", Method::CT_DYNAMIC, _double, 0, 0);
57: }
58:
59: // global variable
60:
61: Methoded *unknown_class;
62:
63: // creator
64:
65: Methoded *MUnknown_create(Pool& pool) {
66: return unknown_class=new(pool) MUnknown(pool);
1.1 paf 67: }
E-mail: