File: pypy.h.rst

package info (click to toggle)
pypy3 7.3.19%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 212,236 kB
  • sloc: python: 2,098,316; ansic: 540,565; sh: 21,462; asm: 14,419; cpp: 4,451; makefile: 4,209; objc: 761; xml: 530; exp: 499; javascript: 314; pascal: 244; lisp: 45; csh: 12; awk: 4
file content (73 lines) | stat: -rw-r--r-- 2,522 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
:orphan:

.. code-block:: c

    #ifndef _PYPY_H_
    #define _PYPY_H_

    /* This header is meant to be included in programs that use PyPy as an
       embedded library.

       NOTE: this is deprecated.  Instead, use cffi's embedding support:
       http://cffi.readthedocs.org/en/latest/embedding.html
    */

    #ifdef __cplusplus
    extern "C" {
    #endif

    // call this first
    void rpython_startup_code(void);

    // pypy_init_threads has to be called in case you want to use threads
    void pypy_init_threads(void);

    /* Initialize the home directory of PyPy.  It is necessary to call this.

       Call it with "home" being the file name of the libpypy.so, for
       example; it will be used as a starting point when searching for the
       lib-python and lib_pypy directories.  They are searched from
       "home/..", "home/../..", etc.  Returns 0 if everything was fine.  If
       an error occurs, returns 1 and (if verbose != 0) prints some
       information to stderr.
     */
    int pypy_setup_home(char *home, int verbose);


    /* If your program has multiple threads, then you need to call
       pypy_thread_attach() once in each other thread that just started
       and in which you want to run Python code (including via callbacks,
       see below). DO NOT CALL IT IN THE MAIN THREAD
     */
    void pypy_thread_attach(void);


    /* The main entry point: executes "source" as plain Python code.
       Returns 0 if everything was fine.  If a Python exception is
       uncaught, it is printed to stderr and 1 is returned.

       Usually, the Python code from "source" should use cffi to fill in
       global variables of "function pointer" type in your program.  Use
       cffi callbacks to do so.  Once it is done, there is no need to call
       pypy_execute_source() any more: from C, you call directly the
       functions (which are "callbacks" from the point of view of Python).
     */
    int pypy_execute_source(char *source);

    /* a similar function, but inside Python code it'll register
       a magic argument c_argument as int, which will be passed as void* from C.
       Useful for passing pointers to arbitrary structs that contain callbacks
       to register */
    int pypy_execute_source_ptr(char *source, void* ptr);


    /* The 3.x versions of PyPy don't include the Windows pragma to
       automatically link python3?.lib.  This is apparently not commonly
       done on Windows anyway. */


    #ifdef __cplusplus
    }
    #endif

    #endif