diff --git a/CMakePresets.json b/CMakePresets.json index 087b9ab..120c024 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -148,7 +148,7 @@ "name": "_release", "hidden": true, "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release" + "CMAKE_BUILD_TYPE": "RelWithDebInfo" } }, { diff --git a/changelog.md b/changelog.md index 376e46d..1834014 100644 --- a/changelog.md +++ b/changelog.md @@ -1,8 +1,12 @@ # Changelog ## v1.8.0 +- Added `WeakPointer.replace`, to modify a pointer in-place. + - Trying to overwrite the return value of a void function will now return a more appropriate error. +- The type hinting of `WrappedArray`s now default to `WrappedArray[Any]`, no generic required. + - Upgraded to support unrealsdk v2 - native modules can expect some breakage. The most notable effect this has on Python code is a number of formerly read-only fields on core unreal types have become read-write. diff --git a/common_cmake b/common_cmake index 0b1c32d..17528aa 160000 --- a/common_cmake +++ b/common_cmake @@ -1 +1 @@ -Subproject commit 0b1c32de1ff98a7851f798d6b092edd1e89e5eba +Subproject commit 17528aa7461deea26f55b2d7dc9ede720feee4c3 diff --git a/libs/unrealsdk b/libs/unrealsdk index c577cc5..693de07 160000 --- a/libs/unrealsdk +++ b/libs/unrealsdk @@ -1 +1 @@ -Subproject commit c577cc52e7a383071dc6f9917cfc039d14f4b991 +Subproject commit 693de073544b7d69e0a7e88efa1fed8e86fac160 diff --git a/src/pyunrealsdk/unreal_bindings/weak_pointer.cpp b/src/pyunrealsdk/unreal_bindings/weak_pointer.cpp index a8a16f8..c71b86a 100644 --- a/src/pyunrealsdk/unreal_bindings/weak_pointer.cpp +++ b/src/pyunrealsdk/unreal_bindings/weak_pointer.cpp @@ -34,7 +34,17 @@ void register_weak_pointer(py::module_& mod) { "be safe under a hook, since the GC shouldn't be running.\n" "\n" "Returns:\n" - " The object this is pointing at, or None if it's become invalid."); + " The object this is pointing at, or None if it's become invalid.") + .def( + "replace", [](WeakPointer& self, const UObject* obj) { self = WeakPointer{obj}; }, + "Replaces the reference in this pointer in-place.\n" + "\n" + "This is equivalent to assigning the same variable to a new pointer, but may be\n" + "more convenient when modifying a parent scope.\n" + "\n" + "Args:\n" + " obj: The new object to hold a weak reference to.", + "obj"_a); // Create as a class method, see pybind11#1693 cls.attr("__class_getitem__") = py::reinterpret_borrow(PyClassMethod_New( diff --git a/stubs/unrealsdk/unreal/_weak_pointer.pyi b/stubs/unrealsdk/unreal/_weak_pointer.pyi index 4223563..ec06ece 100644 --- a/stubs/unrealsdk/unreal/_weak_pointer.pyi +++ b/stubs/unrealsdk/unreal/_weak_pointer.pyi @@ -30,6 +30,17 @@ class WeakPointer[T: UObject = UObject]: The object this is pointing at, or None if it's become invalid. """ + def replace(self, obj: T | None) -> None: + """ + Replaces the reference in this pointer in-place. + + This is equivalent to assigning the same variable to a new pointer, but may be + more convenient when modifying a parent scope. + + Args: + obj: The new object to hold a weak reference to. + """ + @classmethod def __class_getitem__(cls, *args: Any, **kwargs: Any) -> GenericAlias: """ diff --git a/stubs/unrealsdk/unreal/_wrapped_array.pyi b/stubs/unrealsdk/unreal/_wrapped_array.pyi index f169228..7a9fcc4 100644 --- a/stubs/unrealsdk/unreal/_wrapped_array.pyi +++ b/stubs/unrealsdk/unreal/_wrapped_array.pyi @@ -9,7 +9,7 @@ from typing import Any, Never, Self, overload from ._uobject_children import UProperty -class WrappedArray[T]: +class WrappedArray[T = Any]: _type: UProperty def __add__(self, values: Sequence[T]) -> list[T]: