Skip to content

Commit 80a0977

Browse files
author
Roberto De Ioris
committed
first round of 4.18 patches
1 parent daa5eb8 commit 80a0977

File tree

4 files changed

+180
-72
lines changed

4 files changed

+180
-72
lines changed

Source/UnrealEnginePython/Private/UEPyIPlugin.cpp

Lines changed: 92 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,35 @@
55
#include "UnrealEnginePythonPrivatePCH.h"
66
#include "Runtime/Projects/Public/Interfaces/IPluginManager.h"
77

8-
static PyObject *py_ue_iplugin_get_name(ue_PyIPlugin *self, PyObject * args) {
8+
static PyObject *py_ue_iplugin_get_name(ue_PyIPlugin *self, PyObject * args)
9+
{
910
return PyUnicode_FromString(TCHAR_TO_UTF8(*(self->plugin->GetName())));
1011
}
1112

12-
static PyObject *py_ue_iplugin_get_base_dir(ue_PyIPlugin *self, PyObject * args) {
13+
static PyObject *py_ue_iplugin_get_base_dir(ue_PyIPlugin *self, PyObject * args)
14+
{
1315
return PyUnicode_FromString(TCHAR_TO_UTF8(*(self->plugin->GetBaseDir())));
1416
}
1517

16-
static PyObject *py_ue_iplugin_get_content_dir(ue_PyIPlugin *self, PyObject * args) {
18+
static PyObject *py_ue_iplugin_get_content_dir(ue_PyIPlugin *self, PyObject * args)
19+
{
1720
return PyUnicode_FromString(TCHAR_TO_UTF8(*(self->plugin->GetContentDir())));
1821
}
1922

20-
static PyObject *py_ue_iplugin_get_descriptor_file_name(ue_PyIPlugin *self, PyObject * args) {
23+
static PyObject *py_ue_iplugin_get_descriptor_file_name(ue_PyIPlugin *self, PyObject * args)
24+
{
2125
return PyUnicode_FromString(TCHAR_TO_UTF8(*(self->plugin->GetDescriptorFileName())));
2226
}
2327

24-
static PyObject *py_ue_iplugin_get_mounted_asset_path(ue_PyIPlugin *self, PyObject * args) {
28+
static PyObject *py_ue_iplugin_get_mounted_asset_path(ue_PyIPlugin *self, PyObject * args)
29+
{
2530
return PyUnicode_FromString(TCHAR_TO_UTF8(*(self->plugin->GetMountedAssetPath())));
2631
}
2732

28-
static PyObject *py_ue_iplugin_can_contain_content(ue_PyIPlugin *self, PyObject * args) {
29-
if (self->plugin->CanContainContent()) {
33+
static PyObject *py_ue_iplugin_can_contain_content(ue_PyIPlugin *self, PyObject * args)
34+
{
35+
if (self->plugin->CanContainContent())
36+
{
3037
Py_INCREF(Py_True);
3138
return Py_True;
3239
}
@@ -35,8 +42,10 @@ static PyObject *py_ue_iplugin_can_contain_content(ue_PyIPlugin *self, PyObject
3542
return Py_False;
3643
}
3744

38-
static PyObject *py_ue_iplugin_is_enabled(ue_PyIPlugin *self, PyObject * args) {
39-
if (self->plugin->IsEnabled()) {
45+
static PyObject *py_ue_iplugin_is_enabled(ue_PyIPlugin *self, PyObject * args)
46+
{
47+
if (self->plugin->IsEnabled())
48+
{
4049
Py_INCREF(Py_True);
4150
return Py_True;
4251
}
@@ -45,51 +54,62 @@ static PyObject *py_ue_iplugin_is_enabled(ue_PyIPlugin *self, PyObject * args) {
4554
return Py_False;
4655
}
4756

48-
static PyObject *py_ue_iplugin_to_json(ue_PyIPlugin *self, PyObject * args) {
57+
static PyObject *py_ue_iplugin_to_json(ue_PyIPlugin *self, PyObject * args)
58+
{
4959

5060

5161
PyObject *py_bool;
52-
if (!PyArg_ParseTuple(args, "O:to_json", &py_bool)) {
62+
if (!PyArg_ParseTuple(args, "O:to_json", &py_bool))
63+
{
5364
return NULL;
5465
}
5566

5667
bool enabled_by_default = false;
57-
if (PyObject_IsTrue(py_bool)) {
68+
if (PyObject_IsTrue(py_bool))
69+
{
5870
enabled_by_default = true;
5971
}
6072

6173
FPluginDescriptor descriptor = self->plugin->GetDescriptor();
6274
FString text;
6375
#if ENGINE_MINOR_VERSION < 14
6476
text = descriptor.ToString();
65-
#else
77+
#elif ENGINE_MINOR_VERSION <= 17
6678
descriptor.Write(text, enabled_by_default);
79+
#else
80+
descriptor.Write(text);
6781
#endif
6882

6983
return PyUnicode_FromString(TCHAR_TO_UTF8(*text));
7084
}
7185

72-
static PyObject *py_ue_iplugin_from_json(ue_PyIPlugin *self, PyObject * args) {
86+
static PyObject *py_ue_iplugin_from_json(ue_PyIPlugin *self, PyObject * args)
87+
{
7388

7489
char *json;
7590
PyObject *py_bool;
76-
if (!PyArg_ParseTuple(args, "sO:from_json", &json, &py_bool)) {
91+
if (!PyArg_ParseTuple(args, "sO:from_json", &json, &py_bool))
92+
{
7793
return NULL;
7894
}
7995

8096
bool enabled_by_default = false;
81-
if (PyObject_IsTrue(py_bool)) {
97+
if (PyObject_IsTrue(py_bool))
98+
{
8299
enabled_by_default = true;
83100
}
84101

85102
FText error;
86103
FString text = FString(UTF8_TO_TCHAR(json));
87104
FPluginDescriptor descriptor = self->plugin->GetDescriptor();
88105
#if ENGINE_MINOR_VERSION < 14
89-
if (!descriptor.Read(text, error)) {
106+
if (!descriptor.Read(text, error))
107+
#elif ENGINE_MINOR_VERSION <= 17
108+
if (!descriptor.Read(text, enabled_by_default, error))
90109
#else
91-
if (!descriptor.Read(text, enabled_by_default, error)) {
110+
if (!descriptor.Read(text, error))
92111
#endif
112+
{
93113
return PyErr_Format(PyExc_Exception, "unable to update descriptor from json");
94114
}
95115

@@ -110,12 +130,15 @@ static PyMethodDef ue_PyIPlugin_methods[] = {
110130
{ NULL } /* Sentinel */
111131
};
112132

113-
static PyObject *py_ue_iplugin_get_category(ue_PyIPlugin *self, void *closure) {
133+
static PyObject *py_ue_iplugin_get_category(ue_PyIPlugin *self, void *closure)
134+
{
114135
return PyUnicode_FromString(TCHAR_TO_UTF8(*(self->plugin->GetDescriptor().Category)));
115136
}
116137

117-
static PyObject *py_ue_iplugin_get_can_contain_content(ue_PyIPlugin *self, void *closure) {
118-
if (self->plugin->GetDescriptor().bCanContainContent) {
138+
static PyObject *py_ue_iplugin_get_can_contain_content(ue_PyIPlugin *self, void *closure)
139+
{
140+
if (self->plugin->GetDescriptor().bCanContainContent)
141+
{
119142
Py_INCREF(Py_True);
120143
return Py_True;
121144
}
@@ -124,8 +147,14 @@ static PyObject *py_ue_iplugin_get_can_contain_content(ue_PyIPlugin *self, void
124147
return Py_False;
125148
}
126149

127-
static PyObject *py_ue_iplugin_get_enabled_by_default(ue_PyIPlugin *self, void *closure) {
128-
if (self->plugin->GetDescriptor().bEnabledByDefault) {
150+
static PyObject *py_ue_iplugin_get_enabled_by_default(ue_PyIPlugin *self, void *closure)
151+
{
152+
#if ENGINE_MINOR_VERSION < 18
153+
if (self->plugin->GetDescriptor().bEnabledByDefault)
154+
#else
155+
if (self->plugin->GetDescriptor().EnabledByDefault == EPluginEnabledByDefault::Enabled)
156+
#endif
157+
{
129158
Py_INCREF(Py_True);
130159
return Py_True;
131160
}
@@ -134,8 +163,10 @@ static PyObject *py_ue_iplugin_get_enabled_by_default(ue_PyIPlugin *self, void *
134163
return Py_False;
135164
}
136165

137-
static PyObject *py_ue_iplugin_get_installed(ue_PyIPlugin *self, void *closure) {
138-
if (self->plugin->GetDescriptor().bInstalled) {
166+
static PyObject *py_ue_iplugin_get_installed(ue_PyIPlugin *self, void *closure)
167+
{
168+
if (self->plugin->GetDescriptor().bInstalled)
169+
{
139170
Py_INCREF(Py_True);
140171
return Py_True;
141172
}
@@ -144,8 +175,10 @@ static PyObject *py_ue_iplugin_get_installed(ue_PyIPlugin *self, void *closure)
144175
return Py_False;
145176
}
146177

147-
static PyObject *py_ue_iplugin_get_is_beta_version(ue_PyIPlugin *self, void *closure) {
148-
if (self->plugin->GetDescriptor().bIsBetaVersion) {
178+
static PyObject *py_ue_iplugin_get_is_beta_version(ue_PyIPlugin *self, void *closure)
179+
{
180+
if (self->plugin->GetDescriptor().bIsBetaVersion)
181+
{
149182
Py_INCREF(Py_True);
150183
return Py_True;
151184
}
@@ -154,48 +187,64 @@ static PyObject *py_ue_iplugin_get_is_beta_version(ue_PyIPlugin *self, void *clo
154187
return Py_False;
155188
}
156189

157-
static PyObject *py_ue_iplugin_created_by(ue_PyIPlugin *self, void *closure) {
190+
static PyObject *py_ue_iplugin_created_by(ue_PyIPlugin *self, void *closure)
191+
{
158192
return PyUnicode_FromString(TCHAR_TO_UTF8(*(self->plugin->GetDescriptor().CreatedBy)));
159193
}
160194

161-
static PyObject *py_ue_iplugin_created_by_url(ue_PyIPlugin *self, void *closure) {
195+
static PyObject *py_ue_iplugin_created_by_url(ue_PyIPlugin *self, void *closure)
196+
{
162197
return PyUnicode_FromString(TCHAR_TO_UTF8(*(self->plugin->GetDescriptor().CreatedByURL)));
163198
}
164199

165-
static PyObject *py_ue_iplugin_description(ue_PyIPlugin *self, void *closure) {
200+
static PyObject *py_ue_iplugin_description(ue_PyIPlugin *self, void *closure)
201+
{
166202
return PyUnicode_FromString(TCHAR_TO_UTF8(*(self->plugin->GetDescriptor().Description)));
167203
}
168204

169-
static PyObject *py_ue_iplugin_docs_url(ue_PyIPlugin *self, void *closure) {
205+
static PyObject *py_ue_iplugin_docs_url(ue_PyIPlugin *self, void *closure)
206+
{
170207
return PyUnicode_FromString(TCHAR_TO_UTF8(*(self->plugin->GetDescriptor().DocsURL)));
171208
}
172209

173-
static PyObject *py_ue_iplugin_friendly_name(ue_PyIPlugin *self, void *closure) {
210+
static PyObject *py_ue_iplugin_friendly_name(ue_PyIPlugin *self, void *closure)
211+
{
174212
return PyUnicode_FromString(TCHAR_TO_UTF8(*(self->plugin->GetDescriptor().FriendlyName)));
175213
}
176214

177-
static PyObject *py_ue_iplugin_marketplace_url(ue_PyIPlugin *self, void *closure) {
215+
static PyObject *py_ue_iplugin_marketplace_url(ue_PyIPlugin *self, void *closure)
216+
{
178217
return PyUnicode_FromString(TCHAR_TO_UTF8(*(self->plugin->GetDescriptor().MarketplaceURL)));
179218
}
180219

181-
static PyObject *py_ue_iplugin_support_url(ue_PyIPlugin *self, void *closure) {
220+
static PyObject *py_ue_iplugin_support_url(ue_PyIPlugin *self, void *closure)
221+
{
182222
return PyUnicode_FromString(TCHAR_TO_UTF8(*(self->plugin->GetDescriptor().SupportURL)));
183223
}
184224

185-
static PyObject *py_ue_iplugin_version_name(ue_PyIPlugin *self, void *closure) {
225+
static PyObject *py_ue_iplugin_version_name(ue_PyIPlugin *self, void *closure)
226+
{
186227
return PyUnicode_FromString(TCHAR_TO_UTF8(*(self->plugin->GetDescriptor().VersionName)));
187228
}
188229

189-
static PyObject *py_ue_iplugin_file_version(ue_PyIPlugin *self, void *closure) {
230+
static PyObject *py_ue_iplugin_file_version(ue_PyIPlugin *self, void *closure)
231+
{
232+
#if ENGINE_MINOR_VERSION < 18
190233
return PyLong_FromLong(self->plugin->GetDescriptor().FileVersion);
234+
#else
235+
return PyLong_FromLong(self->plugin->GetDescriptor().Version);
236+
#endif
191237
}
192238

193-
static PyObject *py_ue_iplugin_version(ue_PyIPlugin *self, void *closure) {
239+
static PyObject *py_ue_iplugin_version(ue_PyIPlugin *self, void *closure)
240+
{
194241
return PyLong_FromLong(self->plugin->GetDescriptor().Version);
195242
}
196243

197-
static PyObject *py_ue_iplugin_get_requires_build_platform(ue_PyIPlugin *self, void *closure) {
198-
if (self->plugin->GetDescriptor().bRequiresBuildPlatform) {
244+
static PyObject *py_ue_iplugin_get_requires_build_platform(ue_PyIPlugin *self, void *closure)
245+
{
246+
if (self->plugin->GetDescriptor().bRequiresBuildPlatform)
247+
{
199248
Py_INCREF(Py_True);
200249
return Py_True;
201250
}
@@ -264,7 +313,8 @@ static PyTypeObject ue_PyIPluginType = {
264313
};
265314

266315

267-
void ue_python_init_iplugin(PyObject *ue_module) {
316+
void ue_python_init_iplugin(PyObject *ue_module)
317+
{
268318
ue_PyIPluginType.tp_new = PyType_GenericNew;
269319

270320
if (PyType_Ready(&ue_PyIPluginType) < 0)
@@ -274,7 +324,8 @@ void ue_python_init_iplugin(PyObject *ue_module) {
274324
PyModule_AddObject(ue_module, "IPlugin", (PyObject *)&ue_PyIPluginType);
275325
}
276326

277-
PyObject *py_ue_new_iplugin(IPlugin *plugin) {
327+
PyObject *py_ue_new_iplugin(IPlugin *plugin)
328+
{
278329
ue_PyIPlugin *ret = (ue_PyIPlugin *)PyObject_New(ue_PyIPlugin, &ue_PyIPluginType);
279330
ret->plugin = plugin;
280331
return (PyObject *)ret;

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3079,7 +3079,9 @@ UFunction *unreal_engine_add_function(UClass *u_class, char *name, PyObject *py_
30793079
UPythonFunction *function = NewObject<UPythonFunction>(u_class, UTF8_TO_TCHAR(name), RF_Public | RF_Transient | RF_MarkAsNative);
30803080
function->SetPyCallable(py_callable);
30813081

3082+
#if ENGINE_MINOR_VERSION < 18
30823083
function->RepOffset = MAX_uint16;
3084+
#endif
30833085
function->ReturnValueOffset = MAX_uint16;
30843086
function->FirstPropertyToInit = NULL;
30853087
function->Script.Add(EX_EndFunctionParms);
@@ -3356,7 +3358,11 @@ UFunction *unreal_engine_add_function(UClass *u_class, char *name, PyObject *py_
33563358

33573359

33583360
u_class->Children = function;
3361+
#if ENGINE_MINOR_VERSION < 18
33593362
u_class->AddFunctionToFunctionMap(function);
3363+
#else
3364+
u_class->AddFunctionToFunctionMap(function, function->GetFName());
3365+
#endif
33603366

33613367
u_class->Bind();
33623368
u_class->StaticLink(true);

0 commit comments

Comments
 (0)