[PATCH] arg_info and friends

php.internals

Hannes Magnusson

20 years ago
Hi all I've created a patch[1] that welcomes new friend into the zend_arg_info family, resource, and a new flag for ZEND_ME_MAPPING and pals, ZEND_ACC_INFO_MAP_TO_FUNCTION. The idea is to make it easier to define argument info for those extensions who map methods to functions which require some kind of resource as its first argument. Since the methods don't take any resource argument one would need to define two arg_info, one for the function and one for the method, with the only difference being the first parameter. This patch lets you however define the first argument as a resource (ZEND_ARG_RESOURCE_INFO) and then when you register the method you can pass the ZEND_ACC_INFO_MAP_TO_FUNCTION flag so the first argument (*if* it's defined as resource) will be skipped. On a related note, I find it kinda silly we don't offer argument info (except from spl) so I made a patch for ext/dom[2], ext/xsl[3] and ext/reflection[4]. I'd like to take down the rest, of at least the OO once.. Any thoughts? -Hannes [1] http://php.is/bugs/arg_info/ZEND_ARG_RESOURCE.HEAD.patch.txt [2] http://php.is/bugs/arg_info/arginfo.dom.patch.txt [3] http://php.is/bugs/arg_info/arginfo.xsl.patch.txt [4] http://php.is/bugs/arg_info/arginfo.reflection.patch.txt

Marcus Börger

20 years ago
Hello Hannes, Monday, May 29, 2006, 8:52:51 PM, you wrote:
> Hi all
> I've created a patch[1] that welcomes new friend into the > zend_arg_info family, resource, and a new flag for ZEND_ME_MAPPING and > pals, ZEND_ACC_INFO_MAP_TO_FUNCTION.
> The idea is to make it easier to define argument info for those > extensions who map methods to functions which require some kind of > resource as its first argument.
> Since the methods don't take any resource argument one would need to > define two arg_info, one for the function and one for the method, with > the only difference being the first parameter. > This patch lets you however define the first argument as a resource > (ZEND_ARG_RESOURCE_INFO) and then when you register the method you can > pass the ZEND_ACC_INFO_MAP_TO_FUNCTION flag so the first argument > (*if* it's defined as resource) will be skipped.
> On a related note, I find it kinda silly we don't offer argument info > (except from spl) so I made a patch for ext/dom[2], ext/xsl[3] and > ext/reflection[4]. > I'd like to take down the rest, of at least the OO once.. > Any thoughts?
> -Hannes
> [1] http://php.is/bugs/arg_info/ZEND_ARG_RESOURCE.HEAD.patch.txt > [2] http://php.is/bugs/arg_info/arginfo.dom.patch.txt > [3] http://php.is/bugs/arg_info/arginfo.xsl.patch.txt > [4] http://php.is/bugs/arg_info/arginfo.reflection.patch.txt
I comitted the last one and you have commit rights so you can apply the rest to php-src. For the engine stuff you still need somebody else to commit but first you need to discuss the change. To me that patch looks good, though i'd change ZEND_ACC_INFO_MAP_TO_FUNCTION to ZEND_ACC_MAP_TO_FUNCTION. Andi, Zeev? Best regards, Marcus

Hannes Magnusson

20 years ago
Hi Marcus On 6/8/06, Marcus Boerger <helly@php.net> wrote:
> Hello Hannes, > > Monday, May 29, 2006, 8:52:51 PM, you wrote: > > > Hi all > > > I've created a patch[1] that welcomes new friend into the > > zend_arg_info family, resource, and a new flag for ZEND_ME_MAPPING and > > pals, ZEND_ACC_INFO_MAP_TO_FUNCTION. > > > The idea is to make it easier to define argument info for those > > extensions who map methods to functions which require some kind of > > resource as its first argument. > > > Since the methods don't take any resource argument one would need to > > define two arg_info, one for the function and one for the method, with > > the only difference being the first parameter. > > This patch lets you however define the first argument as a resource > > (ZEND_ARG_RESOURCE_INFO) and then when you register the method you can > > pass the ZEND_ACC_INFO_MAP_TO_FUNCTION flag so the first argument > > (*if* it's defined as resource) will be skipped. > > > On a related note, I find it kinda silly we don't offer argument info > > (except from spl) so I made a patch for ext/dom[2], ext/xsl[3] and > > ext/reflection[4]. > > I'd like to take down the rest, of at least the OO once.. > > Any thoughts? > > > -Hannes > > > [1] http://php.is/bugs/arg_info/ZEND_ARG_RESOURCE.HEAD.patch.txt > > [2] http://php.is/bugs/arg_info/arginfo.dom.patch.txt > > [3] http://php.is/bugs/arg_info/arginfo.xsl.patch.txt > > [4] http://php.is/bugs/arg_info/arginfo.reflection.patch.txt > > I comitted the last one and you have commit rights so you can apply > the rest to php-src.
Thanks! :)
> For the engine stuff you still need somebody > else to commit but first you need to discuss the change. To me that > patch looks good, though i'd change ZEND_ACC_INFO_MAP_TO_FUNCTION > to ZEND_ACC_MAP_TO_FUNCTION. Andi, Zeev?
I think ZEND_ACC_MAP_TO_FUNCTION sound like it does more then filter the arginfo..., ZEND_ACC_INFO_MAP_TO_FUNCTION is more clear, imo, that it "only cares about" the arginfo. -Hannes

Marcus Börger

