Original Post
Hi !
I'm currently developping a meta programming system for the registration of class which takes automatically of the generation of generic bindings if and only if the AX_MAX_PORTABILITY is set. Otherwise, the native calling convention is used.
This makes the following possible in C++ code:
Class< MyClass > class("MyClass")
[
MemberFunction( "void DoSomethingA()", MyClass::&DoSomethingA ),
MemberFunction( "void DoSomethingB()", MyClass::&DoSomethingB )
];
GlobalRegistry registry(GetASEngine());
class.Register(registry);
Ultimately, a single function is called for each member function receiving a asIScriptGeneric* pointer when I compile on a platform with AS_MAX_PORTABILITY defined.
template< InvokerType >
void GenericMemberFunctionDispatch( asIScriptGeneric* generic )
{
ASSERT( generic, "AngelScript failed to provide a generic interface.");
MarshallingAgent agent(generic);
InvokerType invoker(functionPtr);
invoker(agent);
}
I'll spare you the details of the Invoker system, which is heavy on meta-programming ( but we have used it extensively in other areas of our pipeline and in other instances where we did integrate scripting solutions ).
However, I have a small (huge) problem. I need to pass a function pointer to the invoker, the real function to call actually.
I either have two choices :
Maintain a mapping of function id to function pointer : I don't particularly like this solution since I'll probably generate a lot of cache misses due to the nature of a map object and that would pain me dearly.
Add user data to a function registration, i.e.: in my case the function ptr. Therefore I could do :
InvokerType invoker(generic->GetUserData());
I know that you're probably wondering : What the hell, why isn't he using the autowrapper ?
Well, mainly, because I want to keep it as simple as possible for people to register their object types and the system in all circumstances, without having to worry about the generic convention, since I work with some platforms not yet supporting the native calling convention.
So, do you think it would be possible to add a user data as an optional parameter ? If so I might get to it !
registry->RegisterObjectMethod(GetName(), asFUNCTION((GenericMemberFunctionInvoker)), asCALL_GENERIC, m_functionPtr);
I'm currently developping a meta programming system for the registration of class which takes automatically of the generation of generic bindings if and only if the AX_MAX_PORTABILITY is set. Otherwise, the native calling convention is used.
This makes the following possible in C++ code:
Class< MyClass > class("MyClass")
[
MemberFunction( "void DoSomethingA()", MyClass::&DoSomethingA ),
MemberFunction( "void DoSomethingB()", MyClass::&DoSomethingB )
];
GlobalRegistry registry(GetASEngine());
class.Register(registry);
Ultimately, a single function is called for each member function receiving a asIScriptGeneric* pointer when I compile on a platform with AS_MAX_PORTABILITY defined.
template< InvokerType >
void GenericMemberFunctionDispatch( asIScriptGeneric* generic )
{
ASSERT( generic, "AngelScript failed to provide a generic interface.");
MarshallingAgent agent(generic);
InvokerType invoker(functionPtr);
invoker(agent);
}
I'll spare you the details of the Invoker system, which is heavy on meta-programming ( but we have used it extensively in other areas of our pipeline and in other instances where we did integrate scripting solutions ).
However, I have a small (huge) problem. I need to pass a function pointer to the invoker, the real function to call actually.
I either have two choices :
Maintain a mapping of function id to function pointer : I don't particularly like this solution since I'll probably generate a lot of cache misses due to the nature of a map object and that would pain me dearly.
Add user data to a function registration, i.e.: in my case the function ptr. Therefore I could do :
InvokerType invoker(generic->GetUserData());
I know that you're probably wondering : What the hell, why isn't he using the autowrapper ?
Well, mainly, because I want to keep it as simple as possible for people to register their object types and the system in all circumstances, without having to worry about the generic convention, since I work with some platforms not yet supporting the native calling convention.
So, do you think it would be possible to add a user data as an optional parameter ? If so I might get to it !
registry->RegisterObjectMethod(GetName(), asFUNCTION((GenericMemberFunctionInvoker