Diff for /parser3/src/classes/int.C between versions 1.38 and 1.49.2.1

version 1.38, 2001/11/05 11:46:21 version 1.49.2.1, 2003/01/31 12:34:26
Line 1 Line 1
 /** @file  /** @file
         Parser: @b int parser class.          Parser: @b int parser class.
   
         Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)          Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com)
         Author: Alexander Petrosyan <paf@design.ru> (http://paf.design.ru)          Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
   
         $Id$  
 */  */
   
   static const char* IDENT_INT_C="$Date$";
   
 #include "classes.h"  #include "classes.h"
 #include "pa_request.h"  #include "pa_request.h"
 #include "pa_vdouble.h"  #include "pa_vdouble.h"
Line 16 Line 16
   
 void _string_format(Request& r, const String& method_name, MethodParams *);  void _string_format(Request& r, const String& method_name, MethodParams *);
   
 // defines  
   
 #define INT_CLASS_NAME "int"  
   
 // class  // class
   
 class MInt : public Methoded {  class MInt : public Methoded {
Line 31  public: // Methoded Line 27  public: // Methoded
   
 // methods  // methods
   
 static void _int(Request& r, const String& method_name, MethodParams *) {  static void _int(Request& r, const String& method_name, MethodParams *params) {
         Pool& pool=r.pool();          Pool& pool=r.pool();
         VInt *vint=static_cast<VInt *>(r.self);          // just checking (default) syntax validity, never really using it  here, just for string.int compatibility
         Value& result=*new(pool) VInt(pool, vint->get_int());          if(params->size()>0)
         result.set_name(method_name);                  params->as_junction(0, "default must be int");
         r.write_no_lang(result);  
           VInt *vint=static_cast<VInt *>(r.get_self());
           r.write_no_lang(*new(pool) VInt(pool, vint->get_int()));
 }  }
   
 static void _double(Request& r, const String& method_name, MethodParams *) {  static void _double(Request& r, const String& method_name, MethodParams *params) {
         Pool& pool=r.pool();          Pool& pool=r.pool();
         VInt *vint=static_cast<VInt *>(r.self);          // just checking (default) syntax validity, never really using it  here, just for string.doube compatibility
         Value& result=*new(pool) VDouble(pool, vint->as_double());          if(params->size()>0)
         result.set_name(method_name);                  params->as_junction(0, "default must be double");
         r.write_no_lang(result);  
           VInt *vint=static_cast<VInt *>(r.get_self());
           r.write_no_lang(*new(pool) VDouble(pool, vint->as_double()));
 }  }
   
 typedef void (*vint_op_func_ptr)(VInt& vint, double param);  typedef void (*vint_op_func_ptr)(VInt& vint, double param);
Line 57  static void __mod(VInt& vint, double par Line 57  static void __mod(VInt& vint, double par
   
 static void vint_op(Request& r, MethodParams *params,   static void vint_op(Request& r, MethodParams *params, 
                                          vint_op_func_ptr func) {                                           vint_op_func_ptr func) {
         VInt *vint=static_cast<VInt *>(r.self);          VInt *vint=static_cast<VInt *>(r.get_self());
         double param=params->size()?params->as_double(0, "param must be numerical", r):1;          double param=params->size()?params->as_double(0, "param must be numerical", r):1;
         (*func)(*vint, param);          (*func)(*vint, param);
 }  }
Line 83  static void _sql(Request& r, const Strin Line 83  static void _sql(Request& r, const Strin
                 val=string->as_int();                  val=string->as_int();
         else          else
                 if(default_code)                  if(default_code)
                         val=r.process(*default_code).as_int();                          val=r.process_to_value(*default_code).as_int();
                 else {                  else {
                         throw Exception(0, 0,                          throw Exception("parser.runtime",
                                 &method_name,                                  &method_name,
                                 "produced no result, but no default option specified");                                  "produced no result, but no default option specified");
                         val=0; //calm, compiler                          val=0; //calm, compiler
                 }                  }
         VInt& result=*new(pool) VInt(pool, val);          r.write_no_lang(*new(pool) VInt(pool, val));
         result.set_name(method_name);  
         r.write_assign_lang(result);  
 }  }
   
 // constructor  // constructor
   
 MInt::MInt(Pool& apool) : Methoded(apool) {  MInt::MInt(Pool& apool) : Methoded(apool, "int") {
         set_name(*NEW String(pool(), INT_CLASS_NAME));  
   
   
         // ^int.int[]          // ^int.int[]
         add_native_method("int", Method::CT_DYNAMIC, _int, 0, 0);          add_native_method("int", Method::CT_DYNAMIC, _int, 0, 1);
   
         // ^int.double[]          // ^int.double[]
         add_native_method("double", Method::CT_DYNAMIC, _double, 0, 0);          add_native_method("double", Method::CT_DYNAMIC, _double, 0, 1);
   
         // ^int.inc[]           // ^int.inc[] 
         // ^int.inc[offset]          // ^int.inc[offset]

Removed from v.1.38  
changed lines
  Added in v.1.49.2.1


E-mail: