summaryrefslogtreecommitdiff
path: root/include/class.h
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-12 15:45:19 +0100
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-12 15:45:19 +0100
commit21edee4d584dbf757b006349e903ff7a3b398a1d (patch)
tree2532ec92649726a2ff59ba440c4090e80c679d9d /include/class.h
parent4415b472ae57e367e1fcece4c04355b55a868a1b (diff)
support for static methods
Diffstat (limited to 'include/class.h')
-rw-r--r--include/class.h28
1 files changed, 26 insertions, 2 deletions
diff --git a/include/class.h b/include/class.h
index 427aa64..d1afab2 100644
--- a/include/class.h
+++ b/include/class.h
@@ -73,7 +73,7 @@ public:
virtual ~Class() {}
/**
- * Add a method to the class
+ * Add a regular method to the class
*
* The method will be accessible as one of the class methods in your PHP
* code. When the method is called, it will automatically be forwarded
@@ -105,6 +105,30 @@ public:
void method(const char *name, Value (T::*method)(Parameters &params) const, const Arguments &args = {}) { ClassBase::method(name, static_cast<method_callback_7>(method), Public, args); }
/**
+ * Add a static method to a class
+ *
+ * In C++ a static method is just a plain function, that only at compile
+ * time has access to the private variables. You can therefore also supply
+ * global functions as static method, and real static methods (that do not
+ * even have to come from the same class.
+ *
+ * In PHP scripts, the function will only be callable as real static method
+ *
+ * @param name Name of the method
+ * @param method The actual method
+ * @param flags Optional flags
+ * @param args Argument descriptions
+ */
+ void method(const char *name, const native_callback_0 &function, int flags, const Arguments &args = {}) { ClassBase::method(name, function, flags, args); }
+ void method(const char *name, const native_callback_1 &function, int flags, const Arguments &args = {}) { ClassBase::method(name, function, flags, args); }
+ void method(const char *name, const native_callback_2 &function, int flags, const Arguments &args = {}) { ClassBase::method(name, function, flags, args); }
+ void method(const char *name, const native_callback_3 &function, int flags, const Arguments &args = {}) { ClassBase::method(name, function, flags, args); }
+ void method(const char *name, const native_callback_0 &function, const Arguments &args = {}) { ClassBase::method(name, function, Public, args); }
+ void method(const char *name, const native_callback_1 &function, const Arguments &args = {}) { ClassBase::method(name, function, Public, args); }
+ void method(const char *name, const native_callback_2 &function, const Arguments &args = {}) { ClassBase::method(name, function, Public, args); }
+ void method(const char *name, const native_callback_3 &function, const Arguments &args = {}) { ClassBase::method(name, function, Public, args); }
+
+ /**
* Add an abstract method to the class
*
* This is only meaningful for classes that can be extended. Because the
@@ -198,7 +222,7 @@ private:
// compare the two objects
if (*t1 < *t2) return -1;
- if (*t1 > *t2) return 1;
+ if (*t2 < *t1) return 1;
// they must be identical
return 0;