-
Notifications
You must be signed in to change notification settings - Fork 49
ucode: Add 'operator execute' #326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
IdWV
wants to merge
8
commits into
jow-:master
Choose a base branch
from
IdWV:operator_exec
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
It can be useful to call a resource as if it was a function. This commit adds a way to do so. When a non-callable is supplied to uc_vm_insn_call(), and it is an object or has a prototype, then the object/prototype stack is searched for a callable named 'operator()', and if found, that is called instead. So in the script var(...); is a functional synonym to var['operator()'](); Signed-off-by: Isaac de Wolff <idewolff@vincitech.nl>
Owner
|
I like the idea, it goes into the direction of Lua's metamethods. A couple of remarks:
|
Contributor
Author
|
Contributor
Author
Is is OK to change the inline function to an exported function? |
Owner
|
Yes, should be fine |
Implement two new formats `X` and `Z` which encode/decode C memory to/from hexadecimal and base64 strings, respectively. This is useful to extract binary data payloads from a given structure buffer directly into ucode string encoded in a printable format suitable for use in JSON objects and similar formats requiring printable character encoding. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This uses socketpair() to return a pair of connected sockets. The function returns an array with a socket instance as the first element and a file descriptor number for the other side. Signed-off-by: Felix Fietkau <nbd@nbd.name>
This opens an existing file descriptor as a socket instance. Can be used to use open sockets received through ubus. Signed-off-by: Felix Fietkau <nbd@nbd.name>
- Verify the instruction number before using it as index into the `insn_names` and `insn_operand_bytes` arrays to avoid reading past the end of those arrays. - Decode `UVAL` sub-instruction as u8, not u32 Fixes: jow-#321 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Handle TXT records with multiple string elements by space-joining the individual substrings. Also introduce a new, default dsabled boolean option `txt_as_array` which makes the resolv module to return TXT record values as ucode arrays containing the individual strings as elements. Fixes: jow-#315 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
The current implementation of rand() returns a number in an unknown (to
the ucode script) range. This commit adds an optional range to rand().
For example the call
let r = math.rand( 7, -3.1 );
returns a number in the range 7 ... -3.1, inclusive.
Signed-off-by: Isaac de Wolff <idewolff@vincitech.nl>
[align code style, minor whitespace spaces & rewrapping]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Signed-off-by: Isaac de Wolff <idewolff@vincitech.nl>
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.
It can be useful to call a resource as if it was a function. This commit adds a way to do so.
When a non-callable is supplied to uc_vm_insn_call(), and it is an object or has a prototype, then the object/prototype stack is searched for a callable named 'operator()', and if found, that is called instead.
So in the script
var(...); is a functional synonym to var'operator()';