@@ -571,8 +571,8 @@ void ue_pydelegates_cleanup(ue_PyUObject *self) {
571571 UE_LOG (LogPython, Warning, TEXT (" Removing UPythonDelegate %p from ue_PyUObject %p mapped to UObject %p" ), py_delegate, self, self->ue_object );
572572#endif
573573 py_delegate->RemoveFromRoot ();
574- }
575- }
574+ }
575+ }
576576 self->python_delegates_gc ->clear ();
577577 delete self->python_delegates_gc ;
578578 self->python_delegates_gc = nullptr ;
@@ -715,7 +715,6 @@ static PyObject *ue_PyUObject_call(ue_PyUObject *self, PyObject *args, PyObject
715715 Py_DECREF (py_args);
716716 return (PyObject *)ret;
717717 }
718-
719718 return PyErr_Format (PyExc_Exception, " the specified uobject has no __call__ support" );
720719}
721720
@@ -1065,6 +1064,8 @@ void unreal_engine_init_py_module() {
10651064
10661065 ue_python_init_callable (new_unreal_engine_module);
10671066
1067+ ue_python_init_uscriptstruct (new_unreal_engine_module);
1068+
10681069 ue_python_init_uclassesimporter (new_unreal_engine_module);
10691070 ue_python_init_enumsimporter (new_unreal_engine_module);
10701071 ue_python_init_ustructsimporter (new_unreal_engine_module);
@@ -1236,7 +1237,7 @@ void unreal_engine_py_log_error() {
12361237 }
12371238
12381239 PyErr_Clear ();
1239- }
1240+ }
12401241
12411242// retrieve a UWorld from a generic UObject (if possible)
12421243UWorld *ue_get_uworld (ue_PyUObject *py_obj) {
@@ -1343,8 +1344,6 @@ PyObject *ue_py_convert_property(UProperty *prop, uint8 *buffer) {
13431344 return PyErr_Format (PyExc_Exception, " invalid UClass type for %s" , TCHAR_TO_UTF8 (*casted_prop->GetName ()));
13441345 }
13451346
1346-
1347-
13481347 // try to manage known struct first
13491348 if (auto casted_prop = Cast<UStructProperty>(prop)) {
13501349 if (auto casted_struct = Cast<UScriptStruct>(casted_prop->Struct )) {
@@ -1373,11 +1372,7 @@ PyObject *ue_py_convert_property(UProperty *prop, uint8 *buffer) {
13731372 FLinearColor color = *casted_prop->ContainerPtrToValuePtr <FLinearColor>(buffer);
13741373 return py_ue_new_flinearcolor (color);
13751374 }
1376- ue_PyUObject *ret = ue_get_python_wrapper (casted_struct);
1377- if (!ret)
1378- return PyErr_Format (PyExc_Exception, " uobject is in invalid state" );
1379- Py_INCREF (ret);
1380- return (PyObject *)ret;
1375+ return (PyObject *)py_ue_new_uscriptstruct (casted_struct, casted_prop->ContainerPtrToValuePtr <uint8>(buffer));
13811376 }
13821377 return PyErr_Format (PyExc_TypeError, " unsupported UStruct type" );
13831378 }
@@ -1530,10 +1525,7 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer) {
15301525 return false ;
15311526 }
15321527
1533- // TODO encode a dictionary to a struct
1534- if (PyDict_Check (py_obj)) {
1535- return false ;
1536- }
1528+ // structs
15371529
15381530 if (ue_PyFVector *py_vec = py_ue_is_fvector (py_obj)) {
15391531 if (auto casted_prop = Cast<UStructProperty>(prop)) {
@@ -1595,6 +1587,18 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer) {
15951587 return false ;
15961588 }
15971589
1590+ // generic structs
1591+ if (py_ue_is_uscriptstruct (py_obj)) {
1592+ ue_PyUScriptStruct *py_u_struct = (ue_PyUScriptStruct *)py_obj;
1593+ if (auto casted_prop = Cast<UStructProperty>(prop)) {
1594+ if (casted_prop->Struct == py_u_struct->u_struct ) {
1595+ *casted_prop->ContainerPtrToValuePtr <uint8 *>(buffer) = py_u_struct->data ;
1596+ return true ;
1597+ }
1598+ }
1599+ return false ;
1600+ }
1601+
15981602 if (PyObject_IsInstance (py_obj, (PyObject *)&ue_PyUObjectType)) {
15991603 ue_PyUObject *ue_obj = (ue_PyUObject *)py_obj;
16001604 if (ue_obj->ue_object ->IsA <UClass>()) {
0 commit comments