Supporting anonymous PHP closures / callbacks from Lua - #2
Merged
Merged
Conversation
Owner
|
I think this idea is great. thanks very much, I will do some test then merge it. thanks :) |
Contributor
Author
|
Thanks! Did you already have some time for testing? |
laruence
added a commit
that referenced
this pull request
Oct 18, 2013
Supporting anonymous PHP closures / callbacks from Lua
Open
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I thought it would be cool to have the possibility to provide a PHP callback to a Lua function or return it from a call from Lua to PHP, without having to register it as callback first. Please have a look at the test i added (013.phpt) for details. I must admit, that i do not have much experience with php core development / extension development, so my code may contain serious issues. I more or less copied the stuff from "registerCallback" function.
I am not sure if this is the right way to do it, anyway, because function names as strings is not supported with this solution (how to determine if the user intended to provide a function name with the string value provided as return value or function parameter?). I hade to move the "php_lua_call_callback" method in the source file to prevent a compilation issue on osx (php_lua_call_callback defined after php_lua_send_zval_to_lua), just in case you wonder ...