Skip to content

Commit 7a21ace

Browse files
author
David
committed
Added debug prints for property conversion from or to python.
1 parent 2ccfe75 commit 7a21ace

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,7 @@ static int ue_PyUObject_setattro(ue_PyUObject* self, PyObject* attr_name, PyObje
13651365
FProperty* f_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(attr)));
13661366
if (f_property)
13671367
{
1368+
EXTRA_UE_LOG(LogPython, Warning, TEXT("Setting attr found %s"), UTF8_TO_TCHAR(attr));
13681369
#ifdef EXTRA_DEBUG_CODE
13691370
if (!strcmp(attr, "TargetType"))
13701371
{
@@ -2512,6 +2513,7 @@ PyObject* ue_py_convert_property(FProperty* prop, uint8* buffer, int32 index)
25122513
if (auto casted_prop = CastField<FBoolProperty>(prop))
25132514
{
25142515
bool value = casted_prop->GetPropertyValue_InContainer(buffer, index);
2516+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_property: bool %d"), value);
25152517
if (value)
25162518
{
25172519
Py_RETURN_TRUE;
@@ -2521,45 +2523,56 @@ PyObject* ue_py_convert_property(FProperty* prop, uint8* buffer, int32 index)
25212523

25222524
if (auto casted_prop = CastField<FIntProperty>(prop))
25232525
{
2526+
// well I thought there was an issue here but turns out this is fine - its the test_blueprint.py thats wrong
2527+
//void* prop_addr = casted_prop->ContainerPtrToValuePtr<void>(buffer, index);
2528+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_property: number int %p (%p) %x"), buffer, prop_addr, *((uint64*)prop_addr));
2529+
//int value = casted_prop->GetPropertyValue(prop_addr);
25242530
int value = casted_prop->GetPropertyValue_InContainer(buffer, index);
2531+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_property: int %d %x"), value, value);
25252532
return PyLong_FromLong(value);
25262533
}
25272534

25282535
if (auto casted_prop = CastField<FUInt32Property>(prop))
25292536
{
25302537
uint32 value = casted_prop->GetPropertyValue_InContainer(buffer, index);
2538+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_property: uint %d"), value);
25312539
return PyLong_FromUnsignedLong(value);
25322540
}
25332541

25342542
if (auto casted_prop = CastField<FInt64Property>(prop))
25352543
{
25362544
long long value = casted_prop->GetPropertyValue_InContainer(buffer, index);
2545+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_property: ull %lld"), value);
25372546
return PyLong_FromLongLong(value);
25382547
}
25392548

25402549
// this is likely a bug - it was a FInt64Property before
25412550
if (auto casted_prop = CastField<FUInt64Property>(prop))
25422551
{
25432552
uint64 value = casted_prop->GetPropertyValue_InContainer(buffer, index);
2553+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_property: uint64 %lld"), value);
25442554
return PyLong_FromUnsignedLongLong(value);
25452555
}
25462556

25472557
if (auto casted_prop = CastField<FFloatProperty>(prop))
25482558
{
25492559
float value = casted_prop->GetPropertyValue_InContainer(buffer, index);
2560+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_property: float %f"), value);
25502561
return PyFloat_FromDouble(value);
25512562
}
25522563

25532564
if (auto casted_prop = CastField<FByteProperty>(prop))
25542565
{
25552566
uint8 value = casted_prop->GetPropertyValue_InContainer(buffer, index);
2567+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_property: uint8 %d"), value);
25562568
return PyLong_FromUnsignedLong(value);
25572569
}
25582570

25592571
if (auto casted_prop = CastField<FEnumProperty>(prop))
25602572
{
25612573
void* prop_addr = casted_prop->ContainerPtrToValuePtr<void>(buffer, index);
25622574
uint64 enum_index = casted_prop->GetUnderlyingProperty()->GetUnsignedIntPropertyValue(prop_addr);
2575+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_property: enum %lld"), enum_index);
25632576
return PyLong_FromUnsignedLong(enum_index);
25642577
}
25652578

@@ -2740,9 +2753,11 @@ PyObject* ue_py_convert_property(FProperty* prop, uint8* buffer, int32 index)
27402753
// convert a python object to a property
27412754
bool ue_py_convert_pyobject(PyObject* py_obj, FProperty* prop, uint8* buffer, int32 index)
27422755
{
2756+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_pyobject"));
27432757

27442758
if (PyBool_Check(py_obj))
27452759
{
2760+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_pyobject: bool"));
27462761
auto casted_prop = CastField<FBoolProperty>(prop);
27472762
if (!casted_prop)
27482763
return false;
@@ -2759,16 +2774,25 @@ bool ue_py_convert_pyobject(PyObject* py_obj, FProperty* prop, uint8* buffer, in
27592774

27602775
if (PyNumber_Check(py_obj))
27612776
{
2777+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_pyobject: number"));
27622778
if (auto casted_prop = CastField<FIntProperty>(prop))
27632779
{
27642780
PyObject* py_long = PyNumber_Long(py_obj);
2781+
//void* prop_addr = casted_prop->ContainerPtrToValuePtr<void>(buffer, index);
2782+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_pyobject: number int %p (%p) %ld"), buffer, prop_addr, PyLong_AsLong(py_long));
2783+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_property: number int %p (%p) %x"), buffer, prop_addr, *((uint64*)prop_addr));
2784+
//casted_prop->SetIntPropertyValue(prop_addr, (int64) PyLong_AsLong(py_long));
27652785
casted_prop->SetPropertyValue_InContainer(buffer, PyLong_AsLong(py_long), index);
27662786
Py_DECREF(py_long);
2787+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_property: number int %p (%p) %x"), buffer, prop_addr, *((uint64*)prop_addr));
27672788
return true;
27682789
}
27692790
if (auto casted_prop = CastField<FUInt32Property>(prop))
27702791
{
27712792
PyObject* py_long = PyNumber_Long(py_obj);
2793+
//void* prop_addr = casted_prop->ContainerPtrToValuePtr<void>(buffer, index);
2794+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_pyobject: number uint %p (%p) %ld"), buffer, prop_addr, PyLong_AsUnsignedLong(py_long));
2795+
//casted_prop->SetIntPropertyValue(prop_addr, (uint64) PyLong_AsUnsignedLong(py_long));
27722796
casted_prop->SetPropertyValue_InContainer(buffer, PyLong_AsUnsignedLong(py_long), index);
27732797
Py_DECREF(py_long);
27742798
return true;
@@ -2777,20 +2801,23 @@ bool ue_py_convert_pyobject(PyObject* py_obj, FProperty* prop, uint8* buffer, in
27772801
{
27782802
PyObject* py_long = PyNumber_Long(py_obj);
27792803
casted_prop->SetPropertyValue_InContainer(buffer, PyLong_AsLongLong(py_long), index);
2804+
//casted_prop->SetIntPropertyValue(buffer, PyLong_AsLongLong(py_long), index);
27802805
Py_DECREF(py_long);
27812806
return true;
27822807
}
27832808
if (auto casted_prop = CastField<FInt64Property>(prop))
27842809
{
27852810
PyObject* py_long = PyNumber_Long(py_obj);
27862811
casted_prop->SetPropertyValue_InContainer(buffer, PyLong_AsUnsignedLongLong(py_long), index);
2812+
//casted_prop->SetIntPropertyValue(buffer, PyLong_AsUnsignedLongLong(py_long), index);
27872813
Py_DECREF(py_long);
27882814
return true;
27892815
}
27902816
if (auto casted_prop = CastField<FFloatProperty>(prop))
27912817
{
27922818
PyObject* py_float = PyNumber_Float(py_obj);
27932819
casted_prop->SetPropertyValue_InContainer(buffer, PyFloat_AsDouble(py_float), index);
2820+
//casted_prop->SetFloatingPointPropertyValue(buffer, PyFloat_AsDouble(py_float), index);
27942821
Py_DECREF(py_float);
27952822
return true;
27962823
}
@@ -2810,11 +2837,14 @@ bool ue_py_convert_pyobject(PyObject* py_obj, FProperty* prop, uint8* buffer, in
28102837
return true;
28112838
}
28122839

2840+
EXTRA_UE_LOG(LogPython, Error, TEXT("ue_py_convert_pyobject: number FAILED"));
2841+
28132842
return false;
28142843
}
28152844

28162845
if (PyUnicodeOrString_Check(py_obj))
28172846
{
2847+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_pyobject: string"));
28182848
if (auto casted_prop = CastField<FStrProperty>(prop))
28192849
{
28202850
casted_prop->SetPropertyValue_InContainer(buffer, UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(py_obj)), index);
@@ -2830,11 +2860,13 @@ bool ue_py_convert_pyobject(PyObject* py_obj, FProperty* prop, uint8* buffer, in
28302860
casted_prop->SetPropertyValue_InContainer(buffer, FText::FromString(UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(py_obj))), index);
28312861
return true;
28322862
}
2863+
EXTRA_UE_LOG(LogPython, Error, TEXT("ue_py_convert_pyobject: string FAILED"));
28332864
return false;
28342865
}
28352866

28362867
if (PyBytes_Check(py_obj))
28372868
{
2869+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_pyobject: bytes"));
28382870
if (auto casted_prop = CastField<FArrayProperty>(prop))
28392871
{
28402872
FScriptArrayHelper_InContainer helper(casted_prop, buffer, index);
@@ -2862,11 +2894,13 @@ bool ue_py_convert_pyobject(PyObject* py_obj, FProperty* prop, uint8* buffer, in
28622894
}
28632895
}
28642896

2897+
EXTRA_UE_LOG(LogPython, Error, TEXT("ue_py_convert_pyobject: bytes FAILED"));
28652898
return false;
28662899
}
28672900

28682901
if (PyByteArray_Check(py_obj))
28692902
{
2903+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_pyobject: array"));
28702904
if (auto casted_prop = CastField<FArrayProperty>(prop))
28712905
{
28722906
FScriptArrayHelper_InContainer helper(casted_prop, buffer, index);
@@ -2895,11 +2929,13 @@ bool ue_py_convert_pyobject(PyObject* py_obj, FProperty* prop, uint8* buffer, in
28952929
}
28962930
}
28972931

2932+
EXTRA_UE_LOG(LogPython, Error, TEXT("ue_py_convert_pyobject: bytearray FAILED"));
28982933
return false;
28992934
}
29002935

29012936
if (PyList_Check(py_obj))
29022937
{
2938+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_pyobject: list"));
29032939
if (auto casted_prop = CastField<FArrayProperty>(prop))
29042940
{
29052941
FScriptArrayHelper_InContainer helper(casted_prop, buffer, index);
@@ -2928,11 +2964,13 @@ bool ue_py_convert_pyobject(PyObject* py_obj, FProperty* prop, uint8* buffer, in
29282964
return true;
29292965
}
29302966

2967+
EXTRA_UE_LOG(LogPython, Error, TEXT("ue_py_convert_pyobject: list FAILED"));
29312968
return false;
29322969
}
29332970

29342971
if (PyTuple_Check(py_obj))
29352972
{
2973+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_pyobject: tuple"));
29362974
if (auto casted_prop = CastField<FArrayProperty>(prop))
29372975
{
29382976
FScriptArrayHelper_InContainer helper(casted_prop, buffer, index);
@@ -2961,11 +2999,13 @@ bool ue_py_convert_pyobject(PyObject* py_obj, FProperty* prop, uint8* buffer, in
29612999
return true;
29623000
}
29633001

3002+
EXTRA_UE_LOG(LogPython, Error, TEXT("ue_py_convert_pyobject: tuple FAILED"));
29643003
return false;
29653004
}
29663005

29673006
if (PyDict_Check(py_obj))
29683007
{
3008+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_pyobject: dict"));
29693009
if (auto casted_prop = CastField<FMapProperty>(prop))
29703010
{
29713011
FScriptMapHelper_InContainer map_helper(casted_prop, buffer, index);
@@ -2996,13 +3036,15 @@ bool ue_py_convert_pyobject(PyObject* py_obj, FProperty* prop, uint8* buffer, in
29963036
return true;
29973037
}
29983038

3039+
EXTRA_UE_LOG(LogPython, Error, TEXT("ue_py_convert_pyobject: dict FAILED"));
29993040
return false;
30003041
}
30013042

30023043
// structs
30033044

30043045
if (ue_PyFVector * py_vec = py_ue_is_fvector(py_obj))
30053046
{
3047+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_pyobject: fvector"));
30063048
if (auto casted_prop = CastField<FStructProperty>(prop))
30073049
{
30083050
if (casted_prop->Struct == TBaseStructure<FVector>::Get())
@@ -3011,11 +3053,13 @@ bool ue_py_convert_pyobject(PyObject* py_obj, FProperty* prop, uint8* buffer, in
30113053
return true;
30123054
}
30133055
}
3056+
EXTRA_UE_LOG(LogPython, Error, TEXT("ue_py_convert_pyobject: fvector FAILED"));
30143057
return false;
30153058
}
30163059

30173060
if (ue_PyFVector2D * py_vec = py_ue_is_fvector2d(py_obj))
30183061
{
3062+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_pyobject: fvector2D"));
30193063
if (auto casted_prop = CastField<FStructProperty>(prop))
30203064
{
30213065
if (casted_prop->Struct == TBaseStructure<FVector2D>::Get())
@@ -3024,11 +3068,13 @@ bool ue_py_convert_pyobject(PyObject* py_obj, FProperty* prop, uint8* buffer, in
30243068
return true;
30253069
}
30263070
}
3071+
EXTRA_UE_LOG(LogPython, Error, TEXT("ue_py_convert_pyobject: fvector2D FAILED"));
30273072
return false;
30283073
}
30293074

30303075
if (ue_PyFRotator * py_rot = py_ue_is_frotator(py_obj))
30313076
{
3077+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_pyobject: frotator"));
30323078
if (auto casted_prop = CastField<FStructProperty>(prop))
30333079
{
30343080
if (casted_prop->Struct == TBaseStructure<FRotator>::Get())
@@ -3037,11 +3083,13 @@ bool ue_py_convert_pyobject(PyObject* py_obj, FProperty* prop, uint8* buffer, in
30373083
return true;
30383084
}
30393085
}
3086+
EXTRA_UE_LOG(LogPython, Error, TEXT("ue_py_convert_pyobject: frotator FAILED"));
30403087
return false;
30413088
}
30423089

30433090
if (ue_PyFTransform * py_transform = py_ue_is_ftransform(py_obj))
30443091
{
3092+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_pyobject: ftransform"));
30453093
if (auto casted_prop = CastField<FStructProperty>(prop))
30463094
{
30473095
if (casted_prop->Struct == TBaseStructure<FTransform>::Get())
@@ -3050,11 +3098,13 @@ bool ue_py_convert_pyobject(PyObject* py_obj, FProperty* prop, uint8* buffer, in
30503098
return true;
30513099
}
30523100
}
3101+
EXTRA_UE_LOG(LogPython, Error, TEXT("ue_py_convert_pyobject: ftransform FAILED"));
30533102
return false;
30543103
}
30553104

30563105
if (ue_PyFColor * py_color = py_ue_is_fcolor(py_obj))
30573106
{
3107+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_pyobject: fcolor"));
30583108
if (auto casted_prop = CastField<FStructProperty>(prop))
30593109
{
30603110
if (casted_prop->Struct == TBaseStructure<FColor>::Get())
@@ -3064,11 +3114,13 @@ bool ue_py_convert_pyobject(PyObject* py_obj, FProperty* prop, uint8* buffer, in
30643114
return true;
30653115
}
30663116
}
3117+
EXTRA_UE_LOG(LogPython, Error, TEXT("ue_py_convert_pyobject: fcolor FAILED"));
30673118
return false;
30683119
}
30693120

30703121
if (ue_PyFLinearColor * py_color = py_ue_is_flinearcolor(py_obj))
30713122
{
3123+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_pyobject: flinearcolor"));
30723124
if (auto casted_prop = CastField<FStructProperty>(prop))
30733125
{
30743126
if (casted_prop->Struct == TBaseStructure<FLinearColor>::Get())
@@ -3077,11 +3129,13 @@ bool ue_py_convert_pyobject(PyObject* py_obj, FProperty* prop, uint8* buffer, in
30773129
return true;
30783130
}
30793131
}
3132+
EXTRA_UE_LOG(LogPython, Error, TEXT("ue_py_convert_pyobject: flinearcolor FAILED"));
30803133
return false;
30813134
}
30823135

30833136
if (ue_PyFHitResult * py_hit = py_ue_is_fhitresult(py_obj))
30843137
{
3138+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_pyobject: fhitresult"));
30853139
if (auto casted_prop = CastField<FStructProperty>(prop))
30863140
{
30873141
if (casted_prop->Struct == FHitResult::StaticStruct())
@@ -3090,12 +3144,14 @@ bool ue_py_convert_pyobject(PyObject* py_obj, FProperty* prop, uint8* buffer, in
30903144
return true;
30913145
}
30923146
}
3147+
EXTRA_UE_LOG(LogPython, Error, TEXT("ue_py_convert_pyobject: fhitresult FAILED"));
30933148
return false;
30943149
}
30953150

30963151
// generic structs
30973152
if (py_ue_is_uscriptstruct(py_obj))
30983153
{
3154+
//EXTRA_UE_LOG(LogPython, Warning, TEXT("ue_py_convert_pyobject: uscriptstruct"));
30993155
ue_PyUScriptStruct* py_u_struct = (ue_PyUScriptStruct*)py_obj;
31003156
if (auto casted_prop = CastField<FStructProperty>(prop))
31013157
{
@@ -3107,6 +3163,7 @@ bool ue_py_convert_pyobject(PyObject* py_obj, FProperty* prop, uint8* buffer, in
31073163
return true;
31083164
}
31093165
}
3166+
EXTRA_UE_LOG(LogPython, Error, TEXT("ue_py_convert_pyobject: uscriptstruct FAILED"));
31103167
return false;
31113168
}
31123169

@@ -3160,6 +3217,7 @@ bool ue_py_convert_pyobject(PyObject* py_obj, FProperty* prop, uint8* buffer, in
31603217
return true;
31613218
}
31623219

3220+
EXTRA_UE_LOG(LogPython, Error, TEXT("ue_py_convert_pyobject: uclass FAILED"));
31633221
return false;
31643222
}
31653223

@@ -3206,6 +3264,7 @@ bool ue_py_convert_pyobject(PyObject* py_obj, FProperty* prop, uint8* buffer, in
32063264
return true;
32073265
}
32083266
}
3267+
EXTRA_UE_LOG(LogPython, Error, TEXT("ue_py_convert_pyobject: uobject FAILED"));
32093268
return false;
32103269
}
32113270

@@ -3227,6 +3286,7 @@ bool ue_py_convert_pyobject(PyObject* py_obj, FProperty* prop, uint8* buffer, in
32273286

32283287
return true;
32293288
}
3289+
EXTRA_UE_LOG(LogPython, Error, TEXT("ue_py_convert_pyobject: Py_None FAILED"));
32303290
return false;
32313291
}
32323292

0 commit comments

Comments
 (0)