Annotation of parser3/src/classes/unknown.C, revision 1.2.4.1
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.2.4.1 ! paf 8: $Id: unknown.C,v 1.2 2001/04/15 13:12:18 paf Exp $
1.1 paf 9: */
10:
1.2.4.1 ! 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.2.4.1 ! paf 17: // defines
1.1 paf 18:
1.2.4.1 ! 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.2.4.1 ! paf 45: // constructor
1.1 paf 46:
1.2.4.1 ! paf 47: MUnknown::MUnknown(Pool& pool, VStateless_class& vclass) {
! 48: set_name(new(pool) String(pool, UNKNOWN_CLASS_NAME));
1.1 paf 49:
50: // ^unknown.int[]
51: vclass.add_native_method("int", Method::CT_DYNAMIC, _int, 0, 0);
52:
53: // ^unknown.double[]
54: vclass.add_native_method("double", Method::CT_DYNAMIC, _double, 0, 0);
1.2.4.1 ! paf 55: }
! 56: // global variable
! 57:
! 58: Methoded *unknown_class;
! 59:
! 60: // creator
! 61:
! 62: Methoded *MTable_create(Pool& pool) {
! 63: return unknown_class=new(pool) MUnknown(pool);
1.1 paf 64: }
E-mail: