Skip to content

Commit 9d65722

Browse files
author
Roberto De Ioris
committed
prepare for better structures api
1 parent 97fe3cc commit 9d65722

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

Source/UnrealEnginePython/Private/UEPyEngine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ PyObject *py_unreal_engine_new_class(PyObject * self, PyObject * args) {
436436
return (PyObject *)ret;
437437
}
438438

439-
PyObject *py_unreal_engine_classes(PyObject * self, PyObject * args) {
439+
PyObject *py_unreal_engine_all_classes(PyObject * self, PyObject * args) {
440440

441441
PyObject *ret = PyList_New(0);
442442

Source/UnrealEnginePython/Private/UEPyEngine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ PyObject *py_unreal_engine_load_enum(PyObject *, PyObject *);
2727

2828
PyObject *py_unreal_engine_find_object(PyObject *, PyObject *);
2929

30-
PyObject *py_unreal_engine_classes(PyObject *, PyObject *);
30+
PyObject *py_unreal_engine_all_classes(PyObject *, PyObject *);
3131

3232

3333
PyObject *py_unreal_engine_new_object(PyObject *, PyObject *);

Source/UnrealEnginePython/Private/UEPyEnumsImporter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static PyTypeObject ue_PyEnumsImporterType = {
5555
0,
5656
};
5757

58-
void ue_python_init_Enumsimporter(PyObject *ue_module) {
58+
void ue_python_init_enumsimporter(PyObject *ue_module) {
5959
ue_PyEnumsImporterType.tp_new = PyType_GenericNew;
6060

6161
if (PyType_Ready(&ue_PyEnumsImporterType) < 0)

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static PyMethodDef unreal_engine_methods[] = {
214214

215215
{ "get_mutable_default", py_unreal_engine_get_mutable_default, METH_VARARGS, "" },
216216

217-
{ "classes", (PyCFunction)py_unreal_engine_classes, METH_VARARGS, "" },
217+
{ "all_classes", (PyCFunction)py_unreal_engine_all_classes, METH_VARARGS, "" },
218218

219219

220220
{ "new_class", py_unreal_engine_new_class, METH_VARARGS, "" },
@@ -1066,6 +1066,9 @@ void unreal_engine_init_py_module() {
10661066
ue_python_init_callable(new_unreal_engine_module);
10671067

10681068
ue_python_init_uclassesimporter(new_unreal_engine_module);
1069+
ue_python_init_enumsimporter(new_unreal_engine_module);
1070+
ue_python_init_ustructsimporter(new_unreal_engine_module);
1071+
10691072

10701073
#if WITH_EDITOR
10711074
ue_python_init_swidget(new_unreal_engine_module);
@@ -1087,6 +1090,10 @@ void unreal_engine_init_py_module() {
10871090
Py_INCREF(u_enums_importer);
10881091
PyDict_SetItemString(py_sys_modules, "unreal_engine.enums", u_enums_importer);
10891092

1093+
PyObject *u_structs_importer = py_ue_new_ustructsimporter();
1094+
Py_INCREF(u_structs_importer);
1095+
PyDict_SetItemString(py_sys_modules, "unreal_engine.structs", u_structs_importer);
1096+
10901097
PyDict_SetItemString(unreal_engine_dict, "ENGINE_MAJOR_VERSION", PyLong_FromLong(ENGINE_MAJOR_VERSION));
10911098
PyDict_SetItemString(unreal_engine_dict, "ENGINE_MINOR_VERSION", PyLong_FromLong(ENGINE_MINOR_VERSION));
10921099
PyDict_SetItemString(unreal_engine_dict, "ENGINE_PATCH_VERSION", PyLong_FromLong(ENGINE_PATCH_VERSION));
@@ -1336,7 +1343,9 @@ PyObject *ue_py_convert_property(UProperty *prop, uint8 *buffer) {
13361343
return PyErr_Format(PyExc_Exception, "invalid UClass type for %s", TCHAR_TO_UTF8(*casted_prop->GetName()));
13371344
}
13381345

1339-
// map a UStruct to a dictionary (if possible)
1346+
1347+
1348+
// try to manage known struct first
13401349
if (auto casted_prop = Cast<UStructProperty>(prop)) {
13411350
if (auto casted_struct = Cast<UScriptStruct>(casted_prop->Struct)) {
13421351
// check for FVector

Source/UnrealEnginePython/Private/UnrealEnginePythonPrivatePCH.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "UEPyCallable.h"
3939
#include "UEPyUClassesImporter.h"
4040
#include "UEPyEnumsImporter.h"
41+
#include "UEPyUStructsImporter.h"
4142

4243
#if WITH_EDITOR
4344
#include "UEPyFAssetData.h"

0 commit comments

Comments
 (0)