Commit Graph

257 Commits

Author SHA1 Message Date
Patrick Laflamme
e91967bd42 Added the __class_getitem__ to the PyWrapperArray, PyWrapperFixedArray, PyWrapperSet and PyWrapperMap to get type hinting working properly when container is used to hint an method input parameters or the return value (or simply declared globally).
- For more information, see https://peps.python.org/pep-0560/
  - Added corresponding tests to test_type_hints.py.

#jira UE-169542 - Type hinting not working properly with unreal.Array
#rb Jamie.Dale
#preflight 636bd021a550a2a75901cc22

[CL 23055484 by Patrick Laflamme in ue5-main branch]
2022-11-09 11:15:16 -05:00
henrik karlsson
fa90b399a4 Added includes for future change. This changelist only contains added #include and a couple of empty placeholder files
Tested compiling fortnite, unrealeditor, lyra, qagame with non-unity/pch

#preflight 63635997876630122adeab9f
#rb none

[CL 22958990 by henrik karlsson in ue5-main branch]
2022-11-03 14:18:47 -04:00
jeanfrancois dube
24188090b0 Fix all known cases of GetTypedOuter<UPackage> since it's not valid anymore with override packages.
#rb francis.hurteau
#preflight 633ee7528579446629e2cb5d
#rnx

[CL 22398835 by jeanfrancois dube in ue5-main branch]
2022-10-07 08:12:45 -04:00
bryan sefcik
50d4fac9e0 Updated ../Engine/Plugins/... to inline gen.cpp files
Before:
3548 unity files
Total CPU Time: 47343.578125 s
Total time in Parallel executor: 494.60 seconds

After:
3445 unity files
Total CPU Time: 46044.671875 s
Total time in Parallel executor: 468.51 seconds

#jira
#preflight 63336159b20e73a098b7f24f

[CL 22218213 by bryan sefcik in ue5-main branch]
2022-09-28 01:06:15 -04:00
patrick laflamme
c7155f94f0 Fixed Python doc generation failing becauses the bound types used in type hinting were not defined yet in the generated Python stub.
#rb none
#jira none
#rb trivial
#preflight 632360c863312bbbbb0c5b49

[CL 22039746 by patrick laflamme in ue5-main branch]
2022-09-15 17:56:54 -04:00
jamie dale
aee77705df Release the GIL before calling FPyWrapperTypeReinstancer::ProcessPending, not within it
Most places that call FPyWrapperTypeReinstancer::ProcessPending don't hold the GIL, so trying to release it inside just lead to an internal Python error

#jira
[FYI] Patrick.Laflamme, Nate.Horne
#rnx

[CL 22019592 by jamie dale in ue5-main branch]
2022-09-14 18:50:09 -04:00
daniel coelho
c7d4556cbd USD: Fix editor hang caused by sneaking into C++ from Python without releasing the GIL.
#jira UE-162470
#rb Jamie.Dale, Patrick.Laflamme, Anousack.Kitisa
#preflight 6318849ff448dc6e58579ea8

[CL 21847904 by daniel coelho in ue5-main branch]
2022-09-07 08:02:21 -04:00
jamie dale
7e3b0b73aa Fixed a GIL deadlock with unreal.load_class(...) to load a BPGC
#jira
#preflight skip
[FYI] Patrick.Laflamme

[CL 21772502 by jamie dale in ue5-main branch]
2022-09-02 21:07:18 -04:00
Patrick Laflamme
dac9c3e94a Fixed python type hinting for unreal.get_editor_subsystem() and unreal.get_engine_subsystem() to hint the correct types.
Thanks to Ryan DowlingSoka for this contribution.

#rb Jamie.Dale
#jira None
#preflight 63110a8e043c42d592cc82b6

[CL 21746103 by Patrick Laflamme in ue5-main branch]
2022-09-01 15:44:13 -04:00
Patrick Laflamme
1a119715ad Fix Python GIL deadlock with reinstancing object.
#rb Jamie.Dale
#jira None
#preflight 631106c2043c42d592cb2eda

[CL 21745879 by Patrick Laflamme in ue5-main branch]
2022-09-01 15:29:11 -04:00
matt johnson
3aa57e0140 PythonScriptPlugin: ensure that custom excepthooks are called with all three arguments
Custom excepthooks can be installed in Python to be invoked when an exception is
raised:

https://docs.python.org/3/library/sys.html#sys.excepthook

The excepthook is expected to take three arguments: the exception class, an
exception instance, and a traceback object.

The PythonScriptPlugin has some handling to detect when a custom excepthook is
installed and make sure that it gets called, which it does from C++ using
PyObject_CallFunctionObjArgs(). Depending on the exception though, it's possible
that the FPyObjectPtrs that hold the exception instance and/or the traceback object
could be invalid. When passed to PyObject_CallFunctionObjArgs(), their value then
becomes nullptr, which is used to signal the end of the arguments list to the function
and would therefore cause too few arguments to be passed to the excepthook.
This would put the interpreter into a bad state where it would continue to attempt to
call the excepthook with too few arguments, and no future commands would work.
The easiest way to get into this bad state was to install a custom excepthook and
then issue a Python command with invalid syntax. Doing so raises a SyntaxError with
no traceback object, since the code could not actually be executed.

To address this, we explicitly pass None for the exception instance and/or the traceback
object when they are invalid to ensure that the excepthook always receives three
arguments.

#rb jamie.dale
#preflight 62c5ba982a05d4f55b097757

[CL 20985039 by matt johnson in ue5-main branch]
2022-07-07 12:03:30 -04:00
Robb Surridge
0a5a02c5b2 Coding standard fixes: gender-inclusive language
#jira UE-156429
#preflight 62b32e826a25ba6ae52f94bd
#rb jason.walter

[CL 20795375 by Robb Surridge in ue5-main branch]
2022-06-23 11:14:07 -04:00
Matt Peters
803e794b36 AssetRegistryModule: Add TryGet function that can return null instead of asserting during Engine shutdown.
#jira UE-157056
#rb PJ.Kack
#rnx
#preflight 62b1d7fd827ccccb2cdec5a3

[CL 20758071 by Matt Peters in ue5-main branch]
2022-06-21 11:07:36 -04:00
matt hoffman
3757ca3b91 Editor: Ctrl + Console Key ( by default) now iterates through active Console Command Executors, so you can switch between Cmd and Python by hitting Ctrl + .
#jira None
#rb Yafes.Sahin, Rob.Millar
#preflight 62a0fabe232daff7b301295f

[CL 20563100 by matt hoffman in ue5-main branch]
2022-06-08 16:13:16 -04:00
ionut matasaru
0fed27e89c [Insights] Added LLM_SCOPEs in PythonScriptPlugin (in an effort to reduce the Untagged allocations).
#jira UE-153330
#rb Patrick.Laflamme
#preflight 62963192fe779f23c8e69ec7

[CL 20484022 by ionut matasaru in ue5-main branch]
2022-06-03 03:55:45 -04:00
robert manuszewski
d1443992e1 Deprecating ANY_PACKAGE.
This change consists of multiple changes:

Core:
- Deprecation of ANY_PACKAGE macro. Added ANY_PACKAGE_DEPRECATED macro which can still be used for backwards compatibility purposes (only used in CoreUObject)
- Deprecation of StaticFindObjectFast* functions that take bAnyPackage parameter
- Added UStruct::GetStructPathName function that returns FTopLevelAssetPath representing the path name (package + object FName, super quick compared to UObject::GetPathName) + wrapper UClass::GetClassPathName to make it look better when used with UClasses
- Added (Static)FindFirstObject* functions that find a first object given its Name (no Outer). These functions are used in places I consider valid to do global UObject (UClass) lookups like parsing command line parameters / checking for unique object names
- Added static UClass::TryFindType function which serves a similar purpose as FindFirstObject however it's going to throw a warning (with a callstack / maybe ensure in the future?) if short class name is provided. This function is used  in places that used to use short class names but now should have been converted to use path names to catch any potential regressions and or edge cases I missed.
- Added static UClass::TryConvertShortNameToPathName utility function
- Added static UClass::TryFixShortClassNameExportPath utility function
- Object text export paths will now also include class path (Texture2D'/Game/Textures/Grass.Grass' -> /Script/Engine.Texture2D'/Game/Textures/Grass.Grass')
- All places that manually generated object export paths for objects will now use FObjectPropertyBase::GetExportPath
- Added a new startup test that checks for short type names in UClass/FProperty MetaData values

AssetRegistry:
- Deprecated any member variables (FAssetData / FARFilter) or functions that use FNames to represent class names and replaced them with FTopLevelAssetPath
- Added new member variables and new function overloads that use FTopLevelAssetPath to represent class names
- This also applies to a few other modules' APIs to match AssetRegistry changes

Everything else:
- Updated code that used ANY_PACKAGE (depending on the use case) to use FindObject(nullptr, PathToObject), UClass::TryFindType (used when path name is expected, warns if it's a short name) or FindFirstObject (usually for finding types based on user input but there's been a few legitimate use cases not related to user input)
- Updated code that used AssetRegistry API to use FTopLevelAssetPaths and USomeClass::StaticClass()->GetClassPathName() instead of GetFName()
- Updated meta data and hardcoded FindObject(ANY_PACKAGE, "EEnumNameOrClassName") calls to use path names

#jira UE-99463
#rb many.people
[FYI] Marcus.Wassmer
#preflight 629248ec2256738f75de9b32

#codereviewnumbers 20320742, 20320791, 20320799, 20320756, 20320809, 20320830, 20320840, 20320846, 20320851, 20320863, 20320780, 20320765, 20320876, 20320786

#ROBOMERGE-OWNER: robert.manuszewski
#ROBOMERGE-AUTHOR: robert.manuszewski
#ROBOMERGE-SOURCE: CL 20430220 via CL 20433854 via CL 20435474 via CL 20435484
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v949-20362246)

[CL 20448496 by robert manuszewski in ue5-main branch]
2022-06-01 03:46:59 -04:00
Patrick Laflamme
275e131fb6 Fix CIS static analytis in PyGetUtil.cpp
#jira UE-154049 - //UE5/Main - Static Analysis Win64 (MSVC) - PyGenUtil.cpp warning: (<non-zero constant> && <expression>) always evaluates to the result of <expression>
#rb Trivial
#preflight 628e7c2ec826bd5a7f02e5e8

[CL 20370010 by Patrick Laflamme in ue5-main branch]
2022-05-25 15:34:21 -04:00
Patrick Laflamme
0781e8d761 Fixed CIS complaining about Native pointer usage in member declaration detected [[[UPyTestObject*]]].
#rb None
#preflight 628d25866c4351e3728bd797

[CL 20352975 by Patrick Laflamme in ue5-main branch]
2022-05-24 14:49:10 -04:00
Patrick Laflamme
ec3db1b24c Implemented Python Type Hinting when generating the Python stub.
- The 'Off' mode turns type hinting off and produce the Python stub as before.
  - The 'Auto-Completion' mode aims to provide types in Python IDE auto-completion while leaving out some information/complexity that clutter the function definition.
  - The 'Type Checker' mode aims to provide the closest to the truth (with some limitations) of the supported API types. Type coercion makes it harder to see the exact types.

Known limitations:
  - We don't know when a reflected UObject can legally be None. In 'Type Checker' mode, the UObject are always marked as typing.Optional[] everywhere to denotate that they can be None. Obviously, some methods never returns None and some method will fails if an Object is None. It might be annoying to users in some case.

#jira UE-119557 - Consider adding type hinting support to the unreal.py stub file
#rb Jamie.Dale
#preflight 628cf27f7778f10598b1e56d

[CL 20349869 by Patrick Laflamme in ue5-main branch]
2022-05-24 12:10:54 -04:00
robert manuszewski
f8a812a32f Converting hardcoded short class/enum names to pathnames ahead of ANY_PACKAGE removal
#rb trivial
#jira UE-99463
#preflight 6288fd998828ea88c8aef3d0

#ROBOMERGE-OWNER: robert.manuszewski
#ROBOMERGE-AUTHOR: robert.manuszewski
#ROBOMERGE-SOURCE: CL 20314896 via CL 20314897 via CL 20314903 via CL 20314904
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v948-20297126)

[CL 20315214 by robert manuszewski in ue5-main branch]
2022-05-22 10:30:02 -04:00
Patrick Laflamme
be778a24cf Fixed Python calling the wrong delegate if the same delegate name/type was declared in two different UObject.
Added a test in test_wrapper_types.py to validate before and after the fix.

#jira UE-148631 - GitHub 9069 : Python Type Registry Name Collision Fix
#9069
#rb Jamie.Dale
#preflight 628253a5c57a894cf67eab9d

[CL 20223162 by Patrick Laflamme in ue5-main branch]
2022-05-16 09:46:36 -04:00
Patrick Laflamme
7a486cdddb Undo //UE5/Main/Engine/Plugins/Experimental/PythonScriptPlugin/... changelist 20188886
It seems those change generates failures in some automation tasks checking asset references.
#rb None
#preflight None

[CL 20191520 by Patrick Laflamme in ue5-main branch]
2022-05-13 18:54:11 -04:00
Patrick Laflamme
464ce5a8b2 Fixed Python calling the wrong delegate if the same delegate name/type was declared in two different UObject.
Added a test in test_wrapper_types.py to validate before and after the fix.

#jira UE-148631 - GitHub 9069 : Python Type Registry Name Collision Fix
#9069
#rb Jamie.Dale
#preflight 627ebc38631ab4370513e79d

[CL 20188886 by Patrick Laflamme in ue5-main branch]
2022-05-13 16:44:31 -04:00
bob tellez
eb9c1e61f2 [Backout] - CL20169181
#fyi Patrick.Laflamme
Original CL Desc
-----------------------------------------------------------------
Fixed Python calling the wrong delegate if the same delegate name/type was declared in two different UObject.
Added a test in test_wrapper_types.py to validate before and after the fix.

#jira UE-148631 - GitHub 9069 : Python Type Registry Name Collision Fix
#9069
#rb Jamie.Dale
#preflight 627d5e294a05ef0394d5ac65

[CL 20173858 by bob tellez in ue5-main branch]
2022-05-12 19:17:40 -04:00
Patrick Laflamme
9281f15588 Fixed Python calling the wrong delegate if the same delegate name/type was declared in two different UObject.
Added a test in test_wrapper_types.py to validate before and after the fix.

#jira UE-148631 - GitHub 9069 : Python Type Registry Name Collision Fix
#rb Jamie.Dale
#preflight 627d5e294a05ef0394d5ac65

[CL 20169181 by Patrick Laflamme in ue5-main branch]
2022-05-12 15:31:14 -04:00