Commit Graph

221 Commits

Author SHA1 Message Date
Helge Mathee
a06c227d07 PythonScriptPlugin: Add import_text / export_text to wrapped structs
#rb jamie.dale
#jira na
#preflight https://horde.devtools.epicgames.com/job/624f06d16d3bb118aaefa1b9

[CL 19673734 by Helge Mathee in ue5-main branch]
2022-04-07 13:57:56 -04:00
jamie dale
e48aa1e99a Search for both 'CPP_Default_X' and 'X' in the function meta-data when resolving the default value of an argument
The latter is used by BP functions, as well as C++ functions that have default arguments that UHT can't parse (eg, a default TMap argument).

#jira
#preflight 62470f9d470aff98e97e71db
#rb Patrick.Laflamme
#rnx

#ROBOMERGE-AUTHOR: jamie.dale
#ROBOMERGE-SOURCE: CL 19590554 via CL 19591745 via CL 19591775 via CL 19591795
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v938-19570697)

[CL 19593534 by jamie dale in ue5-main branch]
2022-04-01 15:09:57 -04:00
jamie dale
502bb2e067 Avoid attempting to generate Python glue for non-C++ types when running the initial glue generation step
#preflight skip
#rb Patrick.Laflamme
#rnx

#ROBOMERGE-AUTHOR: jamie.dale
#ROBOMERGE-SOURCE: CL 19540585 via CL 19542169 via CL 19542171 via CL 19542178
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v937-19513599)

[CL 19544202 by jamie dale in ue5-main branch]
2022-03-29 12:44:13 -04:00
patrick laflamme
3468243bdc In Python stub generation, changed a check() to a checkf() to log the name of the UFunction that was detected as a delegate but didn't have the FUNC_Delegate flag.
#rb Jamie.Dale
#preflight 623cc56bf765c25e98e82454

#ROBOMERGE-AUTHOR: patrick.laflamme
#ROBOMERGE-SOURCE: CL 19502518 via CL 19505190 via CL 19505328
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v937-19513599)

[CL 19514626 by patrick laflamme in ue5-main branch]
2022-03-25 12:34:51 -04:00
dave jones2
135eb09732 UE-146778 - CIS Content Error: Unhandled implicit casts found during compilation of function
The BP compiler erroneously reports that python nodes might be missing implicit casts. However, UK2Node_ExecutePythonScript nodes handle argument slightly differently than conventional function nodes. The pins don't actually correspond to actual arguments on ExecutePythonScript. Instead, they more or less serve as references to their linked inputs, which ExecutePythonScript will pop from the stack and perform a direct conversion to a Python type. As a result, there's nothing to cast, and we can safely remove the entries from the ImplicitCastMap on the current content.

#rb jamie.dale
#jira UE-146778
#preflight 623b4fbeca34ffd7bf7db3e8

[CL 19482561 by dave jones2 in ue5-main branch]
2022-03-23 14:24:22 -04:00
jamie dale
7a31d8565b Moved the code to import default function argument values to a common location so it can be shared
#jira
#preflight 622b9e5eea76b02e348882e3
#rb Patrick.Laflamme

#ROBOMERGE-AUTHOR: jamie.dale
#ROBOMERGE-SOURCE: CL 19392086 via CL 19395541 via CL 19399560 via CL 19399642
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v926-19321884)

[CL 19403795 by jamie dale in ue5-main branch]
2022-03-16 03:49:31 -04:00
Patrick Laflamme
a64e090bae Fixed Python GIL (Global Interpreter Lock) deadlock while loading an asset.
- Released the GIL in Finalize() - rename class, get default object and refresh BlueprintActionDatabase

#jira FORT-444807 - Python Load_Asset is causing the editor to hang if it has to load certain assets
#rb Jamie.Dale, Patrick.Laflamme

#ushell-cherrypick of 19292501 by Max.Chen
#preflight 6226843d1938e4deaa7916fc

[CL 19293291 by Patrick Laflamme in ue5-main branch]
2022-03-07 17:37:07 -05:00
marc audy
cff01aa9fa Added support for native FProperty setters and getters.
Setters and getters are native functions called by FProperties when setting property values with *_InContainer functions.
Setters and getter function names can be manually specified with Setter = Func and Getter = Func keywords inside of UPROEPRTY macro but they will also be automatically parsed if the name is not explicitly specified if the setter or getter function name matches SetPropertyName and GetPropertyName pattern.
The latter behavior can be disabled in UHT's DefaultEngine.ini by setting AutomaticSettersAndGetters=False.
ImportText and ExportTextItem functions have been deprecated and should be replaced with *_InContainer or *_Direct variants.

#rb Steve.Robb
#preflight 6210a377a83e0bcefd03d9e1

#ROBOMERGE-OWNER: marc.audy
#ROBOMERGE-AUTHOR: robert.manuszewski
#ROBOMERGE-SOURCE: CL 19070318 via CL 19098059 via CL 19104650 via CL 19104661 via CL 19110012
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v921-19075845)

[CL 19147839 by marc audy in ue5-main branch]
2022-02-25 10:39:39 -05:00
robert manuszewski
c36e03d5e3 do clause support
#rb Andrew.Scheidecker
#preflight 620f3a108863746a104d6c36

#ROBOMERGE-AUTHOR: robert.manuszewski
#ROBOMERGE-SOURCE: CL 19047989 via CL 19048186 via CL 19048197 via CL 19048203 via CL 19049414
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v918-19018356)

[CL 19065767 by robert manuszewski in ue5-main branch]
2022-02-21 00:33:13 -05:00
patrick laflamme
ce6fb0e451 Fix CIS error in PyWrapperTypeRegistry.cpp.
#rb None
#preflight Trivial

#ROBOMERGE-AUTHOR: patrick.laflamme
#ROBOMERGE-SOURCE: CL 18807217 in //UE5/Release-5.0/... via CL 18809182 via CL 18822221
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v908-18788545)

[CL 18823247 by patrick laflamme in ue5-main branch]
2022-02-02 05:29:00 -05:00
patrick laflamme
9cfdc160f5 Fixed Python plugin to allow resolving USTRUCT Make/Break functions specifed with 'HasNativeMake' and 'HasNativeBreak' later. This supports cases where the function are implemented in a C++ module that is loaded after the module declaring the USTRUCT. The implementation postpones resolving missing functions until FCoreDelegates::OnPostEngineInit is invoked. If one or more functions are still missing, corresponding error(s) are logged.
#jira UE-92057 - Investigate deferring the function resolution for Make/Break meta-data in Python
#rb Jamie.Dale
#preflight 61f84aa35a026d2d19b62c70

#ROBOMERGE-AUTHOR: patrick.laflamme
#ROBOMERGE-SOURCE: CL 18796649 in //UE5/Release-5.0/... via CL 18797780 via CL 18798499
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v908-18788545)

[CL 18798615 by patrick laflamme in ue5-main branch]
2022-01-31 17:03:42 -05:00
patrick laflamme
b065712809 Fixed Python GIL (Global Interpreter Lock) deadlock while loading an asset.
- Released the GIL while loading or finding an asset.
  - Released the GIL while loading or finding an object.
  - Released the GIL while loading or finding packages.
  - Released the GIL while logging/flushing stdout/stderr from Python.

#rb Jamie.Dale
#preflight 61f2fb1d1f12674afbbf9933

#ROBOMERGE-AUTHOR: patrick.laflamme
#ROBOMERGE-SOURCE: CL 18764878 via CL 18764883 via CL 18764890 via CL 18765457 via CL 18765586
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v903-18687472)

[CL 18765591 by patrick laflamme in ue5-main branch]
2022-01-27 19:16:00 -05:00
Patrick Laflamme
868b0d24be Instrumented Python plugin loading time and saved about 500ms to the total module startup time.
#rb Jamie.Dale
#preflight 61f1bba6be0f0e0a623e7697

[CL 18745211 by Patrick Laflamme in ue5-main branch]
2022-01-26 16:44:45 -05:00
patrick laflamme
98e5880317 Fixed the Editor Python Executor to parse and escape quotes for -ExecutePythonScript command line parameters to allow quoting python arguments containing spaces.
#jira UE-136852 - Running python script with -ExecutePythonScript doesn't allow passing python arguments with spaces
#rb Jamie.Dale

#ROBOMERGE-AUTHOR: patrick.laflamme
#ROBOMERGE-SOURCE: CL 18405205 in //UE5/Release-5.0/... via CL 18405209
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v896-18170469)

[CL 18405211 by patrick laflamme in ue5-release-engine-test branch]
2021-12-08 09:14:28 -05:00
patrick laflamme
bb19374ec4 Fixed MakeTransform() function to take a default value for Scale parameter -> "static FTransform MakeTransform(FVector Location, FRotator Rotation, FVector Scale = FVector(1,1,1))"
- Removed the meta=(MakeStructureDefaultValue= "1,1,1") from the FTransform struct because Unreal Header Tool is already capable to deduce that from the MakeTransform() default C++ prameter.
  - Removed the meta=(Scale = "1,1,1") from MakeTransform UFUNCTION because that can be deduced by Unread Header Toold from the default C++ parameter.

Fixed Python code not invoking the a 'Make' function (declared with meta HasNativeMake on a USTRUCT) if no parameters were supplied to Python (ex. unreal.Transform() would not call the MakeTransform(...)).
  - In most case, not calling the Make function worked as expected, but the Make function could implement side effects, so always honor it.

Resaved BP macro assets using MakeTransform() with the default values. The default values saved as string with the asset changed from "1,1,1" to "1.000000,1.000000,1.000000" and this triggered a BP Compiler warning.

The following tests were performed:
  - In the Blueprint Editor, added a Make Transform node and ensured the default values for scale were (1, 1, 1)
  - In the Blueprint Editor, created a User Defined Struct, added as a member a Transform, ensured the default values for the transform scale were (1, 1, 1)
  - Added a Python regression unit tests to ensure unreal.Transform() takes the default scale value as (1, 1, 1) if the scale parameter is not provided.
  - Created a Blueprint Macro Libraries with a Macro calling MakeTransform() with default parameters, saved it, applied the fix, got the warning, refreshed the node, resaved the macro and ensured the macro used the correct default scale.

#jira UE-133741 - MakeStructureDefaultValue is not used in Python
#rb Jamie.Dale

#ROBOMERGE-OWNER: patrick.laflamme
#ROBOMERGE-AUTHOR: patrick.laflamme
#ROBOMERGE-SOURCE: CL 18337929 via CL 18338143 via CL 18338146 via CL 18338492 via CL 18338517
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469)

[CL 18338531 by patrick laflamme in ue5-release-engine-test branch]
2021-12-01 09:27:11 -05:00
patrick laflamme
3997d12563 Prevented adding non-existing directories to Python 'sys.path'
- This makes Python a bit faster at startup (according to my benchmark) and reduce noise looking at the sys.path.

#jira UE-135129 - Avoid adding non-existing directory to Python 'sys.path'
#rb Jamie.Dale

#ROBOMERGE-AUTHOR: patrick.laflamme
#ROBOMERGE-SOURCE: CL 18324422 in //UE5/Release-5.0/... via CL 18324431
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469)

[CL 18324435 by patrick laflamme in ue5-release-engine-test branch]
2021-11-30 09:43:25 -05:00
patrick laflamme
612889c784 Removed C++ code from PythonScriptPlugin refering to Python 2.x.
#jira UE-135651 - Remove Python 2.7 from UE5 (Phase 2)
#rb Jamie.Dale
#preflight 619cfb96c3287aab27f02ddc

#ROBOMERGE-AUTHOR: patrick.laflamme
#ROBOMERGE-SOURCE: CL 18270005 in //UE5/Release-5.0/... via CL 18270039
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469)

[CL 18270053 by patrick laflamme in ue5-release-engine-test branch]
2021-11-23 10:12:09 -05:00
Marc Audy
0c3be2b6ad Merge Release-Engine-Staging to Test @ CL# 18240298
[CL 18241953 by Marc Audy in ue5-release-engine-test branch]
2021-11-18 14:37:34 -05:00
aurel cordonnier
fc542f6cfd Merge from Release-Engine-Staging @ 18081189 to Release-Engine-Test
This represents UE4/Main @18073326, Release-5.0 @18081140 and Dev-PerfTest @18045971

[CL 18081471 by aurel cordonnier in ue5-release-engine-test branch]
2021-11-07 23:43:01 -05:00
patrick laflamme
87e164b574 Exposed UEnum display name to Python through method get_display_name(). Ex: print(unreal.TextureCompressionSettings.TC_GRAYSCALE.get_display_name())
- Supported reading the enum entry display name set in C++ as well as the one injected from python with the [at]uenum annotation.
  - Added unit tests.

#jira UE-132375 - Add a way for python to get the friendly name of an enum value
#rb Jamie.Dale

#ROBOMERGE-AUTHOR: patrick.laflamme
#ROBOMERGE-SOURCE: CL 18019999 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v885-17909292)

[CL 18020038 by patrick laflamme in ue5-release-engine-test branch]
2021-11-02 11:34:25 -04:00
jeanmichel dignard
8a9d07083d Python: Fixed an issue where remove_callable wouldn't work if the callable was a method (vs a function).
PyObject ptr equality doesn't work for method objects as there's a new instance everytime.
Instead, compare the callables tp_call pointers and PyMethod_Self values for methods.

#rb Patrick.Laflamme, Jamie.Dale

#ROBOMERGE-AUTHOR: jeanmichel.dignard
#ROBOMERGE-SOURCE: CL 17981106 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v885-17909292)

[CL 17981189 by jeanmichel dignard in ue5-release-engine-test branch]
2021-10-29 11:32:36 -04:00
aurel cordonnier
a6e741e007 Merge from Release-Engine-Staging @ 17915896 to Release-Engine-Test
This represents UE4/Main @17911760, Release-5.0 @17915875 and Dev-PerfTest @17914035

[CL 17918595 by aurel cordonnier in ue5-release-engine-test branch]
2021-10-25 20:05:28 -04:00
aurel cordonnier
a12d56ff31 Merge from Release-Engine-Staging @ 17791557 to Release-Engine-Test
This represents UE4/Main @17774255, Release-5.0 @17791557 and Dev-PerfTest @17789485

[CL 17794212 by aurel cordonnier in ue5-release-engine-test branch]
2021-10-12 21:21:22 -04:00
patrick laflamme
9aa3d1c4ae Fixed static analyzer complaining about int/bool comparison in Python
- Used static_cast<bool>() to work with both python 3.7 and 3.9. The macro expression type changed from bool to int between the versions.

#jira UE-126618 - //UE5/Main - UE4 Static Analysis Win64 (PVS-Studio) - pyengine.cpp compares a bool type value with a value of 0
#rb Brooke.Hubert

#ROBOMERGE-AUTHOR: patrick.laflamme
#ROBOMERGE-SOURCE: CL 17523778 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530)

[CL 17523850 by patrick laflamme in ue5-release-engine-test branch]
2021-09-15 14:25:05 -04:00
patrick laflamme
6a6f7b7560 Minor fixes to prepare for the upcoming Python 3.9.7 update.
- Tested those fixes with Python 3.7.x (current) and 3.9.7 (upcoming) on Windows and Mac

#jira UE-124978 - Upgrade to Python 3.9.x
#rb Jamie.Dale

#ROBOMERGE-AUTHOR: patrick.laflamme
#ROBOMERGE-SOURCE: CL 17491930 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530)

[CL 17491945 by patrick laflamme in ue5-release-engine-test branch]
2021-09-13 10:43:11 -04:00