Overloaded class registration

php.internals

Evan Nemerson

21 years ago
Hi everyone, I noticed recently that both of my extensions (Panda and FANN, both in PECL) emit error messages when their __get() and __set() methods are registered. The problem seems to be that fptr.common->num_args is always 0 in zend_check_magic_method_implementation(), regardless of what I set them to prior to registration. The functions still work perfectly, and valgrind doesn't complain. There's just an incredibly annoying error message every time. It's entirely possible (if not probable) that it's my code that's wrong, not ZE2, but I can't for the life of me figure it out. The pertinant portion of the code is based on the SOAP extension. The source code for the fann extension is at http://cvs.sourceforge.net/viewcvs.py/*checkout*/fann/fannphp/fann.c?rev=1.13 I tried pecl-dev last week, and the only suggestion I got was using the read_property and write_property callbacks instead of the __get() and __post() methods, but I don't really think that's an option. The thread is at http://marc.theaimsgroup.com/?l=pecl-dev&m=110012046408453&w=2 Thanks.
-- Evan Nemerson evan@coeus-group.com http://coeusgroup.com/en

Marcus Börger

21 years ago
Hello Evan, your implementation is wrong, you need to specify the arguments to __get/__set. best regards marcus Tuesday, November 16, 2004, 9:01:25 PM, you wrote:
> Hi everyone,
> I noticed recently that both of my extensions (Panda and FANN, both in PECL) > emit error messages when their __get() and __set() methods are registered. > The problem seems to be that fptr.common->num_args is always 0 in > zend_check_magic_method_implementation(), regardless of what I set them to > prior to registration.
> The functions still work perfectly, and valgrind doesn't complain. There's > just an incredibly annoying error message every time. It's entirely possible > (if not probable) that it's my code that's wrong, not ZE2, but I can't for > the life of me figure it out.
> The pertinant portion of the code is based on the SOAP extension. The source > code for the fann extension is at > http://cvs.sourceforge.net/viewcvs.py/*checkout*/fann/fannphp/fann.c?rev=1.13
> I tried pecl-dev last week, and the only suggestion I got was using the > read_property and write_property callbacks instead of the __get() and > __post() methods, but I don't really think that's an option. The thread is at > http://marc.theaimsgroup.com/?l=pecl-dev&m=110012046408453&w=2
> Thanks.
> -- > Evan Nemerson > evan@coeus-group.com > http://coeusgroup.com/en
-- Best regards, Marcus mailto:helly@php.net

Evan Nemerson

21 years ago
On Tuesday 16 Nov 2004 13:32, Marcus Boerger wrote:
> Hello Evan, > > your implementation is wrong, you need to specify the arguments to > __get/__set.
Thanks for the reply, but can you be a bit more specific? I'm already specifying num_args and required_num_args (the former of which is what is checked in zend_check_magic_method_implementation()). Setting arg_info seems to have no effect. Here's the code I used to try setting arg_info (apologies if it wraps) for the __set method: fe_set.type = ZEND_INTERNAL_FUNCTION; fe_set.handler = ZEND_FN(fannOO___set); fe_set.function_name = NULL; fe_set.scope = NULL; fe_set.fn_flags = 0; fe_set.prototype = NULL; fe_set.num_args = 2; fe_set.required_num_args = 2; fe_set.arg_info = ecalloc(fe_set.num_args, sizeof(zend_arg_info)); fe_set.pass_rest_by_reference = 0; fe_set.arg_info[0].name = one; fe_set.arg_info[0].name_len = strlen(one); fe_set.arg_info[0].class_name = le_fann_name; fe_set.arg_info[0].class_name_len = strlen(le_fann_name); fe_set.arg_info[0].allow_null = 0; fe_set.arg_info[0].pass_by_reference = 0; fe_set.arg_info[0].return_reference = 0; fe_set.arg_info[0].required_num_args = fe_set.required_num_args; fe_set.arg_info[1].name = two; fe_set.arg_info[1].name_len = strlen(two); fe_set.arg_info[1].class_name = le_fann_name; fe_set.arg_info[1].class_name_len = strlen(le_fann_name); fe_set.arg_info[1].allow_null = 0; fe_set.arg_info[1].pass_by_reference = 0; fe_set.arg_info[1].return_reference = 0; fe_set.arg_info[1].required_num_args = fe_set.required_num_args;
> > best regards > marcus > > Tuesday, November 16, 2004, 9:01:25 PM, you wrote: > > Hi everyone, > > > > I noticed recently that both of my extensions (Panda and FANN, both in > > PECL) emit error messages when their __get() and __set() methods are > > registered. The problem seems to be that fptr.common->num_args is always > > 0 in zend_check_magic_method_implementation(), regardless of what I set > > them to prior to registration. > > > > The functions still work perfectly, and valgrind doesn't complain. > > There's just an incredibly annoying error message every time. It's > > entirely possible (if not probable) that it's my code that's wrong, not > > ZE2, but I can't for the life of me figure it out. > > > > The pertinant portion of the code is based on the SOAP extension. The > > source code for the fann extension is at > > http://cvs.sourceforge.net/viewcvs.py/*checkout*/fann/fannphp/fann.c?rev= > >1.13 > > > > I tried pecl-dev last week, and the only suggestion I got was using the > > read_property and write_property callbacks instead of the __get() and > > __post() methods, but I don't really think that's an option. The thread > > is at http://marc.theaimsgroup.com/?l=pecl-dev&m=110012046408453&w=2 > > > > Thanks. > > > > > > -- > > Evan Nemerson > > evan@coeus-group.com > > http://coeusgroup.com/en > > -- > Best regards, > Marcus mailto:helly@php.net
-- Evan Nemerson evan@coeus-group.com http://coeusgroup.com/en

