A
Alexander Adam
Hi!
I've got an issue. I have more or less an internal class model for
which I want to write various bindings e.g. for Windows COM. Now I've
figured to make my internal classes based on IDispatchEx which works
fine. The biggest pain I have right now is that I need to register
properties and methods dynamically and I need to call those
dynamically, too. Take the following example:
struct method {
short calltype; // 0=property_get, 1=property_set, 2=method
unsigned id;
const char* name;
int* params;
}
class A :
public MyTemplate<A>
{
public:
BEGIN_METHODS(A)
METHOD(0, "something", 1, {})
METHOD(1, "something", 2, {})
METHOD(2, "doSomething", 3, {4,5,2})
END_METHODS
public:
// Properties
virtual std::string get_Something();
virtual void set_Something(const std::string& name);
// Methods
virtual void doSomething();
}
Now in myTemplate I have two functions called from outside, one to get
an unique id for the given name and type and one for calling it. The
question I have is this:
The biggest pain is that I've wanted to call the functions that I have
registered with METHOD() macro directly, passing the parameters
dynamically as an array. But as I'd require my own call stack frame
and my asm knowledge is not the best, I've thought to create two
functions within my BEGIN_METHODS and END_METHODS macros that is, one
for registering the functions which could look like
static const method* _get_methods()
{
...
}
and one that calls it like
void _call_method(int id, params* p)
{
switch( id)
{
case 2: doSomething(p[0].int, p[1].double);
....
}
Now as you can see the issue I have is that I cannot have my Macros
declare two independant functions that is, to be able to create a
_get_methods and a _call_method routine, I'd need to redeclare
evertything like this:
class A :
public MyTemplate<A>
{
public:
BEGIN_METHODS(A) // _get_methods()
METHOD(0, "something", 1, {})
METHOD(1, "something", 2, {})
METHOD(2, "doSomething", 3, {4,5,2})
END_METHODS
BEGIN_METHODS2(A) // _call_method
METHOD(0, (p[0].int, p[1].double))
END_METHODS2
public:
// Properties
virtual std::string get_Something();
virtual void set_Something(const std::string& name);
// Methods
virtual void doSomething();
}
You might see my issue here -- I have to declare everything twice
which is not really nice.
So after fighting and trying and everything for days, I was hoping
that someone could help me out here with a smart advice, hint, help or
anything?
Thanks and Regards
Alexander
I've got an issue. I have more or less an internal class model for
which I want to write various bindings e.g. for Windows COM. Now I've
figured to make my internal classes based on IDispatchEx which works
fine. The biggest pain I have right now is that I need to register
properties and methods dynamically and I need to call those
dynamically, too. Take the following example:
struct method {
short calltype; // 0=property_get, 1=property_set, 2=method
unsigned id;
const char* name;
int* params;
}
class A :
public MyTemplate<A>
{
public:
BEGIN_METHODS(A)
METHOD(0, "something", 1, {})
METHOD(1, "something", 2, {})
METHOD(2, "doSomething", 3, {4,5,2})
END_METHODS
public:
// Properties
virtual std::string get_Something();
virtual void set_Something(const std::string& name);
// Methods
virtual void doSomething();
}
Now in myTemplate I have two functions called from outside, one to get
an unique id for the given name and type and one for calling it. The
question I have is this:
The biggest pain is that I've wanted to call the functions that I have
registered with METHOD() macro directly, passing the parameters
dynamically as an array. But as I'd require my own call stack frame
and my asm knowledge is not the best, I've thought to create two
functions within my BEGIN_METHODS and END_METHODS macros that is, one
for registering the functions which could look like
static const method* _get_methods()
{
...
}
and one that calls it like
void _call_method(int id, params* p)
{
switch( id)
{
case 2: doSomething(p[0].int, p[1].double);
....
}
Now as you can see the issue I have is that I cannot have my Macros
declare two independant functions that is, to be able to create a
_get_methods and a _call_method routine, I'd need to redeclare
evertything like this:
class A :
public MyTemplate<A>
{
public:
BEGIN_METHODS(A) // _get_methods()
METHOD(0, "something", 1, {})
METHOD(1, "something", 2, {})
METHOD(2, "doSomething", 3, {4,5,2})
END_METHODS
BEGIN_METHODS2(A) // _call_method
METHOD(0, (p[0].int, p[1].double))
END_METHODS2
public:
// Properties
virtual std::string get_Something();
virtual void set_Something(const std::string& name);
// Methods
virtual void doSomething();
}
You might see my issue here -- I have to declare everything twice
which is not really nice.
So after fighting and trying and everything for days, I was hoping
that someone could help me out here with a smart advice, hint, help or
anything?
Thanks and Regards
Alexander