[Pyrex] pyrexembed: How to make a method which returns a struct

Martin Dobiasch martin.dobiasch at dobibrennda.at
Mon May 22 13:02:15 CEST 2006


Hi!

I want to write a class with memberfunctions which returns structures

My work:

#header{
#include "ServerHandle.h"
#}header
cdef struct RoomConnection:
	int b  #ID of the Room b
	int ax #point
	int ay
	int az
	int x  #size
	int y
	int z
	int h  #orientation
	int p
	int r
	int bx #entry point in Room b
	int by
	int bz

cdef struct RoomConnections:
	int n
	RoomConnection* rc

cdef class ServerHandle:
	cdef void *thisptr #the this pointer for the class
	
	def __init__(self):
		# create constructor shim func
		#embed{ void *ServerHandle_init()
			return (void *)(new ServerHandle());
		#}embed
		
		self.thisptr = ServerHandle_init()
		
	def __del__ ( self ) :
		#destructor
		#embed{ void ServerHandle_del(void *obj)
			delete (ServerHandle*)obj;
		#}embed
		
		self.thisptr= NULL
	def getRoomConnections( self, rID ):
		#embed{ RoomConnections* ServerHandle_getRoomConnections(void* obj, int rID)
			return ( (ServerHandle* ) obj )->getRoomConnections( rID );
		#}embed
		
		return ServerHandle_getRoomConnections( self.thisptr, rID )
	

This is the error message:
/cygdrive/e/Programmieren/Spiele/VirtualWorld/ServerHandle/pyrex/ServerHandle.py
x:132:40: Cannot convert 'RoomConnections (*)' to Python object

What can i do to make it work?
Thanks Martin



More information about the Pyrex mailing list