Commit 1ff2f2a2 authored by gsamain's avatar gsamain Committed by Xavier Thompson

Cpp: Test case for cppclass method overloading

parent 40598321
# mode: run
# tag: cpp
cdef extern from "cpp_method_overloading_support.h":
cdef cppclass Base:
__init__(int a)
int foo(double)
int foo(double*)
cdef cppclass Derived(Base):
cdef cppclass DefinedBase:
int state
# If we skip this one, inheritance won't work because of the
# derived class constructor implicitely calling default constructor
__init__(int a):
this.state = a
int getter():
return this.state
void setter(int a):
this.state = a
void setter(int* a):
if a != NULL:
this.state = a[0]
cdef cppclass DefinedDerived(DefinedBase):
__init__(int a):
def testDeclared():
>>> testDeclared()
4 3
cdef double a = 4.2
cdef double *b = &a
cdef Derived d
rst_a =
rst_b =
print rst_a, rst_b
def testDefined():
>>> testDefined()
24 42 42
dd = new DefinedDerived(24)
dorig = dd.getter()
cdef int val = 42
dstate = dd.getter()
# dstate should be 42
da_addr = &dstate
# dstate2 should be 42
dstate2 = dd.getter()
print dorig, dstate, dstate2
del dd
\ No newline at end of file
class Base {
int foo(double a) {
return (int) (a+0.5);
int foo(double* a) {
return (int) (*a+0.5) - 1;
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