Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
fccabc4a
Commit
fccabc4a
authored
Apr 26, 2019
by
gsamain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test case for cppclass method overloading
parent
760fe71f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
0 deletions
+86
-0
tests/run/cpp_method_overloading.pyx
tests/run/cpp_method_overloading.pyx
+77
-0
tests/run/cpp_method_overloading_support.h
tests/run/cpp_method_overloading_support.h
+9
-0
No files found.
tests/run/cpp_method_overloading.pyx
0 → 100644
View file @
fccabc4a
# mode: run
# tag: cpp
cdef
extern
from
"cpp_method_overloading_support.h"
:
cdef
cppclass
Base
:
__init__
()
__init__
(
int
a
)
int
foo
(
double
)
int
foo
(
double
*
)
cdef
cppclass
Derived
(
Base
):
pass
cdef
cppclass
DefinedBase
:
int
state
__init__
():
# If we skip this one, inheritance won't work because of the
# derived class constructor implicitely calling default constructor
this
.
__init__
(
0
)
__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
):
DefinedBase
.
__init__
(
a
)
def
testDeclared
():
"""
>>> testDeclared()
4 3
"""
#pass
cdef
double
a
=
4.2
cdef
double
*
b
=
&
a
cdef
Derived
d
rst_a
=
d
.
foo
(
a
)
rst_b
=
d
.
foo
(
b
)
print
rst_a
,
rst_b
def
testDefined
():
"""
>>> testDefined()
24 42 42
"""
dd
=
new
DefinedDerived
(
24
)
dorig
=
dd
.
getter
()
cdef
int
val
=
42
dd
.
setter
(
val
)
dstate
=
dd
.
getter
()
# dstate should be 42
da_addr
=
&
dstate
dd
.
setter
(
da_addr
)
# dstate2 should be 42
dstate2
=
dd
.
getter
()
print
dorig
,
dstate
,
dstate2
del
dd
\ No newline at end of file
tests/run/cpp_method_overloading_support.h
0 → 100644
View file @
fccabc4a
class
Base
{
public:
int
foo
(
double
a
)
{
return
(
int
)
(
a
+
0.5
);
}
int
foo
(
double
*
a
)
{
return
(
int
)
(
*
a
+
0.5
)
-
1
;
}
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment