summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-08-31 15:41:04 -0700
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-08-31 15:41:04 -0700
commitd762ee103bee45bcd18df457c2c7a9f36991c75f (patch)
treebd8937a36a205a8755ac485c4ede65c10078b375 /include
parent708e9cf9da9571a38ac8d2529d016cd78ce8ec54 (diff)
Work in progress on a simpler api
Diffstat (limited to 'include')
-rw-r--r--include/extension.h15
-rw-r--r--include/function.h55
-rw-r--r--include/functions.h9
3 files changed, 31 insertions, 48 deletions
diff --git a/include/extension.h b/include/extension.h
index daff45e..1962fd7 100644
--- a/include/extension.h
+++ b/include/extension.h
@@ -17,7 +17,11 @@
* @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
* @copyright 2013 Copernica BV
*/
-#include <php5/Zend/zend_modules.h>
+
+/**
+ * Structures referenced in this class
+ */
+struct _zend_module_entry;
/**
* Set up namespace
@@ -47,7 +51,7 @@ public:
/**
* Destructor
*/
- virtual ~Extension() {}
+ virtual ~Extension() { delete _entry; }
/**
* Initialize the extension.
@@ -141,9 +145,14 @@ public:
private:
/**
* The information that is passed to the Zend engine
+ *
+ * Although it would be slightly faster to not make this a pointer, this
+ * would require that client code also includes the PHP header files, which
+ * we try to prevent with the PHP-CPP library, so we allocate it dynamically.
+ *
* @var zend_module_entry
*/
- zend_module_entry _entry;
+ _zend_module_entry *_entry;
};
diff --git a/include/function.h b/include/function.h
index fec83e9..ef185ce 100644
--- a/include/function.h
+++ b/include/function.h
@@ -39,51 +39,32 @@ public:
Function(const char *name) : Function(name, {}) {}
/**
- * Copy constructor
+ * No copy constructor
* @param function The other function
*/
- Function(const Function &function)
+ Function(const Function &function) = delete;
+
+ /**
+ * Move constructor
+ * @param function The other function
+ */
+ Function(Function &&function)
{
- // copy other object
- _refcount = function._refcount;
_callable = function._callable;
-
- // increate number of references
- (*_refcount)++;
+ function._callable = nullptr;
}
/**
* Destructor
*/
- virtual ~Function()
- {
- // cleanup the object
- cleanup();
- }
+ virtual ~Function();
/**
- * Assignment operator
+ * No assignment operator
* @param function The other function
* @return Function
*/
- Function &operator=(const Function &function)
- {
- // skip self assignment
- if (&function == this) return *this;
-
- // cleanup the object
- cleanup();
-
- // copy other object
- _refcount = function._refcount;
- _callable = function._callable;
-
- // increate number of references
- (*_refcount)++;
-
- // done
- return *this;
- }
+ Function &operator=(const Function &function) {}
/**
* Method that gets called every time the function is executed
@@ -109,18 +90,6 @@ protected:
* @var smart_ptr
*/
Callable *_callable;
-
- /**
- * Counter with the number of references
- * @var integer
- */
- int *_refcount;
-
-
- /**
- * Remove one reference
- */
- void cleanup();
};
/**
diff --git a/include/functions.h b/include/functions.h
index 49f38b7..fc44f1c 100644
--- a/include/functions.h
+++ b/include/functions.h
@@ -9,6 +9,11 @@
*/
/**
+ * Define structures
+ */
+struct _zend_function_entry;
+
+/**
* Set up namespace
*/
namespace PhpCpp {
@@ -35,7 +40,7 @@ private:
* Retrieve the internal data
* @return zend_function_entry*
*/
- zend_function_entry *internal() const
+ _zend_function_entry *internal() const
{
return _entries;
}
@@ -44,7 +49,7 @@ private:
* The internal entries
* @var zend_function_entry*
*/
- zend_function_entry *_entries;
+ _zend_function_entry *_entries;
/**
* Vector of functions (we need this because the function objects must