Annotation of parser3/src/classes/bool.C, revision 1.2

1.1       misha       1: /** @file
                      2:        Parser: @b int parser class.
                      3: 
1.2     ! misha       4:        Copyright (c) 2001-2009 ArtLebedev Group (http://www.artlebedev.com)
1.1       misha       5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
                      6: */
                      7: 
1.2     ! misha       8: static const char * const IDENT_INT_C="$Date: 2007/02/03 18:08:38 $";
1.1       misha       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: 
1.2     ! misha      60:        r.write_no_lang(GET_SELF(r, VBool));
1.1       misha      61: }
                     62: 
                     63: //typedef void (*vbool_op_func_ptr)(VBool& vbool, double param);
                     64: 
                     65: //static void vbool_op(Request& r, MethodParams& params, 
                     66: //                                      vbool_op_func_ptr func) {
                     67: //     VBool& vbool=GET_SELF(r, VBool);
                     68: //     double param=params.count()?params.as_bool(0, "param must be bool", r):1;
                     69: //     (*func)(vbool, param);
                     70: //}
                     71: 
                     72: // constructor
                     73: 
                     74: MBool::MBool(): Methoded("bool") {
                     75:        // ^bool.int[]
                     76:        add_native_method("int", Method::CT_DYNAMIC, _int, 0, 1);
                     77:        // ^bool.double[]
                     78:        add_native_method("double", Method::CT_DYNAMIC, _double, 0, 1);
                     79:        // ^bool.bool[]
                     80:        add_native_method("bool", Method::CT_DYNAMIC, _bool, 0, 1);
                     81: }

E-mail: