From: <sja...@us...> - 2003-08-17 20:11:50
|
Update of /cvsroot/binaryphp/binaryphp In directory sc8-pr-cvs1:/tmp/cvs-serv29272 Modified Files: php_var.cpp php_var.hpp Log Message: Use class php_var_type. Index: php_var.cpp =================================================================== RCS file: /cvsroot/binaryphp/binaryphp/php_var.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** php_var.cpp 14 Aug 2003 16:40:17 -0000 1.27 --- php_var.cpp 17 Aug 2003 20:11:47 -0000 1.28 *************** *** 16,46 **** php_var::php_var() // Constructor { - type = PHP_NULL; // Make the var, but make it null. container = ""; } php_var::php_var(const char* str) { container = str; ! type = PHP_STRING; } php_var::php_var(double i) { - type = PHP_INT; container = doublestring(i); } php_var::php_var(int i) { - type = PHP_INT; container = intstring(i); } php_var::php_var(unsigned int i) { container = intstring(i); ! type = PHP_INT; } php_var::php_var(long i) { container = intstring(i); ! type = PHP_INT; } php_var::php_var(const php_var &temp) --- 16,46 ---- php_var::php_var() // Constructor { container = ""; + type.is_null = true; // Make the var, but make it null. } php_var::php_var(const char* str) { container = str; ! type.is_string = true; } php_var::php_var(double i) { container = doublestring(i); + type.is_int = true; } php_var::php_var(int i) { container = intstring(i); + type.is_int = true; } php_var::php_var(unsigned int i) { container = intstring(i); ! type.is_int = true; } php_var::php_var(long i) { container = intstring(i); ! type.is_int = true; } php_var::php_var(const php_var &temp) *************** *** 55,64 **** { container = str; ! type = PHP_STRING; } php_var::php_var(string str) { container = str; ! type = PHP_STRING; } php_var::php_var(bool b) --- 55,64 ---- { container = str; ! typ.is_string = true; } php_var::php_var(string str) { container = str; ! typ.is_string = true; } php_var::php_var(bool b) *************** *** 68,76 **** else container = "0"; ! type = PHP_BOOL; } php_var::operator const char*() { ! if(type == PHP_STRING || type == PHP_INT) return container.c_str(); else --- 68,76 ---- else container = "0"; ! typ.is_bool = true; } php_var::operator const char*() { ! if(type.is_string || type.is_int) return container.c_str(); else *************** *** 79,83 **** php_var::operator string() { ! if(type == PHP_STRING || type == PHP_INT) return container; else --- 79,83 ---- php_var::operator string() { ! if(type.is_string || type.is_int) return container; else *************** *** 86,90 **** php_var::operator bool() { ! if(type != PHP_BOOL || (type == PHP_BOOL && container.compare("1") == 0)) return true; return false; --- 86,90 ---- php_var::operator bool() { ! if( !type.is_bool || (type.is_bool && container.compare("1") == 0)) return true; return false; *************** *** 132,140 **** php_var &php_var::operator[](php_var subscript) { ! if(type == PHP_STRING) { // return &container[subscript]; } ! else if(type == PHP_ARRAY) { php_var key = subscript; --- 132,140 ---- php_var &php_var::operator[](php_var subscript) { ! if(type.is_string) { // return &container[subscript]; } ! else if(type.is_array) { php_var key = subscript; *************** *** 237,241 **** void php_var::operator+=(int inc) { ! if(type == PHP_INT) { container = intstring(atol(container.c_str()) + inc); --- 237,241 ---- void php_var::operator+=(int inc) { ! if(type.is_int) { container = intstring(atol(container.c_str()) + inc); *************** *** 244,258 **** void php_var::operator+=(php_var str) { ! if(str.type == PHP_INT) { container = intstring(atol(container.c_str()) + atoi(str.container.c_str())); ! if(type != PHP_INT && type != PHP_STRING) ! type = PHP_INT; } else { container += str.container; ! if(type != PHP_STRING) ! type = PHP_STRING; } } --- 244,258 ---- void php_var::operator+=(php_var str) { ! if(str.type.is_int) { container = intstring(atol(container.c_str()) + atoi(str.container.c_str())); ! if(!type.is_int && !type.is_string) ! type.is_int = true; } else { container += str.container; ! if(!type.is_string) ! type.is_string = true; } } *************** *** 271,275 **** void php_var::operator-=(int dec) { ! if(type == PHP_INT) { container = intstring(atol(container.c_str()) - dec); --- 271,275 ---- void php_var::operator-=(int dec) { ! if(type.is_int) { container = intstring(atol(container.c_str()) - dec); *************** *** 278,287 **** void php_var::operator-=(php_var i) { ! if(type == PHP_INT) container = doublestring(atof(container.c_str()) - atof(i.container.c_str())); } void php_var::to_array() { ! type = PHP_ARRAY; } template<typename T> inline T * OBJ(php_var obj) { return (reinterpret_cast<T *>(obj.res)); } --- 278,287 ---- void php_var::operator-=(php_var i) { ! if(type.is_int) container = doublestring(atof(container.c_str()) - atof(i.container.c_str())); } void php_var::to_array() { ! type.is_array = true; } template<typename T> inline T * OBJ(php_var obj) { return (reinterpret_cast<T *>(obj.res)); } Index: php_var.hpp =================================================================== RCS file: /cvsroot/binaryphp/binaryphp/php_var.hpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** php_var.hpp 14 Aug 2003 16:40:17 -0000 1.3 --- php_var.hpp 17 Aug 2003 20:11:47 -0000 1.4 *************** *** 8,18 **** #define __php_var ! #define PHP_NULL 0 ! #define PHP_STRING 1 ! #define PHP_INT 2 ! #define PHP_BOOL 3 ! #define PHP_ARRAY 4 ! #define PHP_RESOURCE 5 ! #define PHP_OBJECT 6 using namespace std; --- 8,12 ---- #define __php_var ! #include "php_var_type.hpp" using namespace std; *************** *** 84,88 **** void *obj_type; int res_type; ! int type; // Contains current type. }; php_var operator*(php_var l, php_var r); --- 78,82 ---- void *obj_type; int res_type; ! php_var_type type; // Contains current type. }; php_var operator*(php_var l, php_var r); |