Changeset 586
- Timestamp:
- 07/11/08 13:49:45 (4 months ago)
- Files:
-
- trunk/rphp/runtime/CMakeLists.txt (modified) (1 diff)
- trunk/rphp/runtime/cowptr.h (added)
- trunk/rphp/runtime/rphp_hash.cpp (modified) (1 diff)
- trunk/rphp/runtime/rphp_hash.h (modified) (2 diffs)
- trunk/rphp/runtime/test (added)
- trunk/rphp/runtime/test/CMakeLists.txt (added)
- trunk/rphp/runtime/test/HashTestCase.cpp (added)
- trunk/rphp/runtime/test/HashTestCase.h (added)
- trunk/rphp/runtime/test/Main.cpp (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/rphp/runtime/CMakeLists.txt
r585 r586 16 16 add_library( rphp_runtime SHARED ${RUNTIME_SRC_FILES} ) 17 17 18 # test app 19 set(TEST_SRC_FILES 20 var-test.cpp 21 ) 22 23 add_executable( var-test ${TEST_SRC_FILES} ) 18 # test apps 19 add_executable( var-test var-test.cpp ) 24 20 target_link_libraries( var-test rphp_runtime ${ICU_LIBRARIES} ${ICU_IO_LIBRARIES} ) 25 21 22 add_executable( hash-test hash-test.cpp ) 23 target_link_libraries( hash-test rphp_runtime ${ICU_LIBRARIES} ${ICU_IO_LIBRARIES} ) 24 trunk/rphp/runtime/rphp_hash.cpp
r585 r586 23 23 void phash::insert(const bstring &key, pvar data) { 24 24 25 hashData .insert(_dataContainer(key, data));25 hashData->insert(_dataContainer(key, data)); 26 26 27 27 } 28 29 void phash::varDump() { 30 31 32 std::cout << "array(" << hashData->size() << ") {" << std::endl; 33 34 seq_index& ot = get<1>(*hashData); 35 36 for (seq_index::iterator it = ot.begin(); it!=ot.end(); it++) { 37 std::cout << " ['" << (*it).key << "'] => " << (*it).data << std::endl; 38 } 39 40 std::cout << "}" << std::endl; 41 42 } 43 28 44 29 45 std::ostream& operator << (std::ostream& os, const rphp::phash& h) trunk/rphp/runtime/rphp_hash.h
r585 r586 24 24 #include <boost/multi_index/member.hpp> 25 25 #include <boost/multi_index/sequenced_index.hpp> 26 27 26 #include <iostream> 28 27 28 #include "cowptr.h" 29 29 #include "rphp_pvar.h" 30 30 … … 61 61 class phash { 62 62 private: 63 stableHashhashData;63 CowPtr< stableHash > hashData; 64 64 public: 65 65 66 phash() { 67 hashData.insert(_dataContainer("foo", pvar(pint(5)))); 68 hashData.insert(_dataContainer("bar", pvar(bstring("some string val")))); 69 hashData.insert(_dataContainer("baz", pvar(pfloat(5.3212)))); 70 } 71 66 phash() : hashData(new stableHash()) { std::cout << "creating fresh php_hash" << std::endl; } 67 /* 68 phash(phash const& p) { 69 std::cout << "phash copy construct" << std::endl; 70 hashData = p.hashData; 71 } 72 */ 72 73 void insert(const bstring &key, pvar data); 73 74 74 void varDump() { 75 std::cout << "array(" << hashData.size() << ") {" << std::endl; 76 seq_index& ot = get<1>(hashData); 77 for (seq_index::iterator it = ot.begin(); it!=ot.end(); it++) { 78 std::cout << " ['" << (*it).key << "'] => " << (*it).data << std::endl; 79 } 80 std::cout << "}" << std::endl; 81 } 75 void varDump(); 82 76 83 int getSize() const { return hashData .size(); }77 int getSize() const { return hashData->size(); } 84 78 85 79 ~phash() { std::cout << "destorying php_hash" << std::endl; }
