| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 551c3d0 commit 3e1867c
10 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,19 @@ | |||
| 1 | + // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. | ||
| 2 | + | ||
| 3 | + #include "PythonAutomationModule.h" | ||
| 4 | + #include "UnrealEnginePython.h" | ||
| 5 | + #include "UEPyFAutomationEditorCommonUtils.h" | ||
| 6 | + | ||
| 7 | + IMPLEMENT_MODULE(FPythonAutomationModule, PythonAutomation); | ||
| 8 | + | ||
| 9 | + | ||
| 10 | + void FPythonAutomationModule::StartupModule() | ||
| 11 | + { | ||
| 12 | + PyObject *py_automation_module = ue_py_register_module("unreal_engine.automation"); | ||
| 13 | + ue_python_init_fautomation_editor_common_utils(py_automation_module); | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + void FPythonAutomationModule::ShutdownModule() | ||
| 17 | + { | ||
| 18 | + | ||
| 19 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,86 @@ | |||
| 1 | + | ||
| 2 | + #include "UEPyFAutomationEditorCommonUtils.h" | ||
| 3 | + | ||
| 4 | + #include "UnrealEnginePython.h" | ||
| 5 | + #include "Engine/World.h" | ||
| 6 | + | ||
| 7 | + | ||
| 8 | + static PyObject *py_ue_fautomation_editor_common_utils_run_pie(PyObject *cls, PyObject * args) | ||
| 9 | + { | ||
| 10 | + FAutomationEditorCommonUtils::RunPIE(); | ||
| 11 | + Py_RETURN_NONE; | ||
| 12 | + } | ||
| 13 | + | ||
| 14 | + static PyObject *py_ue_fautomation_editor_common_utils_load_map(PyObject *cls, PyObject * args) | ||
| 15 | + { | ||
| 16 | + char *map_name; | ||
| 17 | + if (!PyArg_ParseTuple(args, "s:load_map", &map_name)) | ||
| 18 | + return nullptr; | ||
| 19 | + FAutomationEditorCommonUtils::LoadMap(FString(UTF8_TO_TCHAR(map_name))); | ||
| 20 | + Py_RETURN_NONE; | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + static PyObject *py_ue_fautomation_editor_common_utils_create_new_map(PyObject *cls, PyObject * args) | ||
| 24 | + { | ||
| 25 | + Py_RETURN_UOBJECT(FAutomationEditorCommonUtils::CreateNewMap()); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + static PyMethodDef ue_PyFAutomationEditorCommonUtils_methods[] = { | ||
| 29 | + { "run_pie", (PyCFunction)py_ue_fautomation_editor_common_utils_run_pie, METH_VARARGS | METH_CLASS, "" }, | ||
| 30 | + { "load_map", (PyCFunction)py_ue_fautomation_editor_common_utils_load_map, METH_VARARGS | METH_CLASS, "" }, | ||
| 31 | + { "create_new_map", (PyCFunction)py_ue_fautomation_editor_common_utils_create_new_map, METH_VARARGS | METH_CLASS, "" }, | ||
| 32 | + | ||
| 33 | + { NULL } /* Sentinel */ | ||
| 34 | + }; | ||
| 35 | + | ||
| 36 | + | ||
| 37 | + static PyTypeObject ue_PyFAutomationEditorCommonUtilsType = { | ||
| 38 | + PyVarObject_HEAD_INIT(NULL, 0) | ||
| 39 | + "unreal_engine.FAutomationEditorCommonUtils", /* tp_name */ | ||
| 40 | + sizeof(ue_PyFAutomationEditorCommonUtils), /* tp_basicsize */ | ||
| 41 | + 0, /* tp_itemsize */ | ||
| 42 | + 0, /* tp_dealloc */ | ||
| 43 | + 0, /* tp_print */ | ||
| 44 | + 0, /* tp_getattr */ | ||
| 45 | + 0, /* tp_setattr */ | ||
| 46 | + 0, /* tp_reserved */ | ||
| 47 | + 0, /* tp_repr */ | ||
| 48 | + 0, /* tp_as_number */ | ||
| 49 | + 0, /* tp_as_sequence */ | ||
| 50 | + 0, /* tp_as_mapping */ | ||
| 51 | + 0, /* tp_hash */ | ||
| 52 | + 0, /* tp_call */ | ||
| 53 | + 0, /* tp_str */ | ||
| 54 | + 0, /* tp_getattro */ | ||
| 55 | + 0, /* tp_setattro */ | ||
| 56 | + 0, /* tp_as_buffer */ | ||
| 57 | + Py_TPFLAGS_DEFAULT, /* tp_flags */ | ||
| 58 | + "Unreal Engine AutomationEditorCommonUtils", /* tp_doc */ | ||
| 59 | + 0, /* tp_traverse */ | ||
| 60 | + 0, /* tp_clear */ | ||
| 61 | + 0, /* tp_richcompare */ | ||
| 62 | + 0, /* tp_weaklistoffset */ | ||
| 63 | + 0, /* tp_iter */ | ||
| 64 | + 0, /* tp_iternext */ | ||
| 65 | + ue_PyFAutomationEditorCommonUtils_methods, /* tp_methods */ | ||
| 66 | + 0, | ||
| 67 | + 0, | ||
| 68 | + }; | ||
| 69 | + | ||
| 70 | + static int py_ue_fautomation_editor_common_utils_init(ue_PyFAutomationEditorCommonUtils *self, PyObject * args) | ||
| 71 | + { | ||
| 72 | + PyErr_SetString(PyExc_Exception, "FAutomationEditorCommonUtils is a singleton"); | ||
| 73 | + return -1; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + void ue_python_init_fautomation_editor_common_utils(PyObject *ue_module) | ||
| 77 | + { | ||
| 78 | + ue_PyFAutomationEditorCommonUtilsType.tp_new = PyType_GenericNew; | ||
| 79 | + ue_PyFAutomationEditorCommonUtilsType.tp_init = (initproc)py_ue_fautomation_editor_common_utils_init; | ||
| 80 | + | ||
| 81 | + if (PyType_Ready(&ue_PyFAutomationEditorCommonUtilsType) < 0) | ||
| 82 | + return; | ||
| 83 | + | ||
| 84 | + Py_INCREF(&ue_PyFAutomationEditorCommonUtilsType); | ||
| 85 | + PyModule_AddObject(ue_module, "FAutomationEditorCommonUtils", (PyObject *)&ue_PyFAutomationEditorCommonUtilsType); | ||
| 86 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,13 @@ | |||
| 1 | + #pragma once | ||
| 2 | + | ||
| 3 | + #include "UnrealEnginePython.h" | ||
| 4 | + | ||
| 5 | + #include "Tests/AutomationEditorCommon.h" | ||
| 6 | + | ||
| 7 | + typedef struct | ||
| 8 | + { | ||
| 9 | + PyObject_HEAD | ||
| 10 | + /* Type-specific fields go here. */ | ||
| 11 | + } ue_PyFAutomationEditorCommonUtils; | ||
| 12 | + | ||
| 13 | + void ue_python_init_fautomation_editor_common_utils(PyObject *); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,14 @@ | |||
| 1 | + // Copyright 1998-2018 20Tab S.r.l. All Rights Reserved. | ||
| 2 | + | ||
| 3 | + #pragma once | ||
| 4 | + | ||
| 5 | + #include "CoreMinimal.h" | ||
| 6 | + #include "ModuleInterface.h" | ||
| 7 | + | ||
| 8 | + class FPythonAutomationModule : public IModuleInterface | ||
| 9 | + { | ||
| 10 | + public: | ||
| 11 | + virtual void StartupModule(); | ||
| 12 | + virtual void ShutdownModule(); | ||
| 13 | + | ||
| 14 | + }; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,34 @@ | |||
| 1 | + // Copyright 1998-2018 20Tab S.r.l All Rights Reserved. | ||
| 2 | + | ||
| 3 | + using UnrealBuildTool; | ||
| 4 | + using System.IO; | ||
| 5 | + | ||
| 6 | + public class PythonAutomation : ModuleRules | ||
| 7 | + { | ||
| 8 | + #if WITH_FORWARDED_MODULE_RULES_CTOR | ||
| 9 | + public PythonAutomation(ReadOnlyTargetRules Target) : base(Target) | ||
| 10 | + #else | ||
| 11 | + public PythonAutomation(TargetInfo Target) | ||
| 12 | + #endif | ||
| 13 | + { | ||
| 14 | + PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; | ||
| 15 | + | ||
| 16 | + PrivateIncludePaths.AddRange( | ||
| 17 | + new string[] { | ||
| 18 | + "PythonConsole/Private", | ||
| 19 | + // ... add other private include paths required here ... | ||
| 20 | + } | ||
| 21 | + ); | ||
| 22 | + | ||
| 23 | + PrivateDependencyModuleNames.AddRange( | ||
| 24 | + new string[] { | ||
| 25 | + "Core", | ||
| 26 | + "CoreUObject", // @todo Mac: for some reason it's needed to link in debug on Mac | ||
| 27 | + "Engine", | ||
| 28 | + "UnrealEd", | ||
| 29 | + "UnrealEnginePython" | ||
| 30 | + } | ||
| 31 | + ); | ||
| 32 | + | ||
| 33 | + } | ||
| 34 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1549,21 +1549,10 @@ void unreal_engine_init_py_module() | |||
| 1549 | 1549 | ||
| 1550 | 1550 | ue_python_init_ivoice_capture(new_unreal_engine_module); | |
| 1551 | 1551 | ||
| 1552 | - PyObject *py_sys = PyImport_ImportModule("sys"); | ||
| 1553 | - PyObject *py_sys_dict = PyModule_GetDict(py_sys); | ||
| 1552 | + ue_py_register_magic_module("unreal_engine.classes", py_ue_new_uclassesimporter); | ||
| 1553 | + ue_py_register_magic_module("unreal_engine.enums", py_ue_new_enumsimporter); | ||
| 1554 | + ue_py_register_magic_module("unreal_engine.structs", py_ue_new_ustructsimporter); | ||
| 1554 | 1555 | ||
| 1555 | - PyObject *py_sys_modules = PyDict_GetItemString(py_sys_dict, "modules"); | ||
| 1556 | - PyObject *u_classes_importer = py_ue_new_uclassesimporter(); | ||
| 1557 | - Py_INCREF(u_classes_importer); | ||
| 1558 | - PyDict_SetItemString(py_sys_modules, "unreal_engine.classes", u_classes_importer); | ||
| 1559 | - | ||
| 1560 | - PyObject *u_enums_importer = py_ue_new_enumsimporter(); | ||
| 1561 | - Py_INCREF(u_enums_importer); | ||
| 1562 | - PyDict_SetItemString(py_sys_modules, "unreal_engine.enums", u_enums_importer); | ||
| 1563 | - | ||
| 1564 | - PyObject *u_structs_importer = py_ue_new_ustructsimporter(); | ||
| 1565 | - Py_INCREF(u_structs_importer); | ||
| 1566 | - PyDict_SetItemString(py_sys_modules, "unreal_engine.structs", u_structs_importer); | ||
| 1567 | 1556 | ||
| 1568 | 1557 | PyDict_SetItemString(unreal_engine_dict, "ENGINE_MAJOR_VERSION", PyLong_FromLong(ENGINE_MAJOR_VERSION)); | |
| 1569 | 1558 | PyDict_SetItemString(unreal_engine_dict, "ENGINE_MINOR_VERSION", PyLong_FromLong(ENGINE_MINOR_VERSION)); | |
@@ -3187,7 +3176,7 @@ UFunction *unreal_engine_add_function(UClass *u_class, char *name, PyObject *py_ | |||
| 3187 | 3176 | #endif | |
| 3188 | 3177 | ||
| 3189 | 3178 | return function; | |
| 3190 | - } | ||
| 3179 | + } | ||
| 3191 | 3180 | ||
| 3192 | 3181 | FGuid *ue_py_check_fguid(PyObject *py_obj) | |
| 3193 | 3182 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,7 @@ | |||
| 6 | 6 | #include "UEPyUScriptStruct.h" | |
| 7 | 7 | #include "PythonHouseKeeper.h" | |
| 8 | 8 | ||
| 9 | - // common wrappers | ||
| 9 | + // common wrappersno | ||
| 10 | 10 | #include "Wrappers/UEPyFVector.h" | |
| 11 | 11 | #include "Wrappers/UEPyFRotator.h" | |
| 12 | 12 | #include "Wrappers/UEPyFQuat.h" | |
@@ -15,9 +15,7 @@ | |||
| 15 | 15 | #include "Wrappers/UEPyFLinearColor.h" | |
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | - void unreal_engine_py_log_error(); | ||
| 19 | - ue_PyUObject *ue_get_python_uobject(UObject *); | ||
| 20 | - ue_PyUObject *ue_get_python_uobject_inc(UObject *); | ||
| 18 | + | ||
| 21 | 19 | UWorld *ue_get_uworld(ue_PyUObject *); | |
| 22 | 20 | AActor *ue_get_actor(ue_PyUObject *); | |
| 23 | 21 | PyObject *ue_py_convert_property(UProperty *, uint8 *, int32); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -622,6 +622,22 @@ void FUnrealEnginePythonModule::RunFileSandboxed(char *filename, void(*callback) | |||
| 622 | 622 | PyThreadState_Swap(_main); | |
| 623 | 623 | } | |
| 624 | 624 | ||
| 625 | + void ue_py_register_magic_module(char *name, PyObject *(*func)()) | ||
| 626 | + { | ||
| 627 | + PyObject *py_sys = PyImport_ImportModule("sys"); | ||
| 628 | + PyObject *py_sys_dict = PyModule_GetDict(py_sys); | ||
| 629 | + | ||
| 630 | + PyObject *py_sys_modules = PyDict_GetItemString(py_sys_dict, "modules"); | ||
| 631 | + PyObject *u_module = func(); | ||
| 632 | + Py_INCREF(u_module); | ||
| 633 | + PyDict_SetItemString(py_sys_modules, name, u_module); | ||
| 634 | + } | ||
| 635 | + | ||
| 636 | + PyObject *ue_py_register_module(char *name) | ||
| 637 | + { | ||
| 638 | + return PyImport_AddModule(name); | ||
| 639 | + } | ||
| 640 | + | ||
| 625 | 641 | #undef LOCTEXT_NAMESPACE | |
| 626 | 642 | ||
| 627 | 643 | IMPLEMENT_MODULE(FUnrealEnginePythonModule, UnrealEnginePython) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,6 +48,9 @@ typedef struct | |||
| 48 | 48 | int auto_rooted; | |
| 49 | 49 | } ue_PyUObject; | |
| 50 | 50 | ||
| 51 | + UNREALENGINEPYTHON_API void ue_py_register_magic_module(char *name, PyObject *(*)()); | ||
| 52 | + UNREALENGINEPYTHON_API PyObject *ue_py_register_module(char *); | ||
| 53 | + | ||
| 51 | 54 | #if ENGINE_MINOR_VERSION >= 18 | |
| 52 | 55 | #define FStringAssetReference FSoftObjectPath | |
| 53 | 56 | #endif | |
@@ -67,6 +70,10 @@ int PyGILState_Check(); | |||
| 67 | 70 | #endif | |
| 68 | 71 | bool PyUnicodeOrString_Check(PyObject *py_obj); | |
| 69 | 72 | ||
| 73 | + UNREALENGINEPYTHON_API void unreal_engine_py_log_error(); | ||
| 74 | + UNREALENGINEPYTHON_API ue_PyUObject *ue_get_python_uobject(UObject *); | ||
| 75 | + UNREALENGINEPYTHON_API ue_PyUObject *ue_get_python_uobject_inc(UObject *); | ||
| 76 | + | ||
| 70 | 77 | #define Py_RETURN_UOBJECT(py_uobj) ue_PyUObject *ret = ue_get_python_uobject_inc(py_uobj);\ | |
| 71 | 78 | if (!ret)\ | |
| 72 | 79 | return PyErr_Format(PyExc_Exception, "uobject is in invalid state");\ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,22 +14,27 @@ | |||
| 14 | 14 | "CanContainContent": true, | |
| 15 | 15 | "IsBetaVersion": true, | |
| 16 | 16 | "Installed": false, | |
| 17 | - "Modules": [ | ||
| 17 | + "Modules": [ | ||
| 18 | 18 | { | |
| 19 | 19 | "Name": "UnrealEnginePython", | |
| 20 | 20 | "Type": "Runtime", | |
| 21 | 21 | "LoadingPhase": "Default" | |
| 22 | 22 | }, | |
| 23 | - { | ||
| 24 | - "Name": "PythonConsole", | ||
| 25 | - "Type": "Editor", | ||
| 26 | - "LoadingPhase": "PostDefault" | ||
| 27 | - }, | ||
| 28 | - { | ||
| 29 | - "Name" : "PythonEditor", | ||
| 30 | - "Type" : "Editor", | ||
| 31 | - "LoadingPhase": "PostDefault" | ||
| 32 | - } | ||
| 23 | + { | ||
| 24 | + "Name": "PythonAutomation", | ||
| 25 | + "Type": "Editor", | ||
| 26 | + "LoadingPhase": "PostDefault" | ||
| 27 | + }, | ||
| 28 | + { | ||
| 29 | + "Name": "PythonConsole", | ||
| 30 | + "Type": "Editor", | ||
| 31 | + "LoadingPhase": "PostDefault" | ||
| 32 | + }, | ||
| 33 | + { | ||
| 34 | + "Name": "PythonEditor", | ||
| 35 | + "Type": "Editor", | ||
| 36 | + "LoadingPhase": "PostDefault" | ||
| 37 | + } | ||
| 33 | 38 | ], | |
| 34 | 39 | "Plugins": [ | |
| 35 | 40 | { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments