MCPcopy Create free account
hub / github.com/0xPhoeniX/MazeWalker / load_python

Function load_python

MazeTracer/src/python_support.cpp:54–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52int python_ready = 0;
53
54int load_python(const char* script_base_dir)
55{
56 HMODULE lib = LoadLibraryA("python27.dll");
57 if (lib)
58 {
59 pPy_Initialize = (ptrPy_Initialize)GetProcAddress(lib, "Py_Initialize");
60 pPy_Finalize = (ptrPy_Finalize)GetProcAddress(lib, "Py_Finalize");
61 pPy_IsInitialized = (ptrPy_IsInitialized)GetProcAddress(lib, "Py_IsInitialized");
62 pPyString_FromString = (ptrPyString_FromString)GetProcAddress(lib, "PyString_FromString");
63 pPyImport_Import = (ptrPyImport_Import)GetProcAddress(lib, "PyImport_Import");
64 pPyModule_GetDict = (ptrPyModule_GetDict)GetProcAddress(lib, "PyModule_GetDict");
65 pPyDict_GetItemString = (ptrPyDict_GetItemString)GetProcAddress(lib, "PyDict_GetItemString");
66 pPyCallable_Check = (ptrPyCallable_Check)GetProcAddress(lib, "PyCallable_Check");
67 pPy_DecRef = (ptrPy_DecRef)GetProcAddress(lib, "Py_DecRef");
68 pPySys_GetObject = (ptrPySys_GetObject)GetProcAddress(lib, "PySys_GetObject");
69 pPyList_Append = (ptrPyList_Append)GetProcAddress(lib, "PyList_Append");
70 pPyErr_Print = (ptrPyErr_Print)GetProcAddress(lib, "PyErr_Print");
71 pPyTuple_New = (ptrPyTuple_New)GetProcAddress(lib, "PyTuple_New");
72 pPyTuple_SetItem = (ptrPyTuple_SetItem)GetProcAddress(lib, "PyTuple_SetItem");
73 pPyDict_New = (ptrPyDict_New)GetProcAddress(lib, "PyDict_New");
74 pPyDict_SetItemString = (ptrPyDict_SetItemString)GetProcAddress(lib, "PyDict_SetItemString");
75 pPyObject_Call = (ptrPyObject_Call)GetProcAddress(lib, "PyObject_Call");
76 pPyInt_FromLong = (ptrPyInt_FromLong)GetProcAddress(lib, "PyInt_FromLong");
77 pPyObject_Repr = (ptrPyObject_Repr)GetProcAddress(lib, "PyObject_Repr");
78 pPyString_AsString = (ptrPyString_AsString)GetProcAddress(lib, "PyString_AsString");
79 pPyErr_Fetch = (ptrPyErr_Fetch)GetProcAddress(lib, "PyErr_Fetch");
80 p_Py_NoneStruct = (ptr_Py_NoneStruct)GetProcAddress(lib, "_Py_NoneStruct");
81
82 if (pPy_Initialize &&
83 pPy_Finalize &&
84 pPy_IsInitialized &&
85 pPyString_FromString &&
86 pPyImport_Import &&
87 pPyModule_GetDict &&
88 pPyDict_GetItemString &&
89 pPyCallable_Check &&
90 pPy_DecRef &&
91 pPySys_GetObject &&
92 pPyList_Append &&
93 pPyErr_Print &&
94 pPyTuple_New &&
95 pPyTuple_SetItem &&
96 pPyDict_New &&
97 pPyDict_SetItemString &&
98 pPyObject_Call &&
99 pPyInt_FromLong &&
100 pPyObject_Repr &&
101 pPyErr_Fetch &&
102 p_Py_NoneStruct)
103 {
104 pPy_Initialize();
105
106 if (pPy_IsInitialized() > 0) {
107 PyObject* sysPath = pPySys_GetObject((char*)"path");
108 pPyList_Append(sysPath, pPyString_FromString(script_base_dir));
109
110 python_ready = 1;
111 }

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected