Skip to content

Commit 3d59882

Browse files
committed
add headers missing for numpy's mtrand module
1 parent 57693a9 commit 3d59882

File tree

5 files changed

+323
-6
lines changed

5 files changed

+323
-6
lines changed

graalpython/com.oracle.graal.python.cext/include/Python.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
#include "unicodeobject.h"
7272
#include "pystate.h"
7373
#include "pyarena.h"
74+
#include "compile.h"
7475
#include "pythonrun.h"
7576
#include "ceval.h"
7677
#include "pyerrors.h"
@@ -108,6 +109,8 @@
108109
#include "memoryobject.h"
109110
#include "pystrhex.h"
110111
#include "codecs.h"
112+
#include "frameobject.h"
113+
#include "traceback.h"
111114

112115
#define PY_TRUFFLE_CEXT ((void*)polyglot_import("python_cext"))
113116
#define PY_BUILTIN ((void*)polyglot_import("python_builtins"))
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/* Copyright (c) 2018, Oracle and/or its affiliates.
2+
* Copyright (C) 1996-2017 Python Software Foundation
3+
*
4+
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
5+
*/
6+
7+
#ifndef Py_COMPILE_H
8+
#define Py_COMPILE_H
9+
10+
#ifndef Py_LIMITED_API
11+
#include "code.h"
12+
13+
#ifdef __cplusplus
14+
extern "C" {
15+
#endif
16+
17+
/* Public interface */
18+
struct _node; /* Declare the existence of this type */
19+
PyAPI_FUNC(PyCodeObject *) PyNode_Compile(struct _node *, const char *);
20+
/* XXX (ncoghlan): Unprefixed type name in a public API! */
21+
22+
#define PyCF_MASK (CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT | \
23+
CO_FUTURE_WITH_STATEMENT | CO_FUTURE_PRINT_FUNCTION | \
24+
CO_FUTURE_UNICODE_LITERALS | CO_FUTURE_BARRY_AS_BDFL | \
25+
CO_FUTURE_GENERATOR_STOP)
26+
#define PyCF_MASK_OBSOLETE (CO_NESTED)
27+
#define PyCF_SOURCE_IS_UTF8 0x0100
28+
#define PyCF_DONT_IMPLY_DEDENT 0x0200
29+
#define PyCF_ONLY_AST 0x0400
30+
#define PyCF_IGNORE_COOKIE 0x0800
31+
32+
#ifndef Py_LIMITED_API
33+
typedef struct {
34+
int cf_flags; /* bitmask of CO_xxx flags relevant to future */
35+
} PyCompilerFlags;
36+
#endif
37+
38+
/* Future feature support */
39+
40+
typedef struct {
41+
int ff_features; /* flags set by future statements */
42+
int ff_lineno; /* line number of last future statement */
43+
} PyFutureFeatures;
44+
45+
#define FUTURE_NESTED_SCOPES "nested_scopes"
46+
#define FUTURE_GENERATORS "generators"
47+
#define FUTURE_DIVISION "division"
48+
#define FUTURE_ABSOLUTE_IMPORT "absolute_import"
49+
#define FUTURE_WITH_STATEMENT "with_statement"
50+
#define FUTURE_PRINT_FUNCTION "print_function"
51+
#define FUTURE_UNICODE_LITERALS "unicode_literals"
52+
#define FUTURE_BARRY_AS_BDFL "barry_as_FLUFL"
53+
#define FUTURE_GENERATOR_STOP "generator_stop"
54+
55+
struct _mod; /* Declare the existence of this type */
56+
#define PyAST_Compile(mod, s, f, ar) PyAST_CompileEx(mod, s, f, -1, ar)
57+
PyAPI_FUNC(PyCodeObject *) PyAST_CompileEx(
58+
struct _mod *mod,
59+
const char *filename, /* decoded from the filesystem encoding */
60+
PyCompilerFlags *flags,
61+
int optimize,
62+
PyArena *arena);
63+
PyAPI_FUNC(PyCodeObject *) PyAST_CompileObject(
64+
struct _mod *mod,
65+
PyObject *filename,
66+
PyCompilerFlags *flags,
67+
int optimize,
68+
PyArena *arena);
69+
PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST(
70+
struct _mod * mod,
71+
const char *filename /* decoded from the filesystem encoding */
72+
);
73+
PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromASTObject(
74+
struct _mod * mod,
75+
PyObject *filename
76+
);
77+
78+
/* _Py_Mangle is defined in compile.c */
79+
PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
80+
81+
#define PY_INVALID_STACK_EFFECT INT_MAX
82+
PyAPI_FUNC(int) PyCompile_OpcodeStackEffect(int opcode, int oparg);
83+
84+
PyAPI_FUNC(int) _PyAST_Optimize(struct _mod *, PyArena *arena);
85+
86+
#ifdef __cplusplus
87+
}
88+
#endif
89+
90+
#endif /* !Py_LIMITED_API */
91+
92+
/* These definitions must match corresponding definitions in graminit.h.
93+
There's code in compile.c that checks that they are the same. */
94+
#define Py_single_input 256
95+
#define Py_file_input 257
96+
#define Py_eval_input 258
97+
98+
#endif /* !Py_COMPILE_H */
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/* Copyright (c) 2018, Oracle and/or its affiliates.
2+
* Copyright (C) 1996-2017 Python Software Foundation
3+
*
4+
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
5+
*/
6+
7+
/* Frame object interface */
8+
9+
#ifndef Py_LIMITED_API
10+
#ifndef Py_FRAMEOBJECT_H
11+
#define Py_FRAMEOBJECT_H
12+
#ifdef __cplusplus
13+
extern "C" {
14+
#endif
15+
16+
typedef struct {
17+
int b_type; /* what kind of block this is */
18+
int b_handler; /* where to jump to find handler */
19+
int b_level; /* value stack level to pop to */
20+
} PyTryBlock;
21+
22+
typedef struct _frame {
23+
PyObject_VAR_HEAD
24+
struct _frame *f_back; /* previous frame, or NULL */
25+
PyCodeObject *f_code; /* code segment */
26+
PyObject *f_builtins; /* builtin symbol table (PyDictObject) */
27+
PyObject *f_globals; /* global symbol table (PyDictObject) */
28+
PyObject *f_locals; /* local symbol table (any mapping) */
29+
PyObject **f_valuestack; /* points after the last local */
30+
/* Next free slot in f_valuestack. Frame creation sets to f_valuestack.
31+
Frame evaluation usually NULLs it, but a frame that yields sets it
32+
to the current stack top. */
33+
PyObject **f_stacktop;
34+
PyObject *f_trace; /* Trace function */
35+
char f_trace_lines; /* Emit per-line trace events? */
36+
char f_trace_opcodes; /* Emit per-opcode trace events? */
37+
38+
/* Borrowed reference to a generator, or NULL */
39+
PyObject *f_gen;
40+
41+
int f_lasti; /* Last instruction if called */
42+
/* Call PyFrame_GetLineNumber() instead of reading this field
43+
directly. As of 2.3 f_lineno is only valid when tracing is
44+
active (i.e. when f_trace is set). At other times we use
45+
PyCode_Addr2Line to calculate the line from the current
46+
bytecode index. */
47+
int f_lineno; /* Current line number */
48+
int f_iblock; /* index in f_blockstack */
49+
char f_executing; /* whether the frame is still executing */
50+
PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */
51+
PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */
52+
} PyFrameObject;
53+
54+
55+
/* Standard object interface */
56+
57+
PyAPI_DATA(PyTypeObject) PyFrame_Type;
58+
59+
#define PyFrame_Check(op) (Py_TYPE(op) == &PyFrame_Type)
60+
61+
PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *,
62+
PyObject *, PyObject *);
63+
64+
/* only internal use */
65+
PyFrameObject* _PyFrame_New_NoTrack(PyThreadState *, PyCodeObject *,
66+
PyObject *, PyObject *);
67+
68+
69+
/* The rest of the interface is specific for frame objects */
70+
71+
/* Block management functions */
72+
73+
PyAPI_FUNC(void) PyFrame_BlockSetup(PyFrameObject *, int, int, int);
74+
PyAPI_FUNC(PyTryBlock *) PyFrame_BlockPop(PyFrameObject *);
75+
76+
/* Extend the value stack */
77+
78+
PyAPI_FUNC(PyObject **) PyFrame_ExtendStack(PyFrameObject *, int, int);
79+
80+
/* Conversions between "fast locals" and locals in dictionary */
81+
82+
PyAPI_FUNC(void) PyFrame_LocalsToFast(PyFrameObject *, int);
83+
84+
PyAPI_FUNC(int) PyFrame_FastToLocalsWithError(PyFrameObject *f);
85+
PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *);
86+
87+
PyAPI_FUNC(int) PyFrame_ClearFreeList(void);
88+
89+
PyAPI_FUNC(void) _PyFrame_DebugMallocStats(FILE *out);
90+
91+
/* Return the line of code the frame is currently executing. */
92+
PyAPI_FUNC(int) PyFrame_GetLineNumber(PyFrameObject *);
93+
94+
#ifdef __cplusplus
95+
}
96+
#endif
97+
#endif /* !Py_FRAMEOBJECT_H */
98+
#endif /* Py_LIMITED_API */

