Annotation of parser3/src/classes/bool.C, revision 1.1
1.1 ! misha 1: /** @file
! 2: Parser: @b int parser class.
! 3:
! 4: Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com)
! 5: Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
! 6: */
! 7:
! 8: static const char * const IDENT_INT_C="$Date: 2005/08/26 11:12:45 $";
! 9:
! 10: #include "classes.h"
! 11: #include "pa_vmethod_frame.h"
! 12:
! 13: #include "pa_request.h"
! 14: #include "pa_vdouble.h"
! 15: #include "pa_vint.h"
! 16: #include "pa_vbool.h"
! 17:
! 18: // externs
! 19:
! 20: void _string_format(Request& r, MethodParams&);
! 21:
! 22: // class
! 23:
! 24: class MBool: public Methoded {
! 25: public:
! 26: MBool();
! 27: public: // Methoded
! 28: bool used_directly() { return true; }
! 29: };
! 30:
! 31: // global variable
! 32:
! 33: DECLARE_CLASS_VAR(bool, new MBool, 0);
! 34:
! 35: // methods
! 36:
! 37: static void _int(Request& r, MethodParams& params) {
! 38: // just checking (default) syntax validity, never really using it here, just for string.int compatibility
! 39: if(params.count()>0)
! 40: params.as_int(0, "default must be int", r);
! 41:
! 42: VBool& vbool=GET_SELF(r, VBool);
! 43: r.write_no_lang(*new VInt(vbool.as_bool()));
! 44: }
! 45:
! 46: static void _double(Request& r, MethodParams& params) {
! 47: // just checking (default) syntax validity, never really using it here, just for string.double compatibility
! 48: if(params.count()>0)
! 49: params.as_double(0, "default must be double", r);
! 50:
! 51: VBool& vbool=GET_SELF(r, VBool);
! 52: r.write_no_lang(*new VDouble(vbool.as_bool()));
! 53: }
! 54:
! 55: static void _bool(Request& r, MethodParams& params) {
! 56: // just checking (default) syntax validity, never really using it here, just for string.bool compatibility
! 57: if(params.count()>0)
! 58: params.as_bool(0, "default must be bool", r);
! 59:
! 60: VBool& vbool=GET_SELF(r, VBool);
! 61: r.write_no_lang(*new VBool(vbool));
! 62: }
! 63:
! 64: //typedef void (*vbool_op_func_ptr)(VBool& vbool, double param);
! 65:
! 66: //static void vbool_op(Request& r, MethodParams& params,
! 67: // vbool_op_func_ptr func) {
! 68: // VBool& vbool=GET_SELF(r, VBool);
! 69: // double param=params.count()?params.as_bool(0, "param must be bool", r):1;
! 70: // (*func)(vbool, param);
! 71: //}
! 72:
! 73: // constructor
! 74:
! 75: MBool::MBool(): Methoded("bool") {
! 76: // ^bool.int[]
! 77: add_native_method("int", Method::CT_DYNAMIC, _int, 0, 1);
! 78: // ^bool.double[]
! 79: add_native_method("double", Method::CT_DYNAMIC, _double, 0, 1);
! 80: // ^bool.bool[]
! 81: add_native_method("bool", Method::CT_DYNAMIC, _bool, 0, 1);
! 82: }
E-mail: