Skip to content

Function proxies should return the underlying function rather than wrapping it in another function proxy #65

@zollqir

Description

@zollqir

Currently, when a python function is passed to JS it gets wrapped in a JS function in jsTypeFactory.hh called callPyFunc. If JS then returns that function back to python, it wraps it in a python function in pyTypeFactory.hh called callJSFunc. A similar thing happens in the other direction when starting with a JS function.

What should happen is that when a wrapped python function is returned back to python, it gets unwrapped and the original function is passed back. Conversely, when a wrapped JS function is returned back to JS, it should get unwrapped and the original function passed back.

As an example, the following should be able to pass:

import pythonmonkey as pm
def pyFunc():
  return 0
unwrappedPyFunc = pm.eval("(wrappedPyFunc) => { return wrappedPyFunc; }")(pyFunc)
assert unwrappedPyFunc is pyFunc
import pythonmonkey as pm
wrappedJSFunc = pm.eval(" const JSFunc = () => { return 0; };\nJSFunc;")
assert pm.eval("(unwrappedJSFunc) => { return unwrappedJSFunc === JSFunc; }")(wrappedJSFunc)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions