Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views


Sign in to follow this  


Ack, I know no one cares about my Pythong blabbery, but I've been spending a lot of time thinking about it (in one way or another). Anyway.

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 {
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.


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.

Sign in to follow this  


Recommended Comments

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.

That's why I use AngelScript. I wouldn't touch python with a 10' stick.

Share this comment

Link to comment
whoa, it is. I'll have to put in a work request, thanks for bringing that to my attention!

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!