I've been working out how the shared data stuff is supposed to work. And I've got a prototype working, but it isn't pretty at all. And its only going to get worse from here; its hard as hell to make a nice user interface.
Anyway. For us to use our C structs in Pythong we have to prefix them with a bunch of Pythong data headers so Pythong knows how to eat it. This is easily wrappered -
template < class T >struct WRAPPER { PyObject_HEAD T data;};
Cool. So now we can just instantiate an instance of that template to create a wrappered version of the user's structs.
But then SHilbert came a long and was like "lol how do you handle live references?" and I was like "wtf.... OH DAMMIT".
Basically, if you declare yourself an instance of your user struct, say -
struct foo { ... };
void blah() {
foo myfoo;
call( "some_python_func", myfoo ); // takes a reference.
}
What happens is that struct foo has to get converted to struct WRAPPER. Which means a copy construction. Which means you're getting data passed by-value, not by-reference.
BUT WAIT!
What if, from Pythong -
myfoo = foo();
call( "some_c_func", myfoo );
The Pythong->C function handler will be called, and extract the struct foo from the struct WRAPPER* passed up from Pythong, then pass that (hopefully by refernce) to the expectant C-function. WHICH MEANS ITS BEING PASSED BY REFERENCE.
I'm not really sure what to do about this. I'm really really tempted to leave it like this, because, honestly, that's good enough for me. Wish I could do it by-ref both ways, but the limitations of C make it not so.
Opinions?
That's why I use AngelScript. I wouldn't touch python with a 10' stick.