Commit c96c7eff authored by Robert Bradshaw's avatar Robert Bradshaw

Merge pull request #316 from lambdafu/lambdafu/cpp_class_redef

If cppclass is redefined, make sure the this pointer enters the correct scope
parents 4e7ec931 fa3db367
......@@ -573,7 +573,7 @@ class Scope(object):
entry.type.scope.declare_inherited_cpp_attributes(base_class.scope)
if entry.type.scope:
declare_inherited_attributes(entry, base_classes)
entry.type.scope.declare_var(name="this", cname="this", type=PyrexTypes.CPtrType(entry.type), pos=entry.pos)
scope.declare_var(name="this", cname="this", type=PyrexTypes.CPtrType(entry.type), pos=entry.pos)
if self.is_cpp_class_scope:
entry.type.namespace = self.outer_scope.lookup(self.name).type
return entry
......
# tag: cpp
cdef extern cppclass Foo:
int _foo
void set_foo(int foo) nogil
int get_foo() nogil
# tag: cpp
# This gives a warning, but should not give an error.
cdef cppclass Foo:
int _foo
int get_foo():
return this._foo
void set_foo(int foo):
this._foo = foo
def test_Foo(n):
"""
>>> test_Foo(1)
1
"""
cdef Foo* foo = NULL
try:
foo = new Foo()
foo.set_foo(n)
return foo.get_foo()
finally:
del foo
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment