Closed GoogleCodeExporter closed 8 years ago
Original comment by sgbeal@googlemail.com
on 11 Oct 2009 at 7:28
i'm a moron: i've been attacking this from the angle of binding native member
funcs
to native member vars, which is not at all what we need/want here. We need to
bind
native member functions to JS member properties. That sounds much more doable.
Original comment by sgbeal@googlemail.com
on 13 Oct 2009 at 2:01
Rough (proof of concept) impl is in r719.
i've run into the problem that the getter and setter MUST (because of
limitations of
the v8 API) be defined at the same time. Calling this binding is REALLY ugly
right
now, largely because the setter may return an arbitrary type (which is ignored
for
this purpose) and may take a different argument type than the getter. So i'd
like to
find a way to clean up the call, which currently looks like:
struct my_native
{
std::string str;
private:
int proxied;
public:
int propGetter() const
{
CERR << "my_native::propGetter()\n";
return this->proxied;
}
int propSetter(int v)
{
CERR << "my_native::propSetter("<<v<<")\n";
return this->proxied = v;
}
...
};
binder.BindPropToMemFuncs< int, &MY::propGetter, int, int, &MY::propSetter >(
"proxiedProp" );
TODOs:
- Overloads for various constnesses (constessi?).
- Overloads for setting either getter or setter without requiring the other
(with the
caveat that calling both may overwrite the one which is called first with a null
accessor).
- Various typing-related overloads, to handle the case where the pass/return
types
are all the same.
Original comment by sgbeal@googlemail.com
on 15 Oct 2009 at 8:25
r720 in the "edge" branch implements most of what we need here, i think. It's
possible to bind a getter/setter combination, or a getter-only, but not a
setter-only
because v8 craps out if we do that (crashes because getter is 0).
There may be touch-ups to do here, but it's working for the basic cases.
Original comment by sgbeal@googlemail.com
on 15 Oct 2009 at 10:24
Original issue reported on code.google.com by
sgbeal@googlemail.com
on 11 Oct 2009 at 7:28