Skip to content
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

Get name of native code function #1346

Open
RoyalFoxy opened this issue Oct 9, 2023 · 0 comments
Open

Get name of native code function #1346

RoyalFoxy opened this issue Oct 9, 2023 · 0 comments

Comments

@RoyalFoxy
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant