Commit Graph

54 Commits

Author SHA1 Message Date
brandon schaefer
0fed9fa765 Get a DLLHandle for Linux as well when loadind in the python module
#jira UE-76551
#rb Jamie.Dale

#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: brandon.schaefer
#ROBOMERGE-SOURCE: CL 7094112 in //UE4/Release-4.23/... via CL 7094113
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR) (v367-6836689)

[CL 7153507 by brandon schaefer in Dev-VR branch]
2019-06-21 14:47:57 -04:00
jamie dale
f0ac621dbc CIS fix
#jira
#rb none
#rnx

#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: jamie.dale
#ROBOMERGE-SOURCE: CL 7064757 in //UE4/Release-4.23/... via CL 7064758
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR) (v367-6836689)

[CL 7151921 by jamie dale in Dev-VR branch]
2019-06-21 14:20:27 -04:00
jamie dale
d86f2a3931 Added additional tests for Python-generated overrides and non-POD data (re: CL# 7064650)
#jira UE-75405
#jira UE-75449
[FYI] Rex.Hill
#rb none
#rnx

#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: jamie.dale
#ROBOMERGE-SOURCE: CL 7064660 in //UE4/Release-4.23/... via CL 7064661
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR) (v367-6836689)

[CL 7151910 by jamie dale in Dev-VR branch]
2019-06-21 14:20:18 -04:00
jamie dale
7555be4aa6 Calling a Python-generated function no longer crashes when called from Blueprints, or with non-POD output data
The old logic for dealing with the parameters within the Unreal function thunk (UPythonGeneratedClass::CallPythonFunction and UPythonCallableForDelegate::CallPythonNative) assumed that Stack.Locals would be set-up correctly for input, and could be written to for output. This isn't true, as Stack.Locals is populated by a memcpy in UObject::ProcessEvent (so isn't safe to write to for non-POD data), and Blueprints just pass along their existing frame data since they skip the call to ProcessScriptFunction (as Python generated functions are marked FUNC_Native).

This change adds a common thunk processing function (PyGenUtil::InvokePythonCallableFromUnrealFunctionThunk) which is used when calling into Python from an Unreal function thunk. This function steps the data off the stack frame for each property, copying input data to Python, and building the output chain (FOutParmRec) from output data addresses. This matches what the UHT generated thunk does for native functions (via P_GET_PROPERTY and P_GET_PROPERTY_REF), as well as what ProcessScriptFunction does for functions with Blueprint bytecode.

#jira UE-75405
#jira UE-75449
[FYI] Rex.Hill
#rb Dan.OConnor

#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: jamie.dale
#ROBOMERGE-SOURCE: CL 7064650 in //UE4/Release-4.23/... via CL 7064651
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR) (v367-6836689)

[CL 7151907 by jamie dale in Dev-VR branch]
2019-06-21 14:20:16 -04:00
Jason Bestimt
e2a78c5cdc Merging //UE4/Dev-Main to Dev-VR (//UE4/Dev-VR)
#rb integration
#lockdown Nick.Whiting
#CodeReview: ryan.vance

[CL 6895021 by Jason Bestimt in Dev-VR branch]
2019-06-07 15:38:20 -04:00
Ryan Vance
66b718c72f Merging //UE4/Dev-Main to Dev-VR (//UE4/Dev-VR)
#rb integration
#lockdown Nick.Whiting

[CL 6841995 by Ryan Vance in Dev-VR branch]
2019-06-04 18:54:52 -04:00
jamie dale
983638a452 Added missing include
#jira UE-74616
#rb none
#rnx

#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: jamie.dale
#ROBOMERGE-SOURCE: CL 6576371 via CL 6580688 via CL 6580904
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR) (v364-6709755)

[CL 6714917 by jamie dale in Dev-VR branch]
2019-05-31 14:17:48 -04:00
jamie dale
ca041c3a19 Added an interface for UObject types that own Python data so that they can be cleared during interpreter shutdown if the UObject is still externally referenced and couldn't be GC'd
#jira UE-74616
#rb Lauren.Ridge

#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: jamie.dale
#ROBOMERGE-SOURCE: CL 6574505 via CL 6575624 via CL 6575649
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR) (v364-6709755)

[CL 6711487 by jamie dale in Dev-VR branch]
2019-05-31 14:03:05 -04:00
jamie dale
60b11cba8e Fixed delegate wrappers being incorrectly GC'd when no instances existed in Python
#jira UE-74616
#rb Lauren.Ridge

#ROBOMERGE-VERSION: 348-6547088
#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: jamie.dale
#ROBOMERGE-SOURCE: CL 6540091 via CL 6540633 via CL 6540650
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR)

[CL 6577970 by jamie dale in Dev-VR branch]
2019-05-20 13:59:04 -04:00
jamie dale
3f374b81e0 Disabling agressive Python type purging (and logging of lingering types) due to a GC crash
#jira
[FYI] Bob.Tellez
#rb none
#rnx

#ROBOMERGE-VERSION: 348-6547088
#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: jamie.dale
#ROBOMERGE-SOURCE: CL 6537281 via CL 6538664 via CL 6538750
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR)

[CL 6577410 by jamie dale in Dev-VR branch]
2019-05-20 13:45:44 -04:00
jamie dale
721c9efe1e Attempt to forcefully purge any Python generated Unreal types and their instances when shutting down the Python plugin
#jira UE-74616
#rb Lauren.Ridge

#ROBOMERGE-VERSION: 348-6547088
#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: jamie.dale
#ROBOMERGE-SOURCE: CL 6536765 via CL 6538378 via CL 6538487
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR)

[CL 6577236 by jamie dale in Dev-VR branch]
2019-05-20 13:41:28 -04:00
jamie dale
ee4acdabbb Ensure Python callable wrapper types remove the Native flag from any function signatures that they duplicate
Failing to do this leads to a Native instance inside a non-native instance, which causes GC confusion

#jira UE-74616
#rb Lauren.Ridge

#ROBOMERGE-VERSION: 348-6547088
#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: jamie.dale
#ROBOMERGE-SOURCE: CL 6536762 via CL 6538364 via CL 6538485
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR)

[CL 6577234 by jamie dale in Dev-VR branch]
2019-05-20 13:41:25 -04:00
jamie dale
e37daa3b54 Fixed name conflict when re-instancing Python generated structs
#jira UE-74324
#rb Lauren.Ridge
#lockdown Cristina.Riveron

#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: jamie.dale
#ROBOMERGE-SOURCE: CL 6405053 in //UE4/Release-4.22/... via CL 6405057
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR)

[CL 6489762 by jamie dale in Dev-VR branch]
2019-05-15 13:11:32 -04:00
jamie dale
6d053d5b91 init_unreal.py files are now run using the console scope to let them set-up the console environment in the editor
#jira
[FYI] James.McNatton
#rb Francis.Hurteau

#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: jamie.dale
#ROBOMERGE-SOURCE: CL 6112368 via CL 6113193 via CL 6113292
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR)

[CL 6132626 by jamie dale in Dev-VR branch]
2019-04-26 23:13:47 -04:00
jamie dale
9bb34a8291 Prevent a crash when a Python generated class pending reinstancing is GC'd
We now ARO these pending types to stop them being GC'd, and added unreal.flush_generated_type_reinstancing() to allow you to force the reinstancing to happen at a certain point in your script (rather than when it ends, or on the next Tick).

#jira UE-72853
#rb Chris.Gagnon
#lockdown Cristina.Riveron

#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: jamie.dale
#ROBOMERGE-SOURCE: CL 5956901 in //UE4/Release-4.22/... via CL 5956925
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR)

[CL 5963139 by jamie dale in Dev-VR branch]
2019-04-17 21:05:18 -04:00
steve robb
fa5082908a Fix for warnings about engine classes being hot reloaded when they haven't even changed.
#jira UE-71581
#rb none
[FYI] jamie.dale
#lockdown cristina.riveron

#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: steve.robb
#ROBOMERGE-SOURCE: CL 5459196 in //UE4/Release-4.22/... via CL 5459199
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR)

[CL 5477267 by steve robb in Dev-VR branch]
2019-03-20 13:30:59 -04:00
jamie dale
07a01fa35d Fixed Python doc generation
#jira
#rb none
[CODEREVIEW] Robb.Surridge
#rnx

#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: jamie.dale
#ROBOMERGE-SOURCE: CL 5439514 in //UE4/Release-4.22/... via CL 5439516
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR)

[CL 5442232 by jamie dale in Dev-VR branch]
2019-03-18 21:25:19 -04:00
marc audy
718ec962bc Dynamic Multicast delegates can now specify that their storage be stored in a sparse allocation for delegates that are expected to be bound rarely. The memory usage of an unbound sparse delegate is 1 byte instead of 16 bytes (for the empty array), however, a bound sparse delegate will have access overhead to retrieve the invocation list from the sparse object annotation.
The definition of the delegate type must specify the class and property name of the delegate that will use it and the type cannot be used outside of that context or just on the stack.
UMulticastDelegateProperty is now abstract and has 2 subclasses (UMulticastDelegateInlineProperty and UMulticastDelegateSparseProperty). The SparseProperty SignatureFunction will be a USparseDelegateFunction.
The sparse delegates do not work correctly with the python bindings at this point, but this will be visited soon.
#rb Michael.Noland
#jira

#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: marc.audy
#ROBOMERGE-SOURCE: CL 5295832 via CL 5306530 via CL 5306657
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR)

[CL 5323394 by marc audy in Dev-VR branch]
2019-03-06 18:07:13 -05:00
jamie dale
68751c2983 Fixed build error for platforms without a Python SDK available
#rb none

#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: jamie.dale
#ROBOMERGE-SOURCE: CL 5238143 via CL 5240388 via CL 5240463
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR)

