|
| 1 | +package python3 |
| 2 | + |
| 3 | +/* |
| 4 | +#include "Python.h" |
| 5 | +*/ |
| 6 | +import "C" |
| 7 | + |
| 8 | +import ( |
| 9 | + "unsafe" |
| 10 | +) |
| 11 | + |
| 12 | +//PyImport_ImportModule : https://docs.python.org/3/c-api/import.html#c.PyImport_ImportModule |
| 13 | +func PyImport_ImportModule(name string) *PyObject { |
| 14 | + cname := C.CString(name) |
| 15 | + defer C.free(unsafe.Pointer(cname)) |
| 16 | + |
| 17 | + return togo(C.PyImport_ImportModule(cname)) |
| 18 | +} |
| 19 | + |
| 20 | +//PyImport_ImportModuleEx : https://docs.python.org/3/c-api/import.html#c.PyImport_ImportModuleEx |
| 21 | +func PyImport_ImportModuleEx(name string, globals, locals, fromlist *PyObject) *PyObject { |
| 22 | + return PyImport_ImportModuleLevel(name, globals, locals, fromlist, 0) |
| 23 | +} |
| 24 | + |
| 25 | +//PyImport_ImportModuleLevelObject : https://docs.python.org/3/c-api/import.html#c.PyImport_ImportModuleLevelObject |
| 26 | +func PyImport_ImportModuleLevelObject(name, globals, locals, fromlist *PyObject, level int) *PyObject { |
| 27 | + return togo(C.PyImport_ImportModuleLevelObject(toc(name), toc(globals), toc(locals), toc(fromlist), C.int(level))) |
| 28 | +} |
| 29 | + |
| 30 | +//PyImport_ImportModuleLevel : https://docs.python.org/3/c-api/import.html#c.PyImport_ImportModuleLevel |
| 31 | +func PyImport_ImportModuleLevel(name string, globals, locals, fromlist *PyObject, level int) *PyObject { |
| 32 | + cname := C.CString(name) |
| 33 | + defer C.free(unsafe.Pointer(cname)) |
| 34 | + |
| 35 | + return togo(C.PyImport_ImportModuleLevel(cname, toc(globals), toc(locals), toc(fromlist), C.int(level))) |
| 36 | +} |
| 37 | + |
| 38 | +//PyImport_Import : https://docs.python.org/3/c-api/import.html#c.PyImport_Import |
| 39 | +func PyImport_Import(name *PyObject) *PyObject { |
| 40 | + return togo(C.PyImport_Import(toc(name))) |
| 41 | +} |
| 42 | + |
| 43 | +//PyImport_ReloadModule : https://docs.python.org/3/c-api/import.html#c.PyImport_ReloadModule |
| 44 | +func PyImport_ReloadModule(name *PyObject) *PyObject { |
| 45 | + return togo(C.PyImport_ReloadModule(toc(name))) |
| 46 | +} |
| 47 | + |
| 48 | +//PyImport_AddModuleObject : https://docs.python.org/3/c-api/import.html#c.PyImport_AddModuleObject |
| 49 | +func PyImport_AddModuleObject(name *PyObject) *PyObject { |
| 50 | + return togo(C.PyImport_AddModuleObject(toc(name))) |
| 51 | +} |
| 52 | + |
| 53 | +//PyImport_AddModule : https://docs.python.org/3/c-api/import.html#c.PyImport_AddModule |
| 54 | +func PyImport_AddModule(name string) *PyObject { |
| 55 | + cname := C.CString(name) |
| 56 | + defer C.free(unsafe.Pointer(cname)) |
| 57 | + |
| 58 | + return togo(C.PyImport_AddModule(cname)) |
| 59 | +} |
| 60 | + |
| 61 | +//PyImport_ExecCodeModule : https://docs.python.org/3/c-api/import.html#c.PyImport_ExecCodeModule |
| 62 | +func PyImport_ExecCodeModule(name string, co *PyObject) *PyObject { |
| 63 | + cname := C.CString(name) |
| 64 | + defer C.free(unsafe.Pointer(cname)) |
| 65 | + |
| 66 | + return togo(C.PyImport_ExecCodeModule(cname, toc(co))) |
| 67 | +} |
| 68 | + |
| 69 | +//PyImport_ExecCodeModuleEx : https://docs.python.org/3/c-api/import.html#c.PyImport_ExecCodeModuleEx |
| 70 | +func PyImport_ExecCodeModuleEx(name string, co *PyObject, pathname string) *PyObject { |
| 71 | + cname := C.CString(name) |
| 72 | + defer C.free(unsafe.Pointer(cname)) |
| 73 | + |
| 74 | + cpathname := C.CString(pathname) |
| 75 | + defer C.free(unsafe.Pointer(cpathname)) |
| 76 | + |
| 77 | + return togo(C.PyImport_ExecCodeModuleEx(cname, toc(co), cpathname)) |
| 78 | +} |
| 79 | + |
| 80 | +//PyImport_ExecCodeModuleObject : https://docs.python.org/3/c-api/import.html#c.PyImport_ExecCodeModuleObject |
| 81 | +func PyImport_ExecCodeModuleObject(name, co, pathname, cpathname *PyObject) *PyObject { |
| 82 | + return togo(C.PyImport_ExecCodeModuleObject(toc(name), toc(co), toc(pathname), toc(cpathname))) |
| 83 | +} |
| 84 | + |
| 85 | +//PyImport_ExecCodeModuleWithPathnames : https://docs.python.org/3/c-api/import.html#c.PyImport_ExecCodeModuleWithPathnames |
| 86 | +func PyImport_ExecCodeModuleWithPathnames(name string, co *PyObject, pathname string, cpathname string) *PyObject { |
| 87 | + cname := C.CString(name) |
| 88 | + defer C.free(unsafe.Pointer(cname)) |
| 89 | + |
| 90 | + cspathname := C.CString(pathname) |
| 91 | + defer C.free(unsafe.Pointer(cspathname)) |
| 92 | + |
| 93 | + ccpathname := C.CString(cpathname) |
| 94 | + defer C.free(unsafe.Pointer(ccpathname)) |
| 95 | + |
| 96 | + return togo(C.PyImport_ExecCodeModuleWithPathnames(cname, toc(co), cspathname, ccpathname)) |
| 97 | +} |
| 98 | + |
| 99 | +//PyImport_GetMagicNumber : https://docs.python.org/3/c-api/import.html#c.PyImport_GetMagicNumber |
| 100 | +func PyImport_GetMagicNumber() int { |
| 101 | + return int(C.PyImport_GetMagicNumber()) |
| 102 | +} |
| 103 | + |
| 104 | +//PyImport_GetMagicTag : https://docs.python.org/3/c-api/import.html#c.PyImport_GetMagicTag |
| 105 | +func PyImport_GetMagicTag() string { |
| 106 | + cmagicTag := C.PyImport_GetMagicTag() |
| 107 | + |
| 108 | + return C.GoString(cmagicTag) |
| 109 | +} |
| 110 | + |
| 111 | +//PyImport_GetModuleDict : https://docs.python.org/3/c-api/import.html#c.PyImport_GetModuleDict |
| 112 | +func PyImport_GetModuleDict() *PyObject { |
| 113 | + return togo(C.PyImport_GetModuleDict()) |
| 114 | +} |
| 115 | + |
| 116 | +//PyImport_GetModule : https://docs.python.org/3/c-api/import.html#c.PyImport_GetModule |
| 117 | +func PyImport_GetModule(name *PyObject) *PyObject { |
| 118 | + return togo(C.PyImport_GetModule(toc(name))) |
| 119 | + |
| 120 | +} |
| 121 | + |
| 122 | +//PyImport_GetImporter : https://docs.python.org/3/c-api/import.html#c.PyImport_GetImporter |
| 123 | +func PyImport_GetImporter(path *PyObject) *PyObject { |
| 124 | + return togo(C.PyImport_GetImporter(toc(path))) |
| 125 | + |
| 126 | +} |
| 127 | + |
| 128 | +//PyImport_ImportFrozenModuleObject : https://docs.python.org/3/c-api/import.html#c.PyImport_ImportFrozenModuleObject |
| 129 | +func PyImport_ImportFrozenModuleObject(name *PyObject) int { |
| 130 | + return int(C.PyImport_ImportFrozenModuleObject(toc(name))) |
| 131 | + |
| 132 | +} |
| 133 | + |
| 134 | +//PyImport_ImportFrozenModule : https://docs.python.org/3/c-api/import.html#c.PyImport_ImportFrozenModule |
| 135 | +func PyImport_ImportFrozenModule(name string) int { |
| 136 | + cname := C.CString(name) |
| 137 | + defer C.free(unsafe.Pointer(cname)) |
| 138 | + |
| 139 | + return int(C.PyImport_ImportFrozenModule(cname)) |
| 140 | + |
| 141 | +} |
0 commit comments