Changeset 600
- Timestamp:
- 07/22/08 05:33:58 (4 months ago)
- Files:
-
- trunk/rphp/runtime/include/pHash.h (modified) (1 diff)
- trunk/rphp/runtime/include/pTypes.h (modified) (1 diff)
- trunk/rphp/runtime/pTypes.cpp (modified) (1 diff)
- trunk/rphp/runtime/test/phashTestCase.cpp (modified) (2 diffs)
- trunk/rphp/runtime/test/phashTestCase.h (modified) (1 diff)
- trunk/rphp/runtime/test/pvarTestCase.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/rphp/runtime/include/pHash.h
r599 r600 145 145 return (*k).pData; 146 146 } 147 pVarP operator[] ( const pInt &key ) { 148 stableHash::iterator k = hashData.find(key); 149 if (k == hashData.end()) 150 return pVarP(); 151 else 152 return (*k).pData; 153 } 147 154 148 155 trunk/rphp/runtime/include/pTypes.h
r593 r600 136 136 // get the boolean value of a pVar. does NOT convert so pVar 137 137 // must already be a pTriState 138 inline pTriState pVar_getVal_ bool(const pVar &p) {138 inline pTriState pVar_getVal_pBool(const pVar &p) { 139 139 return boost::get<rphp::pTriState>(p); 140 140 } 141 141 142 inline long pVar_getVal_ int(const pVar &p) {142 inline long pVar_getVal_pInt(const pVar &p) { 143 143 return boost::get<pInt>(p); 144 144 } 145 146 inline pBString pVar_getVal_pBString(const pVar &p) { 147 return boost::get<pBString>(p); 148 } 149 150 inline pUStringP pVar_getVal_pUString(const pVar &p) { 151 return boost::get<pUStringP>(p); 152 } 145 153 146 inline pVarRef pVar_getVal_ ref(const pVar &p) {154 inline pVarRef pVar_getVal_pRef(const pVar &p) { 147 155 return boost::get<pVarRef>(p); 148 156 } trunk/rphp/runtime/pTypes.cpp
r593 r600 47 47 r = pVar_castToNumber(rhs); 48 48 //std::cout << "pVar_add: r is " << r << std::endl; 49 result = pVar_getVal_ int(l) + pVar_getVal_int(r);49 result = pVar_getVal_pInt(l) + pVar_getVal_pInt(r); 50 50 //std::cout << "pVar_add: result is " << result << std::endl; 51 51 } trunk/rphp/runtime/test/phashTestCase.cpp
r599 r600 12 12 { 13 13 14 rphp::pVarP lu; 15 16 // string key 14 17 rphp::pVarP int1(new rphp::pVar(rphp::pInt(971))); 15 16 // php hash 17 rphp::pHash h; 18 h.insert("var-test", int1); 19 20 //std::cout << *(h["var-test"]) << std::endl; 21 rphp::pVarP int2 = h["var-test"]; 22 23 CPPUNIT_ASSERT( pVar_getVal_int(*int1) == pVar_getVal_int(*int2) ); 24 25 // not found 26 int2 = h["foo"]; 27 CPPUNIT_ASSERT( int2.get() == 0 ); 18 testHash.insert("var-test", int1); 19 CPPUNIT_ASSERT( testHash.getSize() == 1 ); 28 20 29 21 // int key 30 22 rphp::pVarP str1(new rphp::pVar(rphp::pBString("int key 1"))); 31 h.insert(55, str1); 32 23 testHash.insert(55, str1); 24 CPPUNIT_ASSERT( testHash.getSize() == 2 ); 25 33 26 // next key 34 27 rphp::pVarP str2(new rphp::pVar(rphp::pBString("next key"))); 35 h.insertNext(str2); 36 37 h.varDump(); 28 testHash.insertNext(str2); 29 CPPUNIT_ASSERT( testHash.getSize() == 3 ); 30 31 //testHash.varDump(); 32 33 // string key 34 lu = testHash["var-test"]; 35 CPPUNIT_ASSERT( pVar_getVal_pInt(*int1) == pVar_getVal_pInt(*lu) ); 36 37 // int key 38 lu = testHash[55]; 39 CPPUNIT_ASSERT( pVar_getVal_pBString(*str1) == pVar_getVal_pBString(*lu) ); 40 41 // next key 42 lu = testHash[56]; 43 CPPUNIT_ASSERT( pVar_getVal_pBString(*str2) == pVar_getVal_pBString(*lu) ); 44 45 // not found 46 lu = testHash["foo"]; 47 CPPUNIT_ASSERT( lu.get() == 0 ); 38 48 39 49 } … … 43 53 { 44 54 45 m_value1 = 2.0;46 m_value2 = 3.0;47 55 48 56 } 49 57 */ 50 58 59 trunk/rphp/runtime/test/phashTestCase.h
r589 r600 16 16 CPPUNIT_TEST_SUITE_END(); 17 17 18 /*19 18 protected: 20 double m_value1; 21 double m_value2; 22 */ 19 rphp::pHash testHash; 23 20 24 /* 25 public: 26 void setUp(); 27 */ 21 //public: 22 // void setUp(); 28 23 29 24 protected: 30 25 void basic(); 26 31 27 }; 32 28 trunk/rphp/runtime/test/pvarTestCase.cpp
r593 r600 69 69 70 70 rphp::pVarRef rval; 71 if (rval = rphp::pVar_getVal_ ref(r)) {71 if (rval = rphp::pVar_getVal_pRef(r)) { 72 72 *rval = rphp::pBString("changed the ref to a string!"); 73 73 } … … 129 129 result = boost::apply_visitor( my_visitor(), u ); 130 130 131 if (rphp::pVar_getVal_ bool(u)) {131 if (rphp::pVar_getVal_pBool(u)) { 132 132 std::cout << "the bool was true" << std::endl; 133 133 } … … 141 141 result = boost::apply_visitor( my_visitor(), u ); 142 142 143 if (rphp::pVar_getVal_ bool(u)) {143 if (rphp::pVar_getVal_pBool(u)) { 144 144 std::cout << "the bool was true" << std::endl; 145 145 }
