[Pyrex] Re: C++, references, deref a pointer...
John Sutherland
garionphx at gmail.com
Sat Apr 8 21:25:46 CEST 2006
<Sorry for being non-threaded.. My procmail rules seem to have eaten
your response..>
>> Approx line 1576 was:
>> if entry.is_variable or entry.is_cmethod:
>> to
>> if entry.is_variable or entry.is_cmethod or entry.is_cfunction:
>>
>I do not understand this change. An extension class attribute cannot
>be a C function. It can be a C function pointer, which is just a C
>attribute. See below.
I was actaully, trying to follow an older example you had done here:
http://lists.copyleft.no/pipermail/pyrex/2005-November/001518.html
In order for that to work, I had to add that small hack.. As I said,
it worked for me..
Of course, I'd much rather do things without a hack... Switching to
function pointers, and that [0] trick to get the reference (duh, I
should have thought of that..), presented another problem..
(I solved it, just presenting for others to who follow later..)
I have a class with overridden methods... The function pointer method
didn't seem to let me "name" the functions that its calls, like I was
doing with my hacked version..
For example, I was doing this:
void (*test1) "test" (int)
void (*test2) "test" (float)
Gives me: Syntax error in C variable declaration..
I then tried:
void (*test1 "test") (int)
void (*test2 "test") (float)
Which seems to work, though it didn't seem obvious to me at first...
This allows me to do this :
cdef class Test
def __init__(self):
self.thisptr = TestFactory()
def test1(self,i):
self.thisptr.test1(i)
def test2(self,a,b):
self.thisptr.test2(a,b)
I'm sure there's other ways, but this is how *i* solved it for now :)
Thanks again!
More information about the Pyrex
mailing list