Marcus Börger

21 years ago
Hello Evan, what you do is irrelevant you need to define the method signature. See example from Zend/zend_interfaces.c: static ZEND_BEGIN_ARG_INFO(arginfo_arrayaccess_offset, 0) ZEND_ARG_INFO(0, offset) ZEND_END_ARG_INFO(); static ZEND_BEGIN_ARG_INFO(arginfo_arrayaccess_offset_value, 0) ZEND_ARG_INFO(0, offset) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO(); zend_function_entry zend_funcs_arrayaccess[] = { ZEND_ABSTRACT_ME(arrayaccess, offsetExists, arginfo_arrayaccess_offset) ZEND_ABSTRACT_ME(arrayaccess, offsetGet, arginfo_arrayaccess_offset) ZEND_ABSTRACT_ME(arrayaccess, offsetSet, arginfo_arrayaccess_offset_value) ZEND_ABSTRACT_ME(arrayaccess, offsetUnset, arginfo_arrayaccess_offset) {NULL, NULL, NULL} }; Tuesday, November 16, 2004, 11:35:24 PM, you wrote:
> On Tuesday 16 Nov 2004 13:32, Marcus Boerger wrote: >> Hello Evan, >> >> your implementation is wrong, you need to specify the arguments to >> __get/__set.
> Thanks for the reply, but can you be a bit more specific? I'm already > specifying num_args and required_num_args (the former of which is what is > checked in zend_check_magic_method_implementation()). Setting arg_info seems > to have no effect. Here's the code I used to try setting arg_info (apologies > if it wraps) for the __set method:
> fe_set.type = ZEND_INTERNAL_FUNCTION; > fe_set.handler = ZEND_FN(fannOO___set); > fe_set.function_name = NULL; > fe_set.scope = NULL; > fe_set.fn_flags = 0; > fe_set.prototype = NULL; > fe_set.num_args = 2; > fe_set.required_num_args = 2; > fe_set.arg_info = ecalloc(fe_set.num_args, sizeof(zend_arg_info)); > fe_set.pass_rest_by_reference = 0;
> fe_set.arg_info[0].name = one; > fe_set.arg_info[0].name_len = strlen(one); > fe_set.arg_info[0].class_name = le_fann_name; > fe_set.arg_info[0].class_name_len = strlen(le_fann_name); > fe_set.arg_info[0].allow_null = 0; > fe_set.arg_info[0].pass_by_reference = 0; > fe_set.arg_info[0].return_reference = 0; > fe_set.arg_info[0].required_num_args = fe_set.required_num_args;
> fe_set.arg_info[1].name = two; > fe_set.arg_info[1].name_len = strlen(two); > fe_set.arg_info[1].class_name = le_fann_name; > fe_set.arg_info[1].class_name_len = strlen(le_fann_name); > fe_set.arg_info[1].allow_null = 0; > fe_set.arg_info[1].pass_by_reference = 0; > fe_set.arg_info[1].return_reference = 0; > fe_set.arg_info[1].required_num_args = fe_set.required_num_args;
>> >> best regards >> marcus >> >> Tuesday, November 16, 2004, 9:01:25 PM, you wrote: >> > Hi everyone, >> > >> > I noticed recently that both of my extensions (Panda and FANN, both in >> > PECL) emit error messages when their __get() and __set() methods are >> > registered. The problem seems to be that fptr.common->num_args is always >> > 0 in zend_check_magic_method_implementation(), regardless of what I set >> > them to prior to registration. >> > >> > The functions still work perfectly, and valgrind doesn't complain. >> > There's just an incredibly annoying error message every time. It's >> > entirely possible (if not probable) that it's my code that's wrong, not >> > ZE2, but I can't for the life of me figure it out. >> > >> > The pertinant portion of the code is based on the SOAP extension. The >> > source code for the fann extension is at >> > >> http://cvs.sourceforge.net/viewcvs.py/*checkout*/fann/fannphp/fann.c?rev= >> >1.13 >> > >> > I tried pecl-dev last week, and the only suggestion I got was using the >> > read_property and write_property callbacks instead of the __get() and >> > __post() methods, but I don't really think that's an option. The thread >> > is at http://marc.theaimsgroup.com/?l=pecl-dev&m=110012046408453&w=2 >> > >> > Thanks. >> > >> > >> > -- >> > Evan Nemerson >> > evan@coeus-group.com >> > http://coeusgroup.com/en >> >> -- >> Best regards, >> Marcus mailto:helly@php.net
> -- > Evan Nemerson > evan@coeus-group.com > http://coeusgroup.com/en
-- Best regards, Marcus mailto:helly@php.net