[CL 5257220 by jamie dale in Dev-VR branch]
2019-02-28 18:39:23 -05:00
jamie dale
4f79d4d1e6 Added support for connecting to an existing editor instance to run Python commands on it remotely
This is off by default, and discovery is limited to the local host by default for safety. To enable it you need to turn on remote discovery in the Python plug-in project settings, which will make your editor discoverable for remote execution (via external scripts using the remote_execution.py module).

Remote execution uses a protocol of UTF-8 encoded JSON, and a combination of UDP-based multicast for discovery and remote connection requests, and TCP-based peer-to-peer communication for the actual command channel. See PythonScriptRemoteExecution.cpp for the full protocol definition.

remote_execution.py serves as both a reference implementation for the protocol implementation needed to connect to an editor instance, and as an out-of-the-box solution for applications that are written in (or can execute) Python (by importing it as a module and creating a RemoteExecution instance). remote_execution.py also provides a minimal example at the bottom of the file that demonstrates how to use the API, and this demo application can be seen by executing the file directly.

[FYI] Aaron.Carlisle
#rb Chris.Gagnon

#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: jamie.dale
#ROBOMERGE-SOURCE: CL 5229289 via CL 5236106 via CL 5236230
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR)

[CL 5254819 by jamie dale in Dev-VR branch]
2019-02-28 18:13:10 -05:00
jamie dale
0b131462f9 Added extra control over executing Python commands
You're now able to get back the execution result and log output from running a Python command, as well as control the execution mode of the command, and whether it should be run in "unattended" mode.

This is handled by the new IPythonScriptPlugin::ExecPythonCommandEx function which takes a FPythonCommandEx struct containing the input flags, mode, and command, as well as fields to fill in with the result and log output.

The mode can be set to one of the following:
  - ExecuteFile: Execute the Python command as a file. This allows you to execute either a literal Python script containing multiple statements, or a file with optional arguments.
  - ExecuteStatement: Execute the Python command as a single statement. This will execute a single statement and print the result. This mode cannot run files.
  - EvaluateStatement: Evaluate the Python command as a single statement. This will evaluate a single statement and return the result. This mode cannot run files.

ExecuteFile is the default to preserve existing behavior, however, since ExecuteStatement allows for a REPL like environment, there is now an additional command executor available ("Python (REPL)") which lets you build and test Python scripts in a similar manner to an interactive command line Python environment.

[FYI] Aaron.Carlisle
#rb Chris.Gagnon

#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: jamie.dale
#ROBOMERGE-SOURCE: CL 5229258 via CL 5236098 via CL 5236204
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR)

[CL 5254791 by jamie dale in Dev-VR branch]
2019-02-28 18:12:55 -05:00
marc audy
8bbedb058f Python wrapped delegate functions cannot be coerced down to UFunction as there will be serialization differences in the future
#jira
#rnx
[CODEREVIEW] Jamie.Dale

#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: marc.audy
#ROBOMERGE-SOURCE: CL 5205512 via CL 5205516 via CL 5205871 via CL 5229749
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR)

[CL 5245961 by marc audy in Dev-VR branch]
2019-02-28 17:13:45 -05:00
jamie dale
9725673ec3 Editor Utilities now respond to editor requests to cleanse object instances by clearing their references to any objects pending purge
This fixes crashes where they would take references to things like an actor within a world, and then the active editor world was changed (which verifies against GC reference leaks).

#jira UE-69150
[FYI] Michael.Noland
#rb Lauren.Ridge

#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: jamie.dale
#ROBOMERGE-SOURCE: CL 4987801 in //UE4/Release-4.22/... via CL 4987804
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR)

[CL 5034266 by jamie dale in Dev-VR branch]
2019-02-16 07:56:54 -05:00
jamie dale
8724eeae7f Hide BlueprintInternalUseOnly and CustomThunk functions from Python
BlueprintInternalUseOnly functions are usually designed to be called via a K2 node wrapper, which may provide additional sanitization or data transformation (which Python is unaware of, so cannot mimic).

CustomThunk functions rely on popping Bytecode data off the stack, but Python calls functions natively so there is no Bytecode available and these functions will crash. We hope to address CustomThunk support in the future by synthesizing the correct Bytecode.

#jira UE-69818
#rb none

#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: jamie.dale
#ROBOMERGE-SOURCE: CL 4951261 in //UE4/Release-4.22/... via CL 4951262
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR)

[CL 5026799 by jamie dale in Dev-VR branch]
2019-02-16 03:51:38 -05:00
jamie dale
cc80173d3b Don't export Python glue for classes that aren't Blueprintable, and have no script exposed fields
#jira UE-69367
#rb Francis.Hurteau

#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: jamie.dale
#ROBOMERGE-SOURCE: CL 4890469 in //UE4/Release-4.22/... via CL 4890471
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR)

[CL 4890485 by jamie dale in Dev-VR branch]
2019-02-04 15:31:14 -05:00