Skip to content

Commit

Permalink
feat: C++/JS proxy functions
Browse files Browse the repository at this point in the history
Define JS proxy types for functions to allow complete interoperability between C++ and JS functions.

When accessing a JS function in C++, the dom::Function contains a reference to the Scope variable with the JS function. The JS execution context will evaluate this function in JS and convert the result back to dom::Value.

When accessing a C++ function in JS, the JS object will contain a hidden buffer to store a copy of the original dom::Function. When JS executes the function, it will get the original dom::Function from this hidden buffer, convert all arguments to dom::Value, call the original dom::Function, and push the dom::Value result to the stack. When the function is garbage collected, the object finalization callback destroys the function stored in the buffer.
  • Loading branch information
alandefreitas committed Nov 24, 2023
1 parent da84105 commit 58e4cec
Show file tree
Hide file tree
Showing 2 changed files with 305 additions and 66 deletions.
Loading

0 comments on commit 58e4cec

Please sign in to comment.