-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EG(arg_types_stack) is now also backed up when generators are used. This allows the use of yield in nested method calls. This commit adds two new functions to the zend_ptr_stack API: zend_ptr_stack_push_from_memory zend_ptr_stack_pop_into_memory both taking the following arguments: zend_ptr_stack *stack, int count, void **pointers
- Loading branch information
Showing
5 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--TEST-- | ||
Yield can be used in nested method calls | ||
--FILE-- | ||
<?php | ||
|
||
class A { | ||
function foo() { | ||
echo "Called A::foo\n"; | ||
} | ||
} | ||
|
||
class B { | ||
function foo() { | ||
echo "Called B::foo\n"; | ||
} | ||
} | ||
|
||
function gen($obj) { | ||
$obj->foo($obj->foo(yield)); | ||
} | ||
|
||
$g1 = gen(new A); | ||
$g1->current(); | ||
|
||
$g2 = gen(new B); | ||
$g2->current(); | ||
|
||
$g1->next(); | ||
|
||
$g3 = clone $g2; | ||
unset($g2); | ||
$g3->next(); | ||
|
||
?> | ||
--EXPECT-- | ||
Called A::foo | ||
Called A::foo | ||
Called B::foo | ||
Called B::foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,8 @@ ZEND_API void zend_ptr_stack_destroy(zend_ptr_stack *stack); | |
ZEND_API void zend_ptr_stack_apply(zend_ptr_stack *stack, void (*func)(void *)); | ||
ZEND_API void zend_ptr_stack_clean(zend_ptr_stack *stack, void (*func)(void *), zend_bool free_elements); | ||
ZEND_API int zend_ptr_stack_num_elements(zend_ptr_stack *stack); | ||
ZEND_API void zend_ptr_stack_push_from_memory(zend_ptr_stack *stack, int count, void **pointers); | ||
ZEND_API void zend_ptr_stack_pop_into_memory(zend_ptr_stack *stack, int count, void **pointers); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
nikic
Author
Member
|
||
END_EXTERN_C() | ||
|
||
#define ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, count) \ | ||
|
Why a new function? Cannot use the n_push APIs?