pmed / v8pp

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

Support for external properties #135

Closed cr-mitmit closed 2 years ago

cr-mitmit commented 4 years ago

Patch add support for "External" property functions. This allows adding to v8pp::class_ properties in the form of T(X const &) for getters and void (X&, T&) for setters. This makes the following code valid .set("lrprop", v8pp::property( [](const X& x) {return x.var; } )) which means that when the user in Javascript calls x = new X(); x.lprop the lambda will get called with unwrapped X as the parameter.

Nelson-numerical-software commented 2 years ago

any reason that it was not merged ?

pmed commented 2 years ago

any reason that it was not merged ?

Hi,

this feature has already been implemented on c++17 branch, that was recently merged onto the master one.

A usage example is in a test case: https://github.com/pmed/v8pp/blob/master/test/test_class.cpp#L171-L172

So I'm going to close this pull request.