graalpython/com.oracle.graal.python.cext/include/pythonrun.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ extern "C" {
2222
#define PyCF_ONLY_AST 0x0400
2323
#define PyCF_IGNORE_COOKIE 0x0800
2424

25-
#ifndef Py_LIMITED_API
26-
typedef struct {
27-
int cf_flags; /* bitmask of CO_xxx flags relevant to future */
28-
} PyCompilerFlags;
29-
#endif
30-
3125
#ifndef Py_LIMITED_API
3226
PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
3327
PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/* Copyright (c) 2018, Oracle and/or its affiliates.
2+
* Copyright (C) 1996-2017 Python Software Foundation
3+
*
4+
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
5+
*/
6+
7+
#ifndef Py_TRACEBACK_H
8+
#define Py_TRACEBACK_H
9+
#ifdef __cplusplus
10+
extern "C" {
11+
#endif
12+
13+
#include "pystate.h"
14+
15+
struct _frame;
16+
17+
/* Traceback interface */
18+
#ifndef Py_LIMITED_API
19+
typedef struct _traceback {
20+
PyObject_HEAD
21+
struct _traceback *tb_next;
22+
struct _frame *tb_frame;
23+
int tb_lasti;
24+
int tb_lineno;
25+
} PyTracebackObject;
26+
#endif
27+
28+
PyAPI_FUNC(int) PyTraceBack_Here(struct _frame *);
29+
PyAPI_FUNC(int) PyTraceBack_Print(PyObject *, PyObject *);
30+
#ifndef Py_LIMITED_API
31+
PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, PyObject *, int, int);
32+
PyAPI_FUNC(void) _PyTraceback_Add(const char *, const char *, int);
33+
#endif
34+
35+
/* Reveal traceback type so we can typecheck traceback objects */
36+
PyAPI_DATA(PyTypeObject) PyTraceBack_Type;
37+
#define PyTraceBack_Check(v) (Py_TYPE(v) == &PyTraceBack_Type)
38+
39+
#ifndef Py_LIMITED_API
40+
/* Write the Python traceback into the file 'fd'. For example:
41+
42+
Traceback (most recent call first):
43+
File "xxx", line xxx in <xxx>
44+
File "xxx", line xxx in <xxx>
45+
...
46+
File "xxx", line xxx in <xxx>
47+
48+
This function is written for debug purpose only, to dump the traceback in
49+
the worst case: after a segmentation fault, at fatal error, etc. That's why,
50+
it is very limited. Strings are truncated to 100 characters and encoded to
51+
ASCII with backslashreplace. It doesn't write the source code, only the
52+
function name, filename and line number of each frame. Write only the first
53+
100 frames: if the traceback is truncated, write the line " ...".
54+
55+
This function is signal safe. */
56+
57+
PyAPI_FUNC(void) _Py_DumpTraceback(
58+
int fd,
59+
PyThreadState *tstate);
60+
61+
/* Write the traceback of all threads into the file 'fd'. current_thread can be
62+
NULL.
63+
64+
Return NULL on success, or an error message on error.
65+
66+
This function is written for debug purpose only. It calls
67+
_Py_DumpTraceback() for each thread, and so has the same limitations. It
68+
only write the traceback of the first 100 threads: write "..." if there are
69+
more threads.
70+
71+
If current_tstate is NULL, the function tries to get the Python thread state
72+
of the current thread. It is not an error if the function is unable to get
73+
the current Python thread state.
74+
75+
If interp is NULL, the function tries to get the interpreter state from
76+
the current Python thread state, or from
77+
_PyGILState_GetInterpreterStateUnsafe() in last resort.
78+
79+
It is better to pass NULL to interp and current_tstate, the function tries
80+
different options to retrieve these informations.
81+
82+
This function is signal safe. */
83+
84+
PyAPI_FUNC(const char*) _Py_DumpTracebackThreads(
85+
int fd,
86+
PyInterpreterState *interp,
87+
PyThreadState *current_tstate);
88+
#endif /* !Py_LIMITED_API */
89+
90+
#ifndef Py_LIMITED_API
91+
92+
/* Write a Unicode object into the file descriptor fd. Encode the string to
93+
ASCII using the backslashreplace error handler.
94+
95+
Do nothing if text is not a Unicode object. The function accepts Unicode
96+
string which is not ready (PyUnicode_WCHAR_KIND).
97+
98+
This function is signal safe. */
99+
PyAPI_FUNC(void) _Py_DumpASCII(int fd, PyObject *text);
100+
101+
/* Format an integer as decimal into the file descriptor fd.
102+
103+
This function is signal safe. */
104+
PyAPI_FUNC(void) _Py_DumpDecimal(
105+
int fd,
106+
unsigned long value);
107+
108+
/* Format an integer as hexadecimal into the file descriptor fd with at least
109+
width digits.
110+
111+
The maximum width is sizeof(unsigned long)*2 digits.
112+
113+
This function is signal safe. */
114+
PyAPI_FUNC(void) _Py_DumpHexadecimal(
115+
int fd,
116+
unsigned long value,
117+
Py_ssize_t width);
118+
119+
#endif /* !Py_LIMITED_API */
120+
121+
#ifdef __cplusplus
122+
}
123+
#endif
124+
#endif /* !Py_TRACEBACK_H */

0 commit comments

Comments
 (0)