diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2015-01-25 18:51:27 +0100 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2015-01-25 18:51:27 +0100 |
commit | b42532f1f49d9f404b100fe1a441de0c131673ee (patch) | |
tree | 2e6ad76940addddafb5b8801984d96cf730e5fcf | |
parent | 3e6fb6ef89600abf2a282396384aab80ec9390ce (diff) |
fixed include order, and fixed added Php::Constant to Php::Class objects
-rw-r--r-- | phpcpp.h | 2 | ||||
-rw-r--r-- | zend/constantimpl.h | 15 |
2 files changed, 12 insertions, 5 deletions
@@ -57,9 +57,9 @@ #include <phpcpp/serializable.h> #include <phpcpp/classtype.h> #include <phpcpp/classbase.h> +#include <phpcpp/constant.h> #include <phpcpp/interface.h> #include <phpcpp/class.h> -#include <phpcpp/constant.h> #include <phpcpp/namespace.h> #include <phpcpp/extension.h> #include <phpcpp/call.h> diff --git a/zend/constantimpl.h b/zend/constantimpl.h index bfae410..7320a8b 100644 --- a/zend/constantimpl.h +++ b/zend/constantimpl.h @@ -116,7 +116,7 @@ public: * Add the constant to a class * @param clss The class to add it to */ - void addTo(ClassBase &clss) + void addTo(ClassBase &clss) const { // check the zval type switch (Z_TYPE(_constant.value)) { @@ -149,11 +149,18 @@ public: default: // this should not happen, the constant can only be constructed as one // of the above types, so it should be impossible to end up here. But - // for completeness, we convert the constant to a string, here - convert_to_string(&_constant.value); + // for completeness, we are going to make a copy of the zval, and convert + // that to a string + zval copy = _constant.value; + + // run the copy constructor to make sure zval is correctly copied + zval_copy_ctor(©); + + // convert the copy to a string + convert_to_string(©); // set as string constant - clss.property(_name, std::string(Z_STRVAL(_constant.value), Z_STRLEN(_constant.value)), Php::Const); + clss.property(_name, std::string(Z_STRVAL(copy), Z_STRLEN(copy)), Php::Const); break; } } |