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
714143f4
Commit
714143f4
authored
Jun 24, 2018
by
gabrieldemarmiesse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved an example to the examples directory.
parent
084a25f5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
24 deletions
+26
-24
docs/examples/userguide/external_C_code/delorean.pyx
docs/examples/userguide/external_C_code/delorean.pyx
+9
-0
docs/examples/userguide/external_C_code/marty.c
docs/examples/userguide/external_C_code/marty.c
+13
-0
docs/src/userguide/external_C_code.rst
docs/src/userguide/external_C_code.rst
+4
-24
No files found.
docs/examples/userguide/external_C_code/delorean.pyx
0 → 100644
View file @
714143f4
# delorean.pyx
cdef
public
struct
Vehicle
:
int
speed
float
power
cdef
api
void
activate
(
Vehicle
*
v
):
if
v
.
speed
>=
88
and
v
.
power
>=
1.21
:
print
(
"Time travel achieved"
)
\ No newline at end of file
docs/examples/userguide/external_C_code/marty.c
0 → 100644
View file @
714143f4
# marty.c
#include "delorean_api.h"
Vehicle
car
;
int
main
(
int
argc
,
char
*
argv
[])
{
Py_Initialize
();
import_delorean
();
car
.
speed
=
atoi
(
argv
[
1
]);
car
.
power
=
atof
(
argv
[
2
]);
activate
(
&
car
);
Py_Finalize
();
}
docs/src/userguide/external_C_code.rst
View file @
714143f4
...
...
@@ -458,32 +458,12 @@ contains the api call which is generating the segmentation fault does not call
the :func:`import_modulename` function before the api call which crashes.
Any public C type or extension type declarations in the Cython module are also
made available when you include :file:`modulename_api.h`.:
:
made available when you include :file:`modulename_api.h`.:
# delorean.pyx
cdef public struct Vehicle:
int speed
float power
.. literalinclude:: ../../examples/userguide/external_C_code/delorean.pyx
cdef api void activate(Vehicle *v):
if v.speed >= 88 and v.power >= 1.21:
print("Time travel achieved")
.. sourcecode:: c
# marty.c
#include "delorean_api.h"
Vehicle car;
int main(int argc, char *argv[]) {
Py_Initialize();
import_delorean();
car.speed = atoi(argv[1]);
car.power = atof(argv[2]);
activate(&car);
Py_Finalize();
}
.. literalinclude:: ../../examples/userguide/external_C_code/marty.c
:language: C
.. note::
...
...
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