Re: how do you create a private property as an array in a class
| From: | Matthew Hernandez | Date: | Sat, 07 Apr 2012 21:38:09 +0000 |
| Subject: | Re: how do you create a private property as an array in a class | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-59445@lists.php.net to get a copy of this message | ||
Hi Johannes,
Yes I just found out that I should extend instead of the approach I was
thinking about.
So I created this:
typedef struct _foo_object {
zend_object std;
zval *array;
int size;
} foo_object;
So the question is how do I correctly pass foo_object around so that I can
manipulate *array ? Having a private variable would mean calling getThis()
and handling it that way would be trivial.
Are there any examples I could see? I'm using the slides from your
presentation in 2009 to help me.
thanks
On Sat, Apr 7, 2012 at 2:27 PM, Johannes Schlüter <johannes@schlueters.de>wrote:
> Hi,
>
> On Sat, 2012-04-07 at 11:23 -0700, Matthew Hernandez wrote:
> > This is my first extension I'm working on. I'm trying to make a class
> > available to the user space with 1 private property that is an array.
>
> The first question is: Why? - Why add the overhead of creating such an
> array if it is private? In most cases it is better to extend the
> zend_object in C (struct my_object { zend_object inner; type
> some_data;}) to hold private data. If you want to show it in var_dump or
> a debugger you could implement a debug_info hook.
>
> johannes
>
>
>