Changeset 586

Show
Ignore:
Timestamp:
07/11/08 13:49:45 (4 months ago)
Author:
weyrick
Message:

real rough and crusty framework for testing, along with a copy-on-write template to play with

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/rphp/runtime/CMakeLists.txt

    r585 r586  
    1616add_library( rphp_runtime SHARED ${RUNTIME_SRC_FILES} ) 
    1717 
    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 
     19add_executable( var-test var-test.cpp ) 
    2420target_link_libraries( var-test  rphp_runtime ${ICU_LIBRARIES} ${ICU_IO_LIBRARIES} ) 
    2521 
     22add_executable( hash-test hash-test.cpp ) 
     23target_link_libraries( hash-test  rphp_runtime ${ICU_LIBRARIES} ${ICU_IO_LIBRARIES} ) 
     24 
  • trunk/rphp/runtime/rphp_hash.cpp

    r585 r586  
    2323void phash::insert(const bstring &key, pvar data) { 
    2424 
    25     hashData.insert(_dataContainer(key, data)); 
     25    hashData->insert(_dataContainer(key, data)); 
    2626 
    2727} 
     28 
     29void 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 
    2844 
    2945std::ostream& operator << (std::ostream& os, const rphp::phash& h) 
  • trunk/rphp/runtime/rphp_hash.h

    r585 r586  
    2424#include <boost/multi_index/member.hpp> 
    2525#include <boost/multi_index/sequenced_index.hpp> 
    26  
    2726#include <iostream> 
    2827 
     28#include "cowptr.h" 
    2929#include "rphp_pvar.h" 
    3030 
     
    6161class phash { 
    6262    private: 
    63         stableHash hashData; 
     63        CowPtr< stableHash > hashData; 
    6464    public: 
    6565         
    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*/ 
    7273        void insert(const bstring &key, pvar data); 
    7374 
    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(); 
    8276         
    83         int getSize() const { return hashData.size(); } 
     77        int getSize() const { return hashData->size(); } 
    8478         
    8579        ~phash() { std::cout << "destorying php_hash" << std::endl; }