summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-09 12:51:02 +0100
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-09 12:51:02 +0100
commiteb4962468ace477cdd72fd1da48ae304407e40d2 (patch)
treeab437ea4c9acdaf523e4c3a1ba6ace8b88bf3025 /include
parent116770c10d2f8219be6d90207b56853bf5a356e1 (diff)
added arrayaccess implementation
Diffstat (limited to 'include')
-rw-r--r--include/arrayaccess.h38
-rw-r--r--include/class.h2
-rw-r--r--include/classbase.h34
-rw-r--r--include/value.h26
4 files changed, 61 insertions, 39 deletions
diff --git a/include/arrayaccess.h b/include/arrayaccess.h
index 6ee3163..cf8c261 100644
--- a/include/arrayaccess.h
+++ b/include/arrayaccess.h
@@ -47,44 +47,6 @@ public:
* @param key
*/
virtual void offsetUnset(const Php::Value &key) = 0;
-
- /**
- * Alternative offsetExists as it is initially called
- * @param params
- * @return bool
- */
- virtual Php::Value offsetExists(Php::Parameters &params)
- {
- return offsetExists(params[0]);
- }
-
- /**
- * Alternative set member function as it is initially called
- * @param params
- */
- virtual void offsetSet(const Php::Parameters &params)
- {
- offsetSet(params[0], params[1]);
- }
-
- /**
- * Alternative retrieve member function that is initially called
- * @param params
- * @return value
- */
- virtual Php::Value offsetGet(Php::Parameters &params)
- {
- return offsetGet(params[0]);
- }
-
- /**
- * Alternative function to remove a member that is initally called
- * @param params
- */
- virtual void offsetUnset(Php::Parameters &params)
- {
- return offsetUnset(params[0]);
- }
};
/**
diff --git a/include/class.h b/include/class.h
index ab4a3e0..e9a7179 100644
--- a/include/class.h
+++ b/include/class.h
@@ -52,7 +52,7 @@ public:
// interfaces are not yet initialized by the zend engine, this only
// happens later when the all classes are registered (after the
// get_module() call)
- if (std::is_base_of<ArrayAccess, T>::value) interface(&zend_ce_arrayaccess);
+// if (std::is_base_of<ArrayAccess, T>::value) interface(&zend_ce_arrayaccess);
}
/**
diff --git a/include/classbase.h b/include/classbase.h
index f15e879..81454ba 100644
--- a/include/classbase.h
+++ b/include/classbase.h
@@ -243,6 +243,40 @@ private:
static int countElements(struct _zval_struct *object, long *count);
/**
+ * Function that is called when the object is used as an array in PHP
+ * @param object The object on which it is called
+ * @param offset The name of the property
+ * @param type The type of the variable???
+ * @return zval
+ */
+ static struct _zval_struct *readDimension(struct _zval_struct *object, struct _zval_struct *offset, int type);
+
+ /**
+ * Function that is called when the object is used as an array in PHP
+ * @param object The object on which it is called
+ * @param offset The name of the property
+ * @param value The new value
+ * @return zval
+ */
+ static void writeDimension(struct _zval_struct *object, struct _zval_struct *offset, struct _zval_struct *value);
+
+ /**
+ * Function that is called when the object is used as an array in PHP
+ * @param object The object on which it is called
+ * @param member The member to check
+ * @param check_empty ????
+ * @return bool
+ */
+ static int hasDimension(struct _zval_struct *object, struct _zval_struct *member, int check_empty);
+
+ /**
+ * Function that is called when the object is used as an array in PHP
+ * @param object The object on which it is called
+ * @param member The member to remove
+ */
+ static void unsetDimension(struct _zval_struct *object, struct _zval_struct *member);
+
+ /**
* Retrieve pointer to our own object handlers
* @return zend_object_handlers
*/
diff --git a/include/value.h b/include/value.h
index 72bd895..a1dd593 100644
--- a/include/value.h
+++ b/include/value.h
@@ -357,6 +357,12 @@ public:
bool isCallable() const;
/**
+ * Is the variable empty?
+ * @return bool
+ */
+ bool isEmpty() const;
+
+ /**
* Retrieve the value as number
* @return long
*/
@@ -802,6 +808,12 @@ private:
*/
Value exec(const char *name, int argc, struct _zval_struct ***params);
+ /**
+ * Refcount - the number of references to the value
+ * @return int
+ */
+ int refcount();
+
protected:
/**
* The wrapped zval
@@ -810,6 +822,19 @@ protected:
struct _zval_struct *_val;
/**
+ * Detach the zval
+ *
+ * This will unlink the zval internal structure from the Value object,
+ * so that the destructor will not reduce the number of references and/or
+ * deallocate the zval structure. This is used for functions that have to
+ * return a zval pointer, that would otherwise be deallocated the moment
+ * the function returns.
+ *
+ * @return zval
+ */
+ struct _zval_struct *detach();
+
+ /**
* Set a certain property without running any checks (you must already know
* for sure that this is an array, and that the index is not yet in use)
*
@@ -836,6 +861,7 @@ protected:
*/
friend class Globals;
friend class Member;
+ friend class ClassBase;
};
/**