[C++-sig] pointers and pyste

Sameer Agarwal sagarwal at cs.ucsd.edu
Sun Apr 27 20:40:36 CEST 2003


Hello Boosters,
thank you for a wonderful library. I am a c++ newbie trying to write a 
ray tracer and making it scriptable in python using boost. I have had a 
fair amount of success but I have a question to which the answer was 
not entirely clear in the documentation or the faq.

I have a c++ class which stores pointers to a set of c++ objects


class B
{
	void render()
}
class A
{
	list<B*> blist;
	void add_b(B*)
	{
		blist.push_back(B*)
	}
	
	void render()
	{
		//iterate over list blist
		// and call the render method on each object.
	}
}


which I wrapped using pyste. I also wrapped the class B using pyste.
now I initialized a copy of B in python and passed it to add_b to add 
it to blist.
so far so good.

The problem starts when I call the render method in A which in turn 
calls the render method on each of the classes stored in blist. since I 
was using pyste to wrap the class,
the render method  being called turned out to be the one associated 
with the wrapped object(a subclass of B from what I can gather) and not 
the actual class B.  This causes problems since there was some 
additional funkiness with the way the wrapped method was handling some 
references. However putting an explicit exclude statement in the pyste 
files to exclude the render method for class B solved the problem.

Is there a problem here ? is this the standard way of doing stuff ? it 
seems quite cumbersome to exclude methods like this.

thanks.
sameer










More information about the Cplusplus-sig mailing list