All,
Back on the topic of trying to write a 'filled' function in an
extension, I have run into trouble. I have declared a function as follows:
---------- 8< -------------------- 8< ----------
static
ZEND_BEGIN_ARG_INFO(all_args_prefer_ref, ZEND_SEND_PREFER_REF)
ZEND_END_ARG_INFO()
zend_function_entry shorthand_functions[] = {
PHP_FE(filled, all_args_prefer_ref)
{NULL, NULL, NULL} /* Must be the last line in
shorthand_functions[] */
};
PHP_FUNCTION(filled)
{
RETURN_TRUE;
}
---------- 8< -------------------- 8< ----------
Then, in PHP I try the following test code:
---------- 8< -------------------- 8< ----------
<?php
$x = array();
$x["dog"] = "spot";
$x["cat"] = "moriss";
print_r($x);
// testing
print filled("testing", $x["pig"], $y->testing);
print "\n";
print_r($x);
print_r($y);
?>
---------- 8< -------------------- 8< ----------
Unfortunately, $x now contains a 'pig' key and the non-existent $y has
been transformed into an object:
---------- 8< -------------------- 8< ----------
Array
(
[dog] => spot
[cat] => moriss
)
1
Array
(
[dog] => spot
[cat] => moriss
[pig] =>
)
stdClass Object
(
[testing] =>
)
---------- 8< -------------------- 8< ----------
Is there a way to define the parameters which an extension's function
will accept to be optionally set? The prefer-by-ref I am using is
making the var exist even when I don't want it to.
Dante
On Fri, 26 May 2006 15:45:19 -0500
dante@vocalspace.com ("D. Dante Lorenso") wrote:
All,
Back on the topic of trying to write a 'filled' function in an
extension, I have run into trouble. I have declared a function as
follows:
It is perfectly normal and desired.
The variable is fetched before entering your function. This fetch
operation raises a E_NOTICE, create/initialize the ZVAL and pass it to
your function.
-- Pierre
Pierre wrote:
On Fri, 26 May 2006 15:45:19 -0500
dante@vocalspace.com ("D. Dante Lorenso") wrote:Back on the topic of trying to write a 'filled' function in an
extension, I have run into trouble. I have declared a function as
follows:It is perfectly normal and desired.
Not desired.
The variable is fetched before entering your function. This fetch
operation raises a E_NOTICE, create/initialize the ZVAL and pass it to
your function.
You miss the point. If the ZVAL was created and initialized already,
then I wouldn't be performing this exercise. It is because the ZVAL has
not been created that I am writing this extension.
Dante
It is perfectly normal and desired.
Not desired.
It is by design.
The variable is fetched before entering your function. This fetch
operation raises a E_NOTICE, create/initialize the ZVAL and pass it to
your function.You miss the point. If the ZVAL was created and initialized already,
then I wouldn't be performing this exercise. It is because the ZVAL has
not been created that I am writing this extension.
I have no idea about what exercise you are talking about, but my
explanation is correct. If you do not understand it, please let me
know which part you don't get.
--Pierre
Hello D.,
you are looking for ZEND_BEGIN_ARG_INFO_EX(), the names of the macro
parameters are self speaking.
best regards
marcus
Friday, May 26, 2006, 10:45:19 PM, you wrote:
All,
Back on the topic of trying to write a 'filled' function in an
extension, I have run into trouble. I have declared a function as follows:
---------- 8< -------------------- 8< ----------
static
ZEND_BEGIN_ARG_INFO(all_args_prefer_ref, ZEND_SEND_PREFER_REF)
ZEND_END_ARG_INFO()
zend_function_entry shorthand_functions[] = {
PHP_FE(filled, all_args_prefer_ref)
{NULL, NULL, NULL} /* Must be the last line in
shorthand_functions[] */
};
PHP_FUNCTION(filled)
{
RETURN_TRUE;
}
---------- 8< -------------------- 8< ----------
Then, in PHP I try the following test code:
---------- 8< -------------------- 8< ----------
<?php
$x = array();
$x["dog"] = "spot";
$x["cat"] = "moriss";
print_r($x);
// testing
print filled("testing", $x["pig"], $y->testing);
print "\n";
print_r($x);
print_r($y);
?>>
---------- 8< -------------------- 8< ----------
Unfortunately, $x now contains a 'pig' key and the non-existent $y has
been transformed into an object:
---------- 8< -------------------- 8< ----------
Array
(
[dog] => spot [cat] => moriss
)
1
Array
(
[dog] => spot
[cat] => moriss
[pig] =>
)
stdClass Object
(
[testing] =>
)
---------- 8< -------------------- 8< ----------
Is there a way to define the parameters which an extension's function
will accept to be optionally set? The prefer-by-ref I am using is
making the var exist even when I don't want it to.
Dante
Best regards,
Marcus
Back on the topic of trying to write a 'filled' function in an
extension, I have run into trouble. I have declared a function as
follows:Unfortunately, $x now contains a 'pig' key and the non-existent $y has
been transformed into an object:
Short answer: No. What you're trying to do can not be done from an
extension.
-Sara
Sara Golemon wrote:
Back on the topic of trying to write a 'filled' function in an
extension, I have run into trouble. I have declared a function as follows:
...
Unfortunately, $x now contains a 'pig' key and the non-existent $y has
been transformed into an object:
Short answer: No. What you're trying to do can not be done from an
extension. -Sara
Can I have this feature added to the TODO list for 5.2 or 6.0?
Simple behavior definition: any ZVAL which does not exist for an
extension's function (which doesn't care about the ZVAL's existence)
should pass a newly created NULL
ZVAL to the extension in place of the
non-existent ZVAL and the non-existent ZVAL will continue to not exist
after the function returns.
Dante
The E_NOTICE
highlights a possible programmer error.
If you don't want to see it, turn off E_NOTICE
level in your error
reporting settings.
--Wez.
Sara Golemon wrote:
Back on the topic of trying to write a 'filled' function in an
extension, I have run into trouble. I have declared a function as follows:
...
Unfortunately, $x now contains a 'pig' key and the non-existent $y has
been transformed into an object:
Short answer: No. What you're trying to do can not be done from an
extension. -SaraCan I have this feature added to the TODO list for 5.2 or 6.0?
Simple behavior definition: any ZVAL which does not exist for an
extension's function (which doesn't care about the ZVAL's existence)
should pass a newly createdNULL
ZVAL to the extension in place of the
non-existent ZVAL and the non-existent ZVAL will continue to not exist
after the function returns.Dante
The
E_NOTICE
highlights a possible programmer error.
If you don't want to see it, turn offE_NOTICE
level in your error
reporting settings.
But he's specifically working on something to allow the developer to
eliminate the warnings because the developer has thought about the use
first. In short he's attempting to create a more succinct structure that
will increase code clarity but is coming up against an extension
limitation.
Cheers,
Rob.
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
Any uninitialized variable is a potential programmer error.
Again, if you don't want the notices, turn them off.
If you want "safe" code, turn them on and respect them.
--Wez.
The
E_NOTICE
highlights a possible programmer error.
If you don't want to see it, turn offE_NOTICE
level in your error
reporting settings.But he's specifically working on something to allow the developer to
eliminate the warnings because the developer has thought about the use
first. In short he's attempting to create a more succinct structure that
will increase code clarity but is coming up against an extension
limitation.Cheers,
Rob..------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
I think he's trying to solve the infamous issetor() in an extension...
Regards
Alan
Wez Furlong wrote:
Any uninitialized variable is a potential programmer error.
Again, if you don't want the notices, turn them off.
If you want "safe" code, turn them on and respect them.--Wez.
The
E_NOTICE
highlights a possible programmer error.
If you don't want to see it, turn offE_NOTICE
level in your error
reporting settings.But he's specifically working on something to allow the developer to
eliminate the warnings because the developer has thought about the use
first. In short he's attempting to create a more succinct structure that
will increase code clarity but is coming up against an extension
limitation.Cheers,
Rob..------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'