20 years ago
Hello Hannes, Thursday, June 8, 2006, 12:37:09 PM, you wrote:
> Hi Marcus
> On 6/8/06, Marcus Boerger <helly@php.net> wrote: >> Hello Hannes, >> >> Monday, May 29, 2006, 8:52:51 PM, you wrote: >> >> > Hi all >> >> > I've created a patch[1] that welcomes new friend into the >> > zend_arg_info family, resource, and a new flag for ZEND_ME_MAPPING and >> > pals, ZEND_ACC_INFO_MAP_TO_FUNCTION. >> >> > The idea is to make it easier to define argument info for those >> > extensions who map methods to functions which require some kind of >> > resource as its first argument. >> >> > Since the methods don't take any resource argument one would need to >> > define two arg_info, one for the function and one for the method, with >> > the only difference being the first parameter. >> > This patch lets you however define the first argument as a resource >> > (ZEND_ARG_RESOURCE_INFO) and then when you register the method you can >> > pass the ZEND_ACC_INFO_MAP_TO_FUNCTION flag so the first argument >> > (*if* it's defined as resource) will be skipped. >> >> > On a related note, I find it kinda silly we don't offer argument info >> > (except from spl) so I made a patch for ext/dom[2], ext/xsl[3] and >> > ext/reflection[4]. >> > I'd like to take down the rest, of at least the OO once.. >> > Any thoughts? >> >> > -Hannes >> >> > [1] http://php.is/bugs/arg_info/ZEND_ARG_RESOURCE.HEAD.patch.txt >> > [2] http://php.is/bugs/arg_info/arginfo.dom.patch.txt >> > [3] http://php.is/bugs/arg_info/arginfo.xsl.patch.txt >> > [4] http://php.is/bugs/arg_info/arginfo.reflection.patch.txt >> >> I comitted the last one and you have commit rights so you can apply >> the rest to php-src. > Thanks! :)
>> For the engine stuff you still need somebody >> else to commit but first you need to discuss the change. To me that >> patch looks good, though i'd change ZEND_ACC_INFO_MAP_TO_FUNCTION >> to ZEND_ACC_MAP_TO_FUNCTION. Andi, Zeev?
> I think ZEND_ACC_MAP_TO_FUNCTION sound like it does more then filter > the arginfo..., ZEND_ACC_INFO_MAP_TO_FUNCTION is more clear, imo, that > it "only cares about" the arginfo.
So it is more a ZEND_COPY_ARGINFO_FROM_FUNCTION and not an ACC flag we want to store in the flags of struct zend_function. Best regards, Marcus

Hannes Magnusson

20 years ago
Hi Marcus On 6/8/06, Marcus Boerger <helly@php.net> wrote:
> Hello Hannes, > > Thursday, June 8, 2006, 12:37:09 PM, you wrote: > > > Hi Marcus > > > On 6/8/06, Marcus Boerger <helly@php.net> wrote: > >> Hello Hannes, > >> > >> Monday, May 29, 2006, 8:52:51 PM, you wrote: > >> > >> > Hi all > >> > >> > I've created a patch[1] that welcomes new friend into the > >> > zend_arg_info family, resource, and a new flag for ZEND_ME_MAPPING and > >> > pals, ZEND_ACC_INFO_MAP_TO_FUNCTION. > >> > >> > The idea is to make it easier to define argument info for those > >> > extensions who map methods to functions which require some kind of > >> > resource as its first argument. > >> > >> > Since the methods don't take any resource argument one would need to > >> > define two arg_info, one for the function and one for the method, with > >> > the only difference being the first parameter. > >> > This patch lets you however define the first argument as a resource > >> > (ZEND_ARG_RESOURCE_INFO) and then when you register the method you can > >> > pass the ZEND_ACC_INFO_MAP_TO_FUNCTION flag so the first argument > >> > (*if* it's defined as resource) will be skipped. > >> > >> > On a related note, I find it kinda silly we don't offer argument info > >> > (except from spl) so I made a patch for ext/dom[2], ext/xsl[3] and > >> > ext/reflection[4]. > >> > I'd like to take down the rest, of at least the OO once.. > >> > Any thoughts? > >> > >> > -Hannes > >> > >> > [1] http://php.is/bugs/arg_info/ZEND_ARG_RESOURCE.HEAD.patch.txt > >> > [2] http://php.is/bugs/arg_info/arginfo.dom.patch.txt > >> > [3] http://php.is/bugs/arg_info/arginfo.xsl.patch.txt > >> > [4] http://php.is/bugs/arg_info/arginfo.reflection.patch.txt > >> > >> I comitted the last one and you have commit rights so you can apply > >> the rest to php-src. > > Thanks! :) > > >> For the engine stuff you still need somebody > >> else to commit but first you need to discuss the change. To me that > >> patch looks good, though i'd change ZEND_ACC_INFO_MAP_TO_FUNCTION > >> to ZEND_ACC_MAP_TO_FUNCTION. Andi, Zeev? > > > I think ZEND_ACC_MAP_TO_FUNCTION sound like it does more then filter > > the arginfo..., ZEND_ACC_INFO_MAP_TO_FUNCTION is more clear, imo, that > > it "only cares about" the arginfo. > > So it is more a ZEND_COPY_ARGINFO_FROM_FUNCTION and not an ACC flag > we want to store in the flags of struct zend_function.
Pretty much, yes - bundled with ZEND_ACC_PUBLIC -Hannes