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

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

E-mail: