pmed / v8pp

Bind C++ functions and classes into V8 JavaScript engine
http://pmed.github.io/v8pp/
Other
901 stars 121 forks source link

Support lambdas as v8pp::property() getters and setters #93

Open VitaminCpp opened 6 years ago

VitaminCpp commented 6 years ago

This is a critical issue, because currently I'm not able to inject C++-only parameters into v8pp::module exported modules.

JS: var myVar = objectA.objectB.object.C.prop;

C++:

v8pp::module objectA(ctx.isolate());
v8pp::module objectB(ctx.isolate());
v8pp::module objectC(ctx.isolate());

std::string myProp = "myProb";

objectB
  .set("objectC", objectC);
  .set("prop", v8pp::property([myProp] { return myProp; }); // <- doesn't work!

objectA.set("objectB", objectB);
pmed commented 6 years ago

Seems to be related to #72

I have a local branch with some work-in-progress for this issue, but have no spare time to complete it.

atvise commented 6 years ago

Hi @pmed,

can I help you to implement this in any way ?

pmed commented 5 years ago

Hi @VitaminCpp

The changes from PR #72 were merged to version-2.0 branch, but I'm not sure they would be backported to the master.