summaryrefslogtreecommitdiff
path: root/include/class.h
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-07 10:52:55 +0100
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-07 10:52:55 +0100
commitd8af7675389df1bf4796e03e9286fdadba882d38 (patch)
tree00dbe04101fed59af5e9bd59f82dd7b94fc1b0b7 /include/class.h
parentc8ff51e13fc0a3d8fb7d1423882fa659f9cf2b3b (diff)
removed tabs from makefile, work in progress on implementing SPL interfaces
Diffstat (limited to 'include/class.h')
-rw-r--r--include/class.h36
1 files changed, 35 insertions, 1 deletions
diff --git a/include/class.h b/include/class.h
index a22b9a8..3326507 100644
--- a/include/class.h
+++ b/include/class.h
@@ -16,6 +16,12 @@
*/
/**
+ * Zend/SPL interfaces that we support
+ */
+extern struct _zend_class_entry *spl_ce_Countable;
+extern struct _zend_class_entry *spl_ce_ArrayAccess;
+
+/**
* Set up namespace
*/
namespace Php {
@@ -38,7 +44,35 @@ public:
Class(const char *name) : ClassBase(name)
{
// check for special classes
- if (std::is_base_of<Countable, T>::value) ClassBase::interface(Countable::implementation());
+ if (std::is_base_of<Countable, T>::value)
+ {
+ // register the interface (we register a pointer-to-a-pointer here,
+ // because when this code runs (during the get_module() call), the
+ // interfaces are not yet initialized by the zend engine, this
+ // happens later when the all classes are registered (after the
+ // get_module() call)
+ interface(&spl_ce_Countable);
+
+ // add the count method
+ method("count", &T::count, {});
+ }
+
+ // check for special classes
+ if (std::is_base_of<ArrayAccess, T>::value)
+ {
+ // register the interface (we register a pointer-to-a-pointer here,
+ // because when this code runs (during the get_module() call), the
+ // interfaces are not yet initialized by the zend engine, this
+ // happens later when the all classes are registered (after the
+ // get_module() call)
+ interface(&spl_ce_ArrayAccess);
+
+ // add the count method
+ method("count", &T::offsetSet);
+ method("count", &T::offsetGet);
+ method("count", &T::offsetUnset);
+ method("count", &T::offsetExists);
+ }
}
/**