Commit 606313ee authored by Stefan Behnel's avatar Stefan Behnel

Rename embedding tests in docs to make it easier to find and select in the test suite.

parent 97689343
# spam.pyx # embedded.pyx
# The following two lines are for test purposed only, please ignore them. # The following two lines are for test purposed only, please ignore them.
# distutils: sources = spam_main.c # distutils: sources = embedded_main.c
# tag: py3only # tag: py3only
TEXT_TO_SAY = 'Hello from Python!' TEXT_TO_SAY = 'Hello from Python!'
......
/* spam_main.c */ /* embedded_main.c */
/* This include file is automatically generated by Cython for 'public' functions. */ /* This include file is automatically generated by Cython for 'public' functions. */
#include "spam.h" #include "embedded.h"
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
...@@ -16,7 +16,7 @@ main(int argc, char *argv[]) ...@@ -16,7 +16,7 @@ main(int argc, char *argv[])
} }
/* Add a built-in module, before Py_Initialize */ /* Add a built-in module, before Py_Initialize */
if (PyImport_AppendInittab("spam", PyInit_spam) == -1) { if (PyImport_AppendInittab("embedded", PyInit_embedded) == -1) {
fprintf(stderr, "Error: could not extend in-built modules table\n"); fprintf(stderr, "Error: could not extend in-built modules table\n");
exit(1); exit(1);
} }
...@@ -31,10 +31,10 @@ main(int argc, char *argv[]) ...@@ -31,10 +31,10 @@ main(int argc, char *argv[])
/* Optionally import the module; alternatively, /* Optionally import the module; alternatively,
import can be deferred until the embedded script import can be deferred until the embedded script
imports it. */ imports it. */
pmodule = PyImport_ImportModule("spam"); pmodule = PyImport_ImportModule("embedded");
if (!pmodule) { if (!pmodule) {
PyErr_Print(); PyErr_Print();
fprintf(stderr, "Error: could not import module 'spam'\n"); fprintf(stderr, "Error: could not import module 'embedded'\n");
goto exit_with_error; goto exit_with_error;
} }
......
...@@ -50,18 +50,18 @@ Embedding example code ...@@ -50,18 +50,18 @@ Embedding example code
====================== ======================
The following is a simple example that shows the main steps for embedding a The following is a simple example that shows the main steps for embedding a
Cython module (``spam.pyx``) in Python 3.x. Cython module (``embedded.pyx``) in Python 3.x.
First, here is a Cython module that exports a C function to be called by external First, here is a Cython module that exports a C function to be called by external
code. Note that the ``say_hello_from_python()`` function is declared as ``public`` code. Note that the ``say_hello_from_python()`` function is declared as ``public``
to export it as a linker symbol that can be used by other C files, which in this to export it as a linker symbol that can be used by other C files, which in this
case is ``spam_main.c``. case is ``embedded_main.c``.
.. literalinclude:: ../../examples/tutorial/embedding/spam.pyx .. literalinclude:: ../../examples/tutorial/embedding/embedded.pyx
The C ``main()`` function of your program could look like this: The C ``main()`` function of your program could look like this:
.. literalinclude:: ../../examples/tutorial/embedding/spam_main.c .. literalinclude:: ../../examples/tutorial/embedding/embedded_main.c
:linenos: :linenos:
:language: c :language: c
......
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