summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-14 09:39:14 +0100
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-14 09:39:14 +0100
commitc9274ab3c422390998e628820afc6a27c12a1a57 (patch)
tree7f416700947dfea34428c1e2ff8d0ebfba69dfd5 /src
parent684f81e8bcbadc3d522e6557161275deaad4fd3b (diff)
introduced super globals Php::POST, Php::GET, et cetera, fixed setting array members, introduced Value::attach() method
Diffstat (limited to 'src')
-rw-r--r--src/extension.cpp2
-rw-r--r--src/includes.h1
-rw-r--r--src/value.cpp62
3 files changed, 64 insertions, 1 deletions
diff --git a/src/extension.cpp b/src/extension.cpp
index 3f29d9c..4c6a46f 100644
--- a/src/extension.cpp
+++ b/src/extension.cpp
@@ -117,7 +117,7 @@ int Extension::onStartup(int type, int module_number)
// is the callback registered?
if (extension->_onStartup) extension->_onStartup();
-
+
// done
return BOOL2SUCCESS(true);
}
diff --git a/src/includes.h b/src/includes.h
index 50d4144..b2cb353 100644
--- a/src/includes.h
+++ b/src/includes.h
@@ -55,6 +55,7 @@
#include "../include/byval.h"
#include "../include/byref.h"
#include "../include/global.h"
+#include "../include/super.h"
#include "../include/hashmember.h"
#include "../include/parameters.h"
#include "../include/modifiers.h"
diff --git a/src/value.cpp b/src/value.cpp
index a78c2d4..29b6dcd 100644
--- a/src/value.cpp
+++ b/src/value.cpp
@@ -170,6 +170,21 @@ Value::Value(struct _zval_struct *val, bool ref)
}
/**
+ * Wrap around a hash table
+ * @param ht Hashtable to wrap
+ */
+Value::Value(HashTable *ht)
+{
+ // construct a zval
+ MAKE_STD_ZVAL(_val);
+ Z_ARRVAL_P(_val) = ht;
+ Z_TYPE_P(_val) = IS_ARRAY;
+
+ // add a reference
+ Z_ADDREF_P(_val);
+}
+
+/**
* Wrap around an object
* @param object
*/
@@ -302,6 +317,9 @@ Value::~Value()
*/
zval *Value::detach()
{
+ // leap out if already detached
+ if (!_val) return nullptr;
+
// copy return value
zval *result = _val;
@@ -316,6 +334,50 @@ zval *Value::detach()
}
/**
+ * Attach a different zval
+ *
+ * This will first detach the current zval, and link the Value object to
+ * a different zval.
+ *
+ * @param val
+ */
+void Value::attach(struct _zval_struct *val)
+{
+ // detach first
+ if (_val) detach();
+
+ // store the zval
+ _val = val;
+
+ // add one more reference
+ Z_ADDREF_P(_val);
+}
+
+/**
+ * Attach a different zval
+ *
+ * This will first detach the current zval, and link the Value object to
+ * a new zval
+ *
+ * @param hashtable
+ */
+void Value::attach(struct _hashtable *hashtable)
+{
+ // detach first
+ if (_val) detach();
+
+ // construct a new zval
+ MAKE_STD_ZVAL(_val);
+
+ // store pointer to the hashtable, and mark the zval as an array
+ Z_ARRVAL_P(_val) = hashtable;
+ Z_TYPE_P(_val) = IS_ARRAY;
+
+ // add a reference
+ Z_ADDREF_P(_val);
+}
+
+/**
* Retrieve the refcount
* @return int
*/