Skip to content

Commit 82269e4

Browse files
authored
Merge pull request #63 from apple1417/master
upgrade unrealsdk, fix tps
2 parents b360085 + e570d04 commit 82269e4

File tree

6 files changed

+47
-13
lines changed

6 files changed

+47
-13
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.25)
22

3-
project(pyunrealsdk VERSION 1.5.0)
3+
project(pyunrealsdk VERSION 1.5.1)
44

55
function(_pyunrealsdk_add_base_target_args target_name)
66
target_compile_features(${target_name} PUBLIC cxx_std_20)

changelog.md

+22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
# Changelog
22

3+
## v1.5.1
4+
- Changed type hinting of `unrealsdk.find_all` to return an `Iterable[UObject]`, instead of
5+
`Iterator[UObject]`. This mirrors what was actually happening at runtime.
6+
7+
[fbe877ef](https://github.com/bl-sdk/pyunrealsdk/commit/fbe877ef)
8+
9+
### unrealsdk v1.6.0
10+
For reference, the unrealsdk v1.6.0 changes this includes are:
11+
12+
> - Handled `UStruct` differing in size between BL2 and TPS.
13+
>
14+
> This affects all members on it's subclasses - `UClass::ClassDefaultObject`, `UClass::Interfaces`,
15+
> `UFunction::FunctionFlags`, `UFunction::NumParams`, `UFunction::ParamsSize`,
16+
> `UFunction::ReturnValueOffset`, and `UScriptStruct::StructFlags` have all now changed to methods
17+
> which return a reference.
18+
>
19+
> [72579c18](https://github.com/bl-sdk/unrealsdk/commit/72579c18)
20+
>
21+
> - Fixed all BL3 console output being treated as console commands instead.
22+
>
23+
> [1432408f](https://github.com/bl-sdk/unrealsdk/commit/1432408f)
24+
325
## v1.5.0
426

527
- Deprecated `unrealsdk.hooks.inject_next_call` in favour of a new

src/pyunrealsdk/unreal_bindings/bound_function.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ namespace impl {
130130
PyCallInfo::PyCallInfo(const UFunction* func, const py::args& args, const py::kwargs& kwargs)
131131
// Start by initializing a null struct, to avoid allocations
132132
: params(func, nullptr) {
133-
if (func->NumParams < args.size()) {
133+
if (func->NumParams() < args.size()) {
134134
throw py::type_error(
135135
unrealsdk::fmt::format("{}() takes {} positional args, but {} were given", func->Name,
136-
func->NumParams, args.size()));
136+
func->NumParams(), args.size()));
137137
}
138138

139139
// If we're given exactly one arg, and it's a wrapped struct of our function type, take it as

src/pyunrealsdk/unreal_bindings/uobject_children.cpp

+19-7
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,12 @@ void register_uobject_children(py::module_& mod) {
153153
"Returns:\n"
154154
" True if this class implements the interface, false otherwise.",
155155
"interface"_a)
156-
.def_readwrite("ClassDefaultObject", &UClass::ClassDefaultObject)
156+
.def_property(
157+
"ClassDefaultObject", [](const UClass* self) { return self->ClassDefaultObject(); },
158+
[](UClass* self, UObject* value) { self->ClassDefaultObject() = value; })
157159
.def_property_readonly("Interfaces", [](const UClass* self) {
158160
std::vector<UClass*> interfaces{};
159-
for (const auto& iface : self->Interfaces) {
161+
for (const auto& iface : self->Interfaces()) {
160162
interfaces.push_back(iface.Class);
161163
}
162164
return interfaces;
@@ -179,10 +181,18 @@ void register_uobject_children(py::module_& mod) {
179181
"\n"
180182
"Returns:\n"
181183
" The return param, or None if it doesn't exist.")
182-
.def_readwrite("FunctionFlags", &UFunction::FunctionFlags)
183-
.def_readwrite("NumParams", &UFunction::NumParams)
184-
.def_readwrite("ParamsSize", &UFunction::ParamsSize)
185-
.def_readwrite("ReturnValueOffset", &UFunction::ReturnValueOffset);
184+
.def_property(
185+
"FunctionFlags", [](const UFunction* self) { return self->FunctionFlags(); },
186+
[](UFunction* self, uint32_t value) { self->FunctionFlags() = value; })
187+
.def_property(
188+
"NumParams", [](const UFunction* self) { return self->NumParams(); },
189+
[](UFunction* self, uint8_t value) { self->NumParams() = value; })
190+
.def_property(
191+
"ParamsSize", [](const UFunction* self) { return self->ParamsSize(); },
192+
[](UFunction* self, uint16_t value) { self->ParamsSize() = value; })
193+
.def_property(
194+
"ReturnValueOffset", [](const UFunction* self) { return self->ReturnValueOffset(); },
195+
[](UFunction* self, uint16_t value) { self->ReturnValueOffset() = value; });
186196

187197
PyUEClass<UInt8Property, UProperty>(mod, "UInt8Property");
188198

@@ -204,7 +214,9 @@ void register_uobject_children(py::module_& mod) {
204214
.def_property_readonly("PropertyClass", &UObjectProperty::get_property_class);
205215

206216
PyUEClass<UScriptStruct, UStruct>(mod, "UScriptStruct")
207-
.def_readwrite("StructFlags", &UScriptStruct::StructFlags);
217+
.def_property(
218+
"StructFlags", [](const UScriptStruct* self) { return self->StructFlags(); },
219+
[](UScriptStruct* self, uint32_t value) { self->StructFlags() = value; });
208220

209221
PyUEClass<UStrProperty, UProperty>(mod, "UStrProperty");
210222

stubs/unrealsdk/__init__.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from collections.abc import Iterator, Mapping
3+
from collections.abc import Iterable, Mapping
44
from typing import Any
55

66
from . import commands, hooks, logging, unreal
@@ -50,7 +50,7 @@ def construct_object(
5050
The constructed object.
5151
"""
5252

53-
def find_all(cls: UClass | str, exact: bool = True) -> Iterator[UObject]:
53+
def find_all(cls: UClass | str, exact: bool = True) -> Iterable[UObject]:
5454
"""
5555
Finds all instances of a class.
5656

0 commit comments

Comments
 (0)