Instance variables
| From: | herrwitten@php.net | Date: | Mon, 04 Jul 2005 02:00:57 +0000 |
| Subject: | Instance variables | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-2532@lists.php.net to get a copy of this message | ||
I already have an extension that creates a class.
The first step in converting PEAR_Delegator to a pecl extension is to create instance variables.
Here is the object definition:
typedef struct _Delegator
{
zend_object zendObject; /* base */
zval * _delegates;
zval * _delegatesFalse;
zval * _method_map;
} Delegator;
I then create the variables as follows:
MAKE_STD_ZVAL(intern->_delegates);
array_init(intern->_delegates);
MAKE_STD_ZVAL(intern->_delegatesFalse);
array_init(intern->_delegatesFalse);
MAKE_STD_ZVAL(intern->_method_map);
array_init(intern->_method_map);
Even though I only need HashTables, I have used zval's. Is this wrong?
The trouble is now to make these protected properties of the class so that subclasses can access them. I have tried using zend_declare_property, but that doesn't allow internal zval's to be arrays, etc.
Moreover, PEAR_Delegator has this code for removing all delegation information:
public function removeAllDelegates()
{
unset($this->_method_map);
unset($this->_delegates);
unset($this->_delegatesFalse);
$this->_method_map = array();
$this->_delegates = array();
$this->_delegatesFalse = array();
}
How can I do this? Is there a more efficient way to clear out an array?
In other words, I would like to know how to manipulate these variables as I do in PHP.
Thanks for any response.
Sincerely,
Witten