would need to be able to bind a method, which is inherited by the
bound class.
What I have until now is a bit low-level, centered around
a templated class, but otherwise does not use much templates, but
macros. I needed this low-level to be able for example to have js
functions with variable arguments or with arguments that can be a
different type.
...MethodToInCa - family of templates, you specify the native method
prototype via the function-like notation, e.g. int(char, float). This
signature is not directly compatible with a method signature, e.g.
int(T::*)(char, float). Also, I would need to extract the argument
types one by one from such a signature.
I tried to fund out how you do
it, but your code, even though very clean and well documented, is too
much for my experience with templates. So my question is - how can it
be done?
> If you figure out a good way to do that let me know. i don't think my
> current binding code can do that.
Should be doable, what do you think is the difficulty?
> If your class binding mechanism is in a
> usable state i'd love to see it.
I am currently working on it, still not even compiled anything. I will
send you the code when
I'm ready with something working.
The lower-level layer binding class is based on something they seem to
call "curiously recurring template pattern":
http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern
I remember that I asked you if this approach is portable, or is just a
something that
the particular compiler lets me do. You said it seems fairly portable.
Indeed,
it seems it's quite heavily used in practice.
With the lower-layer, to implement bindings to existing libraries, I
had the wrapper
class proxy the calls from the wrapper to the native library's API,
it's nothing special. I
implemented a lot of convenience macros to ease this task, but still
this is quite tedious.
Hence the higher layer that I decided to implement.
The basic idea there is to have two native classes - a 'wrapper' and a
' native'.
The native is a class that is not aware of V8, and the wrapper is a
glue between
v8 and the native. So far, the lower-level layer had only the notion
of 'wrapper', and all native
implementation was in that wrapper.
>cvv8 can do that to some degree:
>http://code.google.com/p/v8-juice/wiki/V8Convert_Overloading
Wow, I have seen the arity dispatcher mentioned, but didn't know cvv8
was able to dispatch
based on argument type. I should look at the code, but I'm not sure
if I will understand
how it is done with all the template tricks:)
>The synax (returnType (arg1,arg2)) is really just a convenience form which
>gets internally translated, via template specializations, to (returnType
>(T::*)(arg1,arg2)), and the templates do in fact provide enough type
>information to extract the parts you're looking for. Can you show me your
>(hypothetical) use case?
I am trying to build something universal like MethodToInCa, and would
love to have the method signature specified
in this way. Currently I specify it via separate template arguments.
>See examples/ConvertDemo.cpp and search for:
> void test_new_typelist()
These are examples for the user, I was trying to understand how it is
implemented.
>The framework-level code can tell you the argument count and types and such
Isn't the signature in question a single atomic typename template
argument? How can it be broken down?
I exampiend the code in signature_core.hpp and
signature_generated.hpp, but I couldnt find
the place where the signature is broken down to separate types. I saw
template recursion,
but this was in the case where arguments are provided as separate
template params.
Is it possible to post files here? I'd like to send you my existing
implementation
Greetings
Alex
Heyas :)
Should be doable, what do you think is the difficulty?
> If you figure out a good way to do that let me know. i don't think my
> current binding code can do that.
call "curiously recurring template pattern":http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern
Hence the higher layer that I decided to implement.
The basic idea there is to have two native classes - a 'wrapper' and a
' native'.
The native is a class that is not aware of V8, and the wrapper is a
glue between
v8 and the native. So far, the lower-level layer had only the notion
of 'wrapper', and all native
implementation was in that wrapper.
Wow, I have seen the arity dispatcher mentioned, but didn't know cvv8
was able to dispatch
based on argument type.
>See examples/ConvertDemo.cpp and search for:These are examples for the user, I was trying to understand how it is
> void test_new_typelist()
implemented.
Isn't the signature in question a single atomic typename template
>The framework-level code can tell you the argument count and types and such
argument? How can it be broken down?
I exampiend the code in signature_core.hpp and
signature_generated.hpp, but I couldnt find
the place where the signature is broken down to separate types. I saw
template recursion,
Is it possible to post files here? I'd like to send you my existing
implementation