summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Examples/CppClassesInPhp/cppclassinphp.cpp6
-rw-r--r--include/class.h20
-rw-r--r--include/classbase.h10
-rw-r--r--src/classbase.cpp6
-rw-r--r--src/includes.h2
5 files changed, 19 insertions, 25 deletions
diff --git a/Examples/CppClassesInPhp/cppclassinphp.cpp b/Examples/CppClassesInPhp/cppclassinphp.cpp
index 1b567e1..8e9bf39 100644
--- a/Examples/CppClassesInPhp/cppclassinphp.cpp
+++ b/Examples/CppClassesInPhp/cppclassinphp.cpp
@@ -70,8 +70,10 @@ extern "C"
Php::Class<MyCustomClass> customClass("MyClass");
// add methods to it
- // @todo support setting parameter properties
- customClass.add("myMethod", &MyCustomClass::myMethod, {});
+ customClass.add("myMethod", &MyCustomClass::myMethod, Php::Final, {});
+ customClass.add("property", "bla");
+ customClass.add("property", "bla", Php::Protected);
+ customClass.add("property", "bla", Php::Const);
// add the class to the extension
extension.add(customClass);
diff --git a/include/class.h b/include/class.h
index ad0e1a7..bed9fa7 100644
--- a/include/class.h
+++ b/include/class.h
@@ -39,8 +39,6 @@ public:
* flags are set, a regular public class will be formed.
*
* @param name Name of the class
- *
- * @todo make sure flags are used
*/
Class(const char *name) : ClassBase(name) {}
@@ -64,14 +62,14 @@ public:
* @param flags Optional flags
* @param args Argument descriptions
*/
- void add(const char *name, void(T::*method)(), int flags = 0, const Arguments &args = {}) { ClassBase::add(name, static_cast<method_callback_0>(method), flags, args); }
- void add(const char *name, void(T::*method)(Parameters &params), int flags = 0, const Arguments &args = {}) { ClassBase::add(name, static_cast<method_callback_1>(method), flags, args); }
- void add(const char *name, bool(T::*method)(), int flags = 0, const Arguments &args = {}) { ClassBase::add(name, static_cast<method_callback_2>(method), flags, args); }
- void add(const char *name, bool(T::*method)(Parameters &params), int flags = 0, const Arguments &args = {}) { ClassBase::add(name, static_cast<method_callback_3>(method), flags, args); }
- void add(const char *name, void(T::*method)(), const Arguments &args = {}) { ClassBase::add(name, static_cast<method_callback_0>(method), 0, args); }
- void add(const char *name, void(T::*method)(Parameters &params), const Arguments &args = {}) { ClassBase::add(name, static_cast<method_callback_1>(method), 0, args); }
- void add(const char *name, bool(T::*method)(), const Arguments &args = {}) { ClassBase::add(name, static_cast<method_callback_2>(method), 0, args); }
- void add(const char *name, bool(T::*method)(Parameters &params), const Arguments &args = {}) { ClassBase::add(name, static_cast<method_callback_3>(method), 0, args); }
+ void add(const char *name, void(T::*method)(), int flags = Public, const Arguments &args = {}) { ClassBase::add(name, static_cast<method_callback_0>(method), flags, args); }
+ void add(const char *name, void(T::*method)(Parameters &params), int flags = Public, const Arguments &args = {}) { ClassBase::add(name, static_cast<method_callback_1>(method), flags, args); }
+ void add(const char *name, bool(T::*method)(), int flags = Public, const Arguments &args = {}) { ClassBase::add(name, static_cast<method_callback_2>(method), flags, args); }
+ void add(const char *name, bool(T::*method)(Parameters &params), int flags = Public, const Arguments &args = {}) { ClassBase::add(name, static_cast<method_callback_3>(method), flags, args); }
+ void add(const char *name, void(T::*method)(), const Arguments &args = {}) { ClassBase::add(name, static_cast<method_callback_0>(method), Public, args); }
+ void add(const char *name, void(T::*method)(Parameters &params), const Arguments &args = {}) { ClassBase::add(name, static_cast<method_callback_1>(method), Public, args); }
+ void add(const char *name, bool(T::*method)(), const Arguments &args = {}) { ClassBase::add(name, static_cast<method_callback_2>(method), Public, args); }
+ void add(const char *name, bool(T::*method)(Parameters &params), const Arguments &args = {}) { ClassBase::add(name, static_cast<method_callback_3>(method), Public, args); }
/**
* Add a property to the class
@@ -87,7 +85,7 @@ public:
* @param flags Optional flags
*/
template <typename TYPE>
- void add(const char *name, const Type &value, int flags = Php::Public) { ClassBase::add(name, value, flags); }
+ void add(const char *name, const Type &value, int flags = Public) { ClassBase::add(name, value, flags); }
protected:
/**
diff --git a/include/classbase.h b/include/classbase.h
index 8b6d3dd..9fe1bda 100644
--- a/include/classbase.h
+++ b/include/classbase.h
@@ -50,22 +50,18 @@ public:
/**
* Copy constructor
* @param that
- *
- * @todo add properties
+ *
* @todo prefer move
*/
ClassBase(const ClassBase &that) :
- _name(that._name), _flags(that._flags), _methods(that._methods) {}
+ _name(that._name), _flags(that._flags), _methods(that._methods), _members(that._members) {}
/**
* Move constructor
* @param that
- *
- * @todo add properties
- * @todo use move semantics
*/
ClassBase(ClassBase &&that) :
- _flags(that._flags), _methods(std::move(that._methods)), _entry(that._entry)
+ _flags(that._flags), _methods(std::move(that._methods)), _methods(std::move(that._methods)), _entry(that._entry)
{
// other entry are invalid now (not that it is used..., class objects are
// only moved during extension setup, when the entry pointer has not yet
diff --git a/src/classbase.cpp b/src/classbase.cpp
index 8c5e238..da705b6 100644
--- a/src/classbase.cpp
+++ b/src/classbase.cpp
@@ -136,7 +136,6 @@ const struct _zend_function_entry *ClassBase::entries()
zend_function_entry *entry = &_entries[i++];
// let the function fill the entry
- // @todo check flags for the method
method->initialize(entry, _name);
}
@@ -199,9 +198,8 @@ void ClassBase::initialize()
#endif
// set access types flags for class
- // @todo something with the flags, but before or after the register_internal_class?
- //setFlags(entry, _type.getFlags());
-
+ _entry->ce_flags = flags;
+
// declare all member variables
for (auto &member : _members) member->initialize(_entry);
}
diff --git a/src/includes.h b/src/includes.h
index f101080..d2355c1 100644
--- a/src/includes.h
+++ b/src/includes.h
@@ -23,7 +23,7 @@
#include <iostream>
/**
- * @todo: if ZTS defined very many errors. need debug.
+ * @todo: if ZTS defined many errors appear. need debug.
*/
//#define ZTS 1