Skip to content

Commit db94627

Browse files
author
Roberto De Ioris
committed
second round of reference counting refactoring
1 parent 17a212b commit db94627

29 files changed

Lines changed: 1066 additions & 972 deletions

‎Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraph.cpp‎

Lines changed: 138 additions & 102 deletions
Large diffs are not rendered by default.

‎Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraphPin.cpp‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,9 @@ static int py_ue_edgraphpin_set_default_value(ue_PyEdGraphPin *self, PyObject *v
119119
static PyObject *py_ue_edgraphpin_get_default_object(ue_PyEdGraphPin *self, void *closure) {
120120
UObject *u_object = self->pin->DefaultObject;
121121
if (!u_object) {
122-
Py_INCREF(Py_None);
123-
return Py_None;
122+
Py_RETURN_NONE;
124123
}
125-
PyObject *ret = (PyObject *)ue_get_python_wrapper(u_object);
126-
if (!ret)
127-
return PyErr_Format(PyExc_Exception, "uobject is in invalid state");
128-
Py_INCREF(ret);
129-
return ret;
124+
Py_RETURN_UOBJECT(u_object);
130125
}
131126

132127
static int py_ue_edgraphpin_set_default_object(ue_PyEdGraphPin *self, PyObject *value, void *closure) {

‎Source/UnrealEnginePython/Private/PyCharacter.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void APyCharacter::PreInitializeComponents()
2929

3030
FScopePythonGIL gil;
3131

32-
py_uobject = ue_get_python_wrapper(this);
32+
py_uobject = ue_get_python_uobject(this);
3333
if (!py_uobject) {
3434
unreal_engine_py_log_error();
3535
return;
@@ -191,7 +191,7 @@ void APyCharacter::SetPythonAttrObject(FString attr, UObject *object)
191191

192192
FScopePythonGIL gil;
193193

194-
ue_PyUObject *py_obj = ue_get_python_wrapper(object);
194+
ue_PyUObject *py_obj = ue_get_python_uobject(object);
195195
if (!py_obj) {
196196
PyErr_Format(PyExc_Exception, "PyUObject is in invalid state");
197197
unreal_engine_py_log_error();
@@ -408,7 +408,7 @@ void APyCharacter::SetupPlayerInputComponent(class UInputComponent* input)
408408

409409
// no need to check for method availability, we did it in begin_play
410410

411-
PyObject *ret = PyObject_CallMethod(py_character_instance, (char *)"setup_player_input_component", (char *)"O", ue_get_python_wrapper(input));
411+
PyObject *ret = PyObject_CallMethod(py_character_instance, (char *)"setup_player_input_component", (char *)"O", ue_get_python_uobject(input));
412412
if (!ret) {
413413
unreal_engine_py_log_error();
414414
return;

‎Source/UnrealEnginePython/Private/PyHUD.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void APyHUD::BeginPlay()
2525

2626
FScopePythonGIL gil;
2727

28-
py_uobject = ue_get_python_wrapper(this);
28+
py_uobject = ue_get_python_uobject(this);
2929
if (!py_uobject)
3030
{
3131
unreal_engine_py_log_error();

‎Source/UnrealEnginePython/Private/PyPawn.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void APyPawn::PreInitializeComponents()
4141

4242
FScopePythonGIL gil;
4343

44-
py_uobject = ue_get_python_wrapper(this);
44+
py_uobject = ue_get_python_uobject(this);
4545
if (!py_uobject) {
4646
unreal_engine_py_log_error();
4747
return;

‎Source/UnrealEnginePython/Private/PyUserWidget.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void UPyUserWidget::NativeConstruct()
2727

2828
FScopePythonGIL gil;
2929

30-
py_uobject = ue_get_python_wrapper(this);
30+
py_uobject = ue_get_python_uobject(this);
3131
if (!py_uobject) {
3232
unreal_engine_py_log_error();
3333
return;

‎Source/UnrealEnginePython/Private/PythonDelegate.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ bool UPythonDelegate::Tick(float DeltaTime)
113113
void UPythonDelegate::PyFOnAssetPostImport(UFactory *factory, UObject *u_object)
114114
{
115115
FScopePythonGIL gil;
116-
PyObject *ret = PyObject_CallFunction(py_callable, (char *)"OO", ue_get_python_wrapper((UObject *)factory), ue_get_python_wrapper(u_object));
116+
PyObject *ret = PyObject_CallFunction(py_callable, (char *)"OO", ue_get_python_uobject((UObject *)factory), ue_get_python_uobject(u_object));
117117
if (!ret) {
118118
unreal_engine_py_log_error();
119119
return;

‎Source/UnrealEnginePython/Private/PythonFunction.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL)
3636
PyObject *py_args = PyTuple_New(argn);
3737

3838
if (Stack.Object && !is_static) {
39-
PyObject *py_obj = (PyObject *)ue_get_python_wrapper(Stack.Object);
39+
PyObject *py_obj = (PyObject *)ue_get_python_uobject(Stack.Object);
4040
if (!py_obj) {
4141
unreal_engine_py_log_error();
4242
on_error = true;

‎Source/UnrealEnginePython/Private/Slate/UEPySLevelViewport.cpp‎

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,16 @@
88

99
#define sw_level_viewport StaticCastSharedRef<SLevelViewport>(self->s_editor_viewport.s_compound_widget.s_widget.s_widget)
1010

11-
static PyObject *py_ue_slevel_viewport_get_world(ue_PySLevelViewport *self, PyObject * args) {
12-
13-
ue_PyUObject *ret = ue_get_python_wrapper(sw_level_viewport->GetWorld());
14-
if (!ret)
15-
return PyErr_Format(PyExc_Exception, "uobject is in invalid state");
16-
Py_INCREF(ret);
17-
return (PyObject *)ret;
11+
static PyObject *py_ue_slevel_viewport_get_world(ue_PySLevelViewport *self, PyObject * args)
12+
{
13+
Py_RETURN_UOBJECT(sw_level_viewport->GetWorld());
1814
}
1915

20-
static PyObject *py_ue_slevel_viewport_set_show_bounds(ue_PySLevelViewport *self, PyObject * args) {
16+
static PyObject *py_ue_slevel_viewport_set_show_bounds(ue_PySLevelViewport *self, PyObject * args)
17+
{
2118
PyObject *py_bool;
22-
if (!PyArg_ParseTuple(args, "O:set_show_bounds", &py_bool)) {
19+
if (!PyArg_ParseTuple(args, "O:set_show_bounds", &py_bool))
20+
{
2321
return NULL;
2422
}
2523

@@ -29,9 +27,11 @@ static PyObject *py_ue_slevel_viewport_set_show_bounds(ue_PySLevelViewport *self
2927
return (PyObject *)self;
3028
}
3129

32-
static PyObject *py_ue_slevel_viewport_set_show_stats(ue_PySLevelViewport *self, PyObject * args) {
30+
static PyObject *py_ue_slevel_viewport_set_show_stats(ue_PySLevelViewport *self, PyObject * args)
31+
{
3332
PyObject *py_bool;
34-
if (!PyArg_ParseTuple(args, "O:set_show_stats", &py_bool)) {
33+
if (!PyArg_ParseTuple(args, "O:set_show_stats", &py_bool))
34+
{
3535
return NULL;
3636
}
3737

@@ -41,9 +41,11 @@ static PyObject *py_ue_slevel_viewport_set_show_stats(ue_PySLevelViewport *self,
4141
return (PyObject *)self;
4242
}
4343

44-
static PyObject *py_ue_slevel_viewport_set_view_mode(ue_PySLevelViewport *self, PyObject * args) {
44+
static PyObject *py_ue_slevel_viewport_set_view_mode(ue_PySLevelViewport *self, PyObject * args)
45+
{
4546
int mode;
46-
if (!PyArg_ParseTuple(args, "i:set_view_mode", &mode)) {
47+
if (!PyArg_ParseTuple(args, "i:set_view_mode", &mode))
48+
{
4749
return NULL;
4850
}
4951

@@ -53,14 +55,17 @@ static PyObject *py_ue_slevel_viewport_set_view_mode(ue_PySLevelViewport *self,
5355
return (PyObject *)self;
5456
}
5557

56-
static PyObject *py_ue_slevel_viewport_set_exposure_settings(ue_PySPythonEditorViewport *self, PyObject * args) {
58+
static PyObject *py_ue_slevel_viewport_set_exposure_settings(ue_PySPythonEditorViewport *self, PyObject * args)
59+
{
5760
PyObject *py_settings;
58-
if (!PyArg_ParseTuple(args, "O:set_exposure_settings", &py_settings)) {
61+
if (!PyArg_ParseTuple(args, "O:set_exposure_settings", &py_settings))
62+
{
5963
return NULL;
6064
}
6165

6266
FExposureSettings *settings = ue_py_check_struct<FExposureSettings>(py_settings);
63-
if (!settings) {
67+
if (!settings)
68+
{
6469
return PyErr_Format(PyExc_Exception, "argument is not a FExposureSettings");
6570
}
6671

@@ -120,7 +125,8 @@ PyTypeObject ue_PySLevelViewportType = {
120125
ue_PySLevelViewport_methods, /* tp_methods */
121126
};
122127

123-
static int ue_py_slevel_viewport_init(ue_PySLevelViewport *self, PyObject *args, PyObject *kwargs) {
128+
static int ue_py_slevel_viewport_init(ue_PySLevelViewport *self, PyObject *args, PyObject *kwargs)
129+
{
124130

125131
FLevelEditorModule &EditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
126132

@@ -130,15 +136,16 @@ static int ue_py_slevel_viewport_init(ue_PySLevelViewport *self, PyObject *args,
130136

131137
ue_py_slate_farguments_optional_bool("realtime", Realtime);
132138
ue_py_slate_farguments_optional_enum("viewport_type", ViewportType, ELevelViewportType);
133-
139+
134140
ue_py_snew(SLevelViewport, s_editor_viewport.s_compound_widget.s_widget);
135141

136142
EditorModule.GetFirstLevelEditor()->AddStandaloneLevelViewport(sw_level_viewport);
137143

138144
return 0;
139145
}
140146

141-
void ue_python_init_slevel_viewport(PyObject *ue_module) {
147+
void ue_python_init_slevel_viewport(PyObject *ue_module)
148+
{
142149

143150
ue_PySLevelViewportType.tp_init = (initproc)ue_py_slevel_viewport_init;
144151

0 commit comments

Comments
 (0)