Skip to content

Commit 07c9c07

Browse files
author
Roberto De Ioris
committed
use if defined instead of plain if preprocessor
1 parent 5d1ef0b commit 07c9c07

13 files changed

Lines changed: 28 additions & 28 deletions

‎Source/UnrealEnginePython/Private/UEPyCallable.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// destructor
44
static void ue_pycallable_dealloc(ue_PyCallable *self) {
5-
#if UEPY_MEMORY_DEBUG
5+
#if defined(UEPY_MEMORY_DEBUG)
66
UE_LOG(LogPython, Warning, TEXT("Destroying ue_PyCallable %p mapped to UFunction %p"), self, self->u_function);
77
#endif
88
Py_TYPE(self)->tp_free((PyObject *)self);

‎Source/UnrealEnginePython/Private/UEPyModule.cpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ std::map<UObject *, ue_PyUObject *> ue_python_gc;
6161
static PyObject *py_unreal_engine_py_gc(PyObject * self, PyObject * args) {
6262
std::list<UObject *> broken_list;
6363
for (auto it : ue_python_gc) {
64-
#if UEPY_MEMORY_DEBUG
64+
#if defined(UEPY_MEMORY_DEBUG)
6565
UE_LOG(LogPython, Warning, TEXT("Checking for UObject at %p"), it.first);
6666
#endif
6767
UObject *u_obj = it.first;
6868
if (!u_obj || !u_obj->IsValidLowLevel() || u_obj->IsPendingKillOrUnreachable()) {
69-
#if UEPY_MEMORY_DEBUG
69+
#if defined(UEPY_MEMORY_DEBUG)
7070
UE_LOG(LogPython, Warning, TEXT("Removing UObject at %p (refcnt: %d)"), it.first, it.second->ob_base.ob_refcnt);
7171
#endif
7272
broken_list.push_back(u_obj);
@@ -583,7 +583,7 @@ void ue_pydelegates_cleanup(ue_PyUObject *self) {
583583
return;
584584
for (UPythonDelegate *py_delegate : *(self->python_delegates_gc)) {
585585
if (py_delegate && py_delegate->IsValidLowLevel()) {
586-
#if UEPY_MEMORY_DEBUG
586+
#if defined(UEPY_MEMORY_DEBUG)
587587
UE_LOG(LogPython, Warning, TEXT("Removing UPythonDelegate %p from ue_PyUObject %p mapped to UObject %p"), py_delegate, self, self->ue_object);
588588
#endif
589589
py_delegate->RemoveFromRoot();
@@ -598,7 +598,7 @@ void ue_pydelegates_cleanup(ue_PyUObject *self) {
598598

599599
// destructor
600600
static void ue_pyobject_dealloc(ue_PyUObject *self) {
601-
#if UEPY_MEMORY_DEBUG
601+
#if defined(UEPY_MEMORY_DEBUG)
602602
UE_LOG(LogPython, Warning, TEXT("Destroying ue_PyUObject %p mapped to UObject %p"), self, self->ue_object);
603603
#endif
604604
ue_pydelegates_cleanup(self);
@@ -1189,7 +1189,7 @@ ue_PyUObject *ue_get_python_wrapper(UObject *ue_obj) {
11891189

11901190
ue_python_gc[ue_obj] = ue_py_object;
11911191

1192-
#if UEPY_MEMORY_DEBUG
1192+
#if defined(UEPY_MEMORY_DEBUG)
11931193
UE_LOG(LogPython, Warning, TEXT("CREATED UPyObject at %p for %p %s"), ue_py_object, ue_obj, *ue_obj->GetName());
11941194
#endif
11951195
//Py_INCREF(ue_py_object);

‎Source/UnrealEnginePython/Private/UEPyUScriptStruct.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ static int ue_PyUScriptStruct_setattro(ue_PyUScriptStruct *self, PyObject *attr_
128128

129129
// destructor
130130
static void ue_PyUScriptStruct_dealloc(ue_PyUScriptStruct *self) {
131-
#if UEPY_MEMORY_DEBUG
131+
#if defined(UEPY_MEMORY_DEBUG)
132132
UE_LOG(LogPython, Warning, TEXT("Destroying ue_PyUScriptStruct %p with size %d"), self, self->u_struct->GetStructureSize());
133133
#endif
134134
FMemory::Free(self->data);

‎Source/UnrealEnginePython/Private/UnrealEnginePython.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
void unreal_engine_init_py_module();
66

7-
#if UNREAL_ENGINE_PYTHON_ON_LINUX
7+
#if defined(UNREAL_ENGINE_PYTHON_ON_LINUX)
88
const char *ue4_module_options = "linux_global_symbols";
99
#endif
1010

@@ -43,15 +43,15 @@ bool PyUnicodeOrString_Check(PyObject *py_obj) {
4343

4444

4545
void FUnrealEnginePythonModule::PythonGILRelease() {
46-
#if UEPY_THREADING
46+
#if defined(UEPY_THREADING)
4747
if (PyGILState_Check() == 1) {
4848
ue_python_gil = PyEval_SaveThread();
4949
}
5050
#endif
5151
}
5252

5353
bool FUnrealEnginePythonModule::PythonGILAcquire() {
54-
#if UEPY_THREADING
54+
#if defined(UEPY_THREADING)
5555
if (PyGILState_Check() == 0) {
5656
PyEval_RestoreThread((PyThreadState *)ue_python_gil);
5757
return true;

‎Source/UnrealEnginePython/Private/UnrealEnginePythonPrivatePCH.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515

1616
#include "Runtime/Launch/Resources/Version.h"
1717

18-
#if UNREAL_ENGINE_PYTHON_ON_MAC
18+
#if defined(UNREAL_ENGINE_PYTHON_ON_MAC)
1919
#include <Headers/Python.h>
2020
#include <Headers/structmember.h>
21-
#elif UNREAL_ENGINE_PYTHON_ON_LINUX
21+
#elif defined(UNREAL_ENGINE_PYTHON_ON_LINUX)
2222
#include <Python.h>
2323
#include <structmember.h>
2424
#else

‎Source/UnrealEnginePython/Public/PyActor.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,14 @@ APyActor::~APyActor()
202202

203203
ue_pydelegates_cleanup(py_uobject);
204204

205-
#if UEPY_MEMORY_DEBUG
205+
#if defined(UEPY_MEMORY_DEBUG)
206206
if (py_actor_instance && py_actor_instance->ob_refcnt != 1) {
207207
UE_LOG(LogPython, Error, TEXT("Inconsistent Python AActor wrapper refcnt = %d"), py_actor_instance->ob_refcnt);
208208
}
209209
#endif
210210
Py_XDECREF(py_actor_instance);
211211

212-
#if UEPY_MEMORY_DEBUG
212+
#if defined(UEPY_MEMORY_DEBUG)
213213
UE_LOG(LogPython, Warning, TEXT("Python AActor %p (mapped to %p) wrapper XDECREF'ed"), this, py_uobject ? py_uobject->ue_object : nullptr);
214214
#endif
215215

‎Source/UnrealEnginePython/Public/PyCharacter.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,14 +365,14 @@ APyCharacter::~APyCharacter()
365365

366366
ue_pydelegates_cleanup(py_uobject);
367367

368-
#if UEPY_MEMORY_DEBUG
368+
#if defined(UEPY_MEMORY_DEBUG)
369369
if (py_character_instance && py_character_instance->ob_refcnt != 1) {
370370
UE_LOG(LogPython, Error, TEXT("Inconsistent Python ACharacter wrapper refcnt = %d"), py_character_instance->ob_refcnt);
371371
}
372372
#endif
373373
Py_XDECREF(py_character_instance);
374374

375-
#if UEPY_MEMORY_DEBUG
375+
#if defined(UEPY_MEMORY_DEBUG)
376376
UE_LOG(LogPython, Warning, TEXT("Python ACharacter (mapped to %p) wrapper XDECREF'ed"), py_uobject ? py_uobject->ue_object : nullptr);
377377
#endif
378378

‎Source/UnrealEnginePython/Public/PyCommandlet.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ int32 UPyCommandlet::Main(const FString& CommandLine)
7272
{
7373
#if PY_MAJOR_VERSION >= 3
7474
argv[i] = (wchar_t*)malloc(PyArgv[i].Len()+1);
75-
#if UNREAL_ENGINE_PYTHON_ON_MAC || UNREAL_ENGINE_PYTHON_ON_LINUX
75+
#if defined(UNREAL_ENGINE_PYTHON_ON_MAC) || defined(UNREAL_ENGINE_PYTHON_ON_LINUX)
7676
wcsncpy(argv[i], *PyArgv[i].ReplaceEscapedCharWithChar(), PyArgv[i].Len() + 1);
7777
#else
7878
wcscpy_s(argv[i], PyArgv[i].Len() + 1, *PyArgv[i].ReplaceEscapedCharWithChar());
7979
#endif
8080
#else
8181
argv[i] = (char*)malloc(PyArgv[i].Len() + 1);
82-
#if UNREAL_ENGINE_PYTHON_ON_MAC || UNREAL_ENGINE_PYTHON_ON_LINUX
82+
#if defined(UNREAL_ENGINE_PYTHON_ON_MAC) || defined(UNREAL_ENGINE_PYTHON_ON_LINUX)
8383
strncpy(argv[i], TCHAR_TO_UTF8(*PyArgv[i].ReplaceEscapedCharWithChar()), PyArgv[i].Len()+1);
8484
#else
8585
strcpy_s(argv[i], PyArgv[i].Len()+1, TCHAR_TO_UTF8(*PyArgv[i].ReplaceEscapedCharWithChar()));

‎Source/UnrealEnginePython/Public/PyPawn.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,15 @@ APyPawn::~APyPawn()
179179

180180
ue_pydelegates_cleanup(py_uobject);
181181

182-
#if UEPY_MEMORY_DEBUG
182+
#if defined(UEPY_MEMORY_DEBUG)
183183
if (py_pawn_instance && py_pawn_instance->ob_refcnt != 1) {
184184
UE_LOG(LogPython, Error, TEXT("Inconsistent Python APawn wrapper refcnt = %d"), py_pawn_instance->ob_refcnt);
185185
}
186186
#endif
187187
Py_XDECREF(py_pawn_instance);
188188

189189

190-
#if UEPY_MEMORY_DEBUG
190+
#if defined(UEPY_MEMORY_DEBUG)
191191
UE_LOG(LogPython, Warning, TEXT("Python APawn (mapped to %p) wrapper XDECREF'ed"), py_uobject ? py_uobject->ue_object : nullptr);
192192
#endif
193193

‎Source/UnrealEnginePython/Public/PythonComponent.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,14 +426,14 @@ UPythonComponent::~UPythonComponent()
426426

427427
ue_pydelegates_cleanup(py_uobject);
428428

429-
#if UEPY_MEMORY_DEBUG
429+
#if defined(UEPY_MEMORY_DEBUG)
430430
if (py_component_instance && py_component_instance->ob_refcnt != 1) {
431431
UE_LOG(LogPython, Error, TEXT("Inconsistent Python UActorComponent wrapper refcnt = %d"), py_component_instance->ob_refcnt);
432432
}
433433
#endif
434434
Py_XDECREF(py_component_instance);
435435

436-
#if UEPY_MEMORY_DEBUG
436+
#if defined(UEPY_MEMORY_DEBUG)
437437
UE_LOG(LogPython, Warning, TEXT("Python UActorComponent %p (mapped to %p) wrapper XDECREF'ed"), this, py_uobject ? py_uobject->ue_object : nullptr);
438438
#endif
439439

0 commit comments

Comments
 (0)