Changeset 631 for trunk

Show
Ignore:
Timestamp:
08/15/08 13:23:09 (3 months ago)
Author:
weyrick
Message:

resource: the forgotten php type

Files:

Legend:

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

    r618 r631  
    66 
    77set(RUNTIME_SRC_FILES 
     8  pResource.cpp 
    89  pHash.cpp 
    910  pObject.cpp 
  • trunk/rphp/runtime/include/pTypes.h

    r619 r631  
    2626#include "pHash.h" 
    2727#include "pObject.h" 
     28#include "pResource.h" 
    2829 
    2930U_NAMESPACE_BEGIN 
     
    7677        pVarType operator()(const pObjectP &h) const { 
    7778            return pVarObjectType; 
     79        } 
     80 
     81        pVarType operator()(const pResourceP &h) const { 
     82            return pVarResourceType; 
    7883        } 
    7984 
     
    128133        } 
    129134 
     135        void operator()(pResourceP &h) const { 
     136            // TODO: return static resource count 
     137            var = 0l; 
     138        } 
     139 
    130140        void operator()(pVarRef &r) const { 
    131141            // unbox 
     
    172182            // TODO: toString 
    173183            var = pBString("object"); 
     184        } 
     185 
     186        void operator()(pResourceP &h) const { 
     187            var = pBString("resource"); 
    174188        } 
    175189 
  • trunk/rphp/runtime/include/pVar.h

    r629 r631  
    2525#include <boost/shared_ptr.hpp> 
    2626#include <unicode/unistr.h> 
    27 #include <unicode/ustream.h> 
    2827#include <iostream> 
    2928 
     
    6261    typedef boost::shared_ptr<pObject> pObjectP; 
    6362 
     63    // php resources 
     64    class pResource; 
     65    typedef boost::shared_ptr<pResource> pResourceP; 
     66 
    6467    // base variant that represents a php variable 
    65     typedef boost::variant< pTriState, pInt, pFloat, pBString, pUStringP, pHashP, pObjectP > pVarBase; 
     68    typedef boost::variant< pTriState, pInt, pFloat, pBString, pUStringP, pHashP, pObjectP, pResourceP > pVarBase; 
    6669 
    6770    // reference to a pvarBase, i.e. a container for pvar variables 
    68     // shared_ptr maintains a reference count and guarantees proper destruction 
    6971    typedef boost::shared_ptr<pVarBase> pVarRef; 
    7072 
    7173    // full pvar definition: a variant that can hold a base type or a reference 
    72     typedef boost::variant< pTriState, pInt, pFloat, pBString, pUStringP, pHashP, pObjectP, pVarRef > pVar; 
     74    typedef boost::variant< pTriState, pInt, pFloat, pBString, pUStringP, pHashP, pObjectP, pResourceP, pVarRef > pVar; 
    7375    typedef boost::shared_ptr<pVar> pVarP; 
    7476 
     
    8385        pVarHashType, 
    8486        pVarObjectType, 
     87        pVarResourceType, 
    8588        pVarRefType 
    8689    } pVarType; 
  • trunk/rphp/runtime/pHash.cpp

    r617 r631  
    1818 
    1919#include <iostream> 
     20#include <unicode/ustream.h> 
    2021#include "pHash.h" 
    2122 
  • trunk/rphp/runtime/test/pvarTestCase.cpp

    r600 r631  
    5757    int operator()(const rphp::pObjectP &h) const { 
    5858        std::cout << "i see a pObject" << std::endl; 
     59        return 0; 
     60    } 
     61 
     62    int operator()(const rphp::pResourceP &h) const { 
     63        std::cout << "i see a resource" << std::endl; 
    5964        return 0; 
    6065    } 
     
    95100    std::cout << "pObject: " << sizeof(rphp::pObject) << std::endl; 
    96101    std::cout << "pObjectP: " << sizeof(rphp::pObjectP) << std::endl; 
     102    std::cout << "pResource: " << sizeof(rphp::pResource) << std::endl; 
     103    std::cout << "pResourceP: " << sizeof(rphp::pResourceP) << std::endl; 
    97104    std::cout << "pVarBase: " << sizeof(rphp::pVarBase) << std::endl; 
    98105    std::cout << "pVarRef: " << sizeof(rphp::pVarRef) << std::endl; 
     
    135142        std::cout << "the bool was false" << std::endl; 
    136143    } 
    137      
     144 
    138145    u = rphp::pFalse; 
    139146