diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2013-10-22 13:39:21 -0700 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2013-10-22 13:39:21 -0700 |
commit | f96fc6c53bc8bd8888aeb291441f61a65b439413 (patch) | |
tree | 030815351f20cfa6dfb36c816c5c0d737516e784 /src | |
parent | f16847ab29d474e2b20d7f8c9f3a0f229b54c850 (diff) |
Initial setup for dealing with object properties
Diffstat (limited to 'src')
-rw-r--r-- | src/base.cpp | 19 | ||||
-rw-r--r-- | src/classinfo.cpp | 9 | ||||
-rw-r--r-- | src/hashmember.cpp | 40 | ||||
-rw-r--r-- | src/includes.h | 1 | ||||
-rw-r--r-- | src/value.cpp | 11 |
5 files changed, 77 insertions, 3 deletions
diff --git a/src/base.cpp b/src/base.cpp new file mode 100644 index 0000000..60e8c2d --- /dev/null +++ b/src/base.cpp @@ -0,0 +1,19 @@ +/** + * Base.cpp + * + * Implementation of the base class + * + * @documentation private + */ +#include "includes.h" + +/** + * Set up namespace + */ +namespace Php { + +/** + * End of namespace + */ +} + diff --git a/src/classinfo.cpp b/src/classinfo.cpp index f1ffb8e..8e78df7 100644 --- a/src/classinfo.cpp +++ b/src/classinfo.cpp @@ -65,9 +65,6 @@ static zend_object_value create_object(zend_class_entry *type TSRMLS_DC) // retrieve the classinfo object _ClassInfo *info = (_ClassInfo *)base->info.user.doc_comment; - // construct the cpp object - object->cpp = info->construct(); - // store the class object->php.ce = type; @@ -90,6 +87,12 @@ static zend_object_value create_object(zend_class_entry *type TSRMLS_DC) // put the object in the storage, and assign a method for deallocating and cloning result.handle = zend_objects_store_put(object, NULL, deallocate_object, clone_object TSRMLS_CC); + // finally, construct the cpp object + object->cpp = info->construct(); + + std::cout << "Allocate object" << std::endl; + std::cout << object->cpp << " " << object << std::endl; + // done return result; } diff --git a/src/hashmember.cpp b/src/hashmember.cpp new file mode 100644 index 0000000..f6f8483 --- /dev/null +++ b/src/hashmember.cpp @@ -0,0 +1,40 @@ +/** + * HashMember.cpp + * + * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com> + * @copyright 2013 Copernica BV + */ +#include "includes.h" + +/** + * Set up namespace + */ +namespace Php { + +/** + * Custom output stream operator + * @param stream + * @param value + * @return ostream + */ +std::ostream &operator<<(std::ostream &stream, const HashMember<int> &value) +{ + return stream << value.value(); +} + +/** + * Custom output stream operator + * @param stream + * @param value + * @return ostream + */ +std::ostream &operator<<(std::ostream &stream, const HashMember<std::string> &value) +{ + return stream << value.value(); +} + +/** + * End of namespace + */ +} + diff --git a/src/includes.h b/src/includes.h index 4effa90..87b5d64 100644 --- a/src/includes.h +++ b/src/includes.h @@ -45,6 +45,7 @@ #include "../include/hashmember.h" #include "../include/parameters.h" #include "../include/function.h" +#include "../include/properties.h" #include "../include/base.h" #include "../include/method.h" #include "../include/member.h" diff --git a/src/value.cpp b/src/value.cpp index 5e6d9b0..ded6c4a 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -1006,6 +1006,17 @@ HashMember<std::string> Value::operator[](const char *key) } /** + * Custom output stream operator + * @param stream + * @param value + * @return ostream + */ +std::ostream &operator<<(std::ostream &stream, const Value &value) +{ + return stream << value.stringValue(); +} + +/** * End of namespace */ } |