Get name of native code function
RoyalFoxy opened this issue · 0 comments
I'm currently facing a wall where I need to somehow get a single string into a native code function. Obviously I cannot just let the closure capture it as that would make the closure sized and that's a no go for how rusty_v8 is implemented.
I tried several methods ranging from trying a javascript child function which returns the callers name which works if the caller is a javascript function (tested in node.js) but not if the caller is a native code function which returns null.
// This is a (deprecated) function that would return the name of the parent function
function get_name() {
const caller = arguments.callee.caller;
return caller ? caller.name : null;
}
I also looked at the args.this()
which I assume is the global context which matches up with javascript. I looked at the Function type in rusty_v8 and it seems to have getter and setter for it's name which is great! The problem here lies in the small detail that I have no clue how to get the actual function itself in the function. In javascript you can basically just reference the function like this
function return_myself() {
return return_myself;
}
This works in javascript but you cannot do that in rust, not considering we're dealing with a closure here anyways...
I'd really like help on this manner as I'm lost and I can't find any documentation explaining how to get the name of the currently executed function.