| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d9d6ead commit 03b7642
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,25 +11,34 @@ extern "C" { | |||
| 11 | 11 | #include "Python.h" | |
| 12 | 12 | #include "Python-ast.h" | |
| 13 | 13 | ||
| 14 | - PyAPI_FUNC(mod_ty) PyPegen_ASTFromFile(const char *filename, int mode, PyCompilerFlags*, PyArena *arena); | ||
| 15 | - PyAPI_FUNC(mod_ty) PyPegen_ASTFromString(const char *str, int mode, PyCompilerFlags *flags, | ||
| 16 | - PyArena *arena); | ||
| 17 | - PyAPI_FUNC(mod_ty) PyPegen_ASTFromStringObject(const char *str, PyObject* filename, int mode, | ||
| 18 | - PyCompilerFlags *flags, PyArena *arena); | ||
| 19 | - PyAPI_FUNC(mod_ty) PyPegen_ASTFromFileObject(FILE *fp, PyObject *filename_ob, | ||
| 20 | - int mode, const char *enc, const char *ps1, | ||
| 21 | - const char *ps2, PyCompilerFlags *flags, | ||
| 22 | - int *errcode, PyArena *arena); | ||
| 23 | - PyAPI_FUNC(PyCodeObject *) PyPegen_CodeObjectFromFile(const char *filename, int mode, PyCompilerFlags *flags); | ||
| 24 | - PyAPI_FUNC(PyCodeObject *) PyPegen_CodeObjectFromString(const char *str, int mode, | ||
| 25 | - PyCompilerFlags *flags); | ||
| 26 | - PyAPI_FUNC(PyCodeObject *) PyPegen_CodeObjectFromFileObject(FILE *, PyObject *filename_ob, | ||
| 27 | - int mode, | ||
| 28 | - const char *ps1, | ||
| 29 | - const char *ps2, | ||
| 30 | - PyCompilerFlags *flags, | ||
| 31 | - const char *enc, | ||
| 32 | - int *errcode); | ||
| 14 | + PyAPI_FUNC(mod_ty) PyPegen_ASTFromString( | ||
| 15 | + const char *str, | ||
| 16 | + const char *filename, | ||
| 17 | + int mode, | ||
| 18 | + PyCompilerFlags *flags, | ||
| 19 | + PyArena *arena); | ||
| 20 | + PyAPI_FUNC(mod_ty) PyPegen_ASTFromStringObject( | ||
| 21 | + const char *str, | ||
| 22 | + PyObject* filename, | ||
| 23 | + int mode, | ||
| 24 | + PyCompilerFlags *flags, | ||
| 25 | + PyArena *arena); | ||
| 26 | + PyAPI_FUNC(mod_ty) PyPegen_ASTFromFileObject( | ||
| 27 | + FILE *fp, | ||
| 28 | + PyObject *filename_ob, | ||
| 29 | + int mode, | ||
| 30 | + const char *enc, | ||
| 31 | + const char *ps1, | ||
| 32 | + const char *ps2, | ||
| 33 | + PyCompilerFlags *flags, | ||
| 34 | + int *errcode, | ||
| 35 | + PyArena *arena); | ||
| 36 | + PyAPI_FUNC(mod_ty) PyPegen_ASTFromFilename( | ||
| 37 | + const char *filename, | ||
| 38 | + int mode, | ||
| 39 | + PyCompilerFlags *flags, | ||
| 40 | + PyArena *arena); | ||
| 41 | + | ||
| 33 | 42 | ||
| 34 | 43 | #ifdef __cplusplus | |
| 35 | 44 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,7 +31,7 @@ _Py_parse_file(PyObject *self, PyObject *args, PyObject *kwds) | |||
| 31 | 31 | PyCompilerFlags flags = _PyCompilerFlags_INIT; | |
| 32 | 32 | PyObject *result = NULL; | |
| 33 | 33 | ||
| 34 | - mod_ty res = PyPegen_ASTFromFile(filename, mode, &flags, arena); | ||
| 34 | + mod_ty res = PyPegen_ASTFromFilename(filename, mode, &flags, arena); | ||
| 35 | 35 | if (res == NULL) { | |
| 36 | 36 | goto error; | |
| 37 | 37 | } | |
@@ -84,7 +84,7 @@ _Py_parse_string(PyObject *self, PyObject *args, PyObject *kwds) | |||
| 84 | 84 | res = PyParser_ASTFromString(the_string, "<string>", mode, &flags, arena); | |
| 85 | 85 | } | |
| 86 | 86 | else { | |
| 87 | - res = PyPegen_ASTFromString(the_string, mode, &flags, arena); | ||
| 87 | + res = PyPegen_ASTFromString(the_string, "<string>", mode, &flags, arena); | ||
| 88 | 88 | } | |
| 89 | 89 | if (res == NULL) { | |
| 90 | 90 | goto error; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,9 +4,10 @@ | |||
| 4 | 4 | #include "pegen.h" | |
| 5 | 5 | ||
| 6 | 6 | mod_ty | |
| 7 | - PyPegen_ASTFromString(const char *str, int mode, PyCompilerFlags *flags, PyArena *arena) | ||
| 7 | + PyPegen_ASTFromString(const char *str, const char *filename, int mode, | ||
| 8 | + PyCompilerFlags *flags, PyArena *arena) | ||
| 8 | 9 | { | |
| 9 | - PyObject *filename_ob = PyUnicode_FromString("<string>"); | ||
| 10 | + PyObject *filename_ob = PyUnicode_FromString(filename); | ||
| 10 | 11 | if (filename_ob == NULL) { | |
| 11 | 12 | return NULL; | |
| 12 | 13 | } | |
@@ -16,7 +17,8 @@ PyPegen_ASTFromString(const char *str, int mode, PyCompilerFlags *flags, PyArena | |||
| 16 | 17 | } | |
| 17 | 18 | ||
| 18 | 19 | mod_ty | |
| 19 | - PyPegen_ASTFromStringObject(const char *str, PyObject* filename, int mode, PyCompilerFlags *flags, PyArena *arena) | ||
| 20 | + PyPegen_ASTFromStringObject(const char *str, PyObject* filename, int mode, | ||
| 21 | + PyCompilerFlags *flags, PyArena *arena) | ||
| 20 | 22 | { | |
| 21 | 23 | if (PySys_Audit("compile", "yO", str, filename) < 0) { | |
| 22 | 24 | return NULL; | |
@@ -27,7 +29,7 @@ PyPegen_ASTFromStringObject(const char *str, PyObject* filename, int mode, PyCom | |||
| 27 | 29 | } | |
| 28 | 30 | ||
| 29 | 31 | mod_ty | |
| 30 | - PyPegen_ASTFromFile(const char *filename, int mode, PyCompilerFlags *flags, PyArena *arena) | ||
| 32 | + PyPegen_ASTFromFilename(const char *filename, int mode, PyCompilerFlags *flags, PyArena *arena) | ||
| 31 | 33 | { | |
| 32 | 34 | PyObject *filename_ob = PyUnicode_FromString(filename); | |
| 33 | 35 | if (filename_ob == NULL) { | |
@@ -50,84 +52,3 @@ PyPegen_ASTFromFileObject(FILE *fp, PyObject *filename_ob, int mode, | |||
| 50 | 52 | return _PyPegen_run_parser_from_file_pointer(fp, mode, filename_ob, enc, ps1, ps2, | |
| 51 | 53 | flags, errcode, arena); | |
| 52 | 54 | } | |
| 53 | - | ||
| 54 | - PyCodeObject * | ||
| 55 | - PyPegen_CodeObjectFromString(const char *str, int mode, PyCompilerFlags *flags) | ||
| 56 | - { | ||
| 57 | - PyArena *arena = PyArena_New(); | ||
| 58 | - if (arena == NULL) { | ||
| 59 | - return NULL; | ||
| 60 | - } | ||
| 61 | - | ||
| 62 | - PyCodeObject *result = NULL; | ||
| 63 | - | ||
| 64 | - PyObject *filename_ob = PyUnicode_FromString("<string>"); | ||
| 65 | - if (filename_ob == NULL) { | ||
| 66 | - goto error; | ||
| 67 | - } | ||
| 68 | - | ||
| 69 | - mod_ty res = PyPegen_ASTFromString(str, mode, flags, arena); | ||
| 70 | - if (res == NULL) { | ||
| 71 | - goto error; | ||
| 72 | - } | ||
| 73 | - | ||
| 74 | - result = PyAST_CompileObject(res, filename_ob, NULL, -1, arena); | ||
| 75 | - | ||
| 76 | - error: | ||
| 77 | - Py_XDECREF(filename_ob); | ||
| 78 | - PyArena_Free(arena); | ||
| 79 | - return result; | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | - PyCodeObject * | ||
| 83 | - PyPegen_CodeObjectFromFile(const char *filename, int mode, PyCompilerFlags* flags) | ||
| 84 | - { | ||
| 85 | - PyArena *arena = PyArena_New(); | ||
| 86 | - if (arena == NULL) { | ||
| 87 | - return NULL; | ||
| 88 | - } | ||
| 89 | - | ||
| 90 | - PyCodeObject *result = NULL; | ||
| 91 | - | ||
| 92 | - PyObject *filename_ob = PyUnicode_FromString(filename); | ||
| 93 | - if (filename_ob == NULL) { | ||
| 94 | - goto error; | ||
| 95 | - } | ||
| 96 | - | ||
| 97 | - mod_ty res = PyPegen_ASTFromFile(filename, mode, flags, arena); | ||
| 98 | - if (res == NULL) { | ||
| 99 | - goto error; | ||
| 100 | - } | ||
| 101 | - | ||
| 102 | - result = PyAST_CompileObject(res, filename_ob, NULL, -1, arena); | ||
| 103 | - | ||
| 104 | - error: | ||
| 105 | - Py_XDECREF(filename_ob); | ||
| 106 | - PyArena_Free(arena); | ||
| 107 | - return result; | ||
| 108 | - } | ||
| 109 | - | ||
| 110 | - PyCodeObject * | ||
| 111 | - PyPegen_CodeObjectFromFileObject(FILE *fp, PyObject *filename_ob, int mode, | ||
| 112 | - const char *ps1, const char *ps2, | ||
| 113 | - PyCompilerFlags *flags, const char *enc, int *errcode) | ||
| 114 | - { | ||
| 115 | - PyArena *arena = PyArena_New(); | ||
| 116 | - if (arena == NULL) { | ||
| 117 | - return NULL; | ||
| 118 | - } | ||
| 119 | - | ||
| 120 | - PyCodeObject *result = NULL; | ||
| 121 | - | ||
| 122 | - mod_ty res = PyPegen_ASTFromFileObject(fp, filename_ob, mode, enc, ps1, ps2, | ||
| 123 | - flags, errcode, arena); | ||
| 124 | - if (res == NULL) { | ||
| 125 | - goto error; | ||
| 126 | - } | ||
| 127 | - | ||
| 128 | - result = PyAST_CompileObject(res, filename_ob, NULL, -1, arena); | ||
| 129 | - | ||
| 130 | - error: | ||
| 131 | - PyArena_Free(arena); | ||
| 132 | - return result; | ||
| 133 | - } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments