Skip to content

Commit d68c895

Browse files
authored
Merge pull request #68 from apple1417/master
add `_get_address` method to wrapped struct, array, and delegates
2 parents be69be6 + 9fa2d30 commit d68c895

9 files changed

+53
-0
lines changed

changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111

1212
[10bdc130](https://github.com/bl-sdk/pyunrealsdk/commit/10bdc130)
1313

14+
- Added a `_get_address` method to `WrappedArray`, `WrappedMulticastDelegate`, and `WrappedStruct`.
15+
16+
[1b3e9686](https://github.com/bl-sdk/pyunrealsdk/commit/1b3e9686)
17+
1418
## v1.5.2
1519

1620
### unrealsdk v1.6.1

src/pyunrealsdk/unreal_bindings/wrapped_array.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ void register_wrapped_array(py::module_& mod) {
189189
" key: A one-arg function used to extract a comparison key.\n"
190190
" reverse: If true, the list is sorted as if each comparison were reversed.",
191191
py::kw_only{}, "key"_a = py::none{}, "reverse"_a = false)
192+
.def("_get_address", &impl::array_py_getaddress,
193+
"Gets the address of this array, for debugging.\n"
194+
"\n"
195+
"Returns:\n"
196+
" This array's address.")
192197
.def_readwrite("_type", &WrappedArray::type);
193198

194199
// Create as a class method, see pybind11#1693

src/pyunrealsdk/unreal_bindings/wrapped_array.h

+2
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ void array_py_remove(WrappedArray& self, const py::object& value);
207207
void array_py_reverse(WrappedArray& self);
208208
// sort
209209
void array_py_sort(WrappedArray& self, const py::object& key, bool reverse);
210+
// _get_address
211+
uintptr_t array_py_getaddress(const WrappedArray& self);
210212

211213
} // namespace impl
212214

src/pyunrealsdk/unreal_bindings/wrapped_array_methods.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ void array_py_sort(WrappedArray& self, const py::object& key, bool reverse) {
182182
});
183183
}
184184

185+
uintptr_t array_py_getaddress(const WrappedArray& self) {
186+
return reinterpret_cast<uintptr_t>(self.base.get());
187+
}
188+
185189
} // namespace pyunrealsdk::unreal::impl
186190

187191
#endif

src/pyunrealsdk/unreal_bindings/wrapped_multicast_delegate.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,15 @@ void register_wrapped_multicast_delegate(py::module_& mod) {
262262
"Args:\n"
263263
" value: The function to remove.",
264264
"value"_a)
265+
.def(
266+
"_get_address",
267+
[](const WrappedMulticastDelegate& self) {
268+
return reinterpret_cast<uintptr_t>(self.base.get());
269+
},
270+
"Gets the address of this delegate, for debugging.\n"
271+
"\n"
272+
"Returns:\n"
273+
" This delegate's address.")
265274
.def_readwrite("_signature", &WrappedMulticastDelegate::signature);
266275
}
267276

src/pyunrealsdk/unreal_bindings/wrapped_struct.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,13 @@ void register_wrapped_struct(py::module_& mod) {
228228
"Returns:\n"
229229
" A new, python-owned copy of this struct.",
230230
"memo"_a)
231+
.def(
232+
"_get_address",
233+
[](const WrappedStruct& self) { return reinterpret_cast<uintptr_t>(self.base.get()); },
234+
"Gets the address of this struct, for debugging.\n"
235+
"\n"
236+
"Returns:\n"
237+
" This struct's address.")
231238
.def_readwrite("_type", &WrappedStruct::type);
232239
}
233240

stubs/unrealsdk/unreal/_wrapped_array.pyi

+7
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ class WrappedArray[T]:
162162
range: The range to set.
163163
value: The values to set.
164164
"""
165+
def _get_address(self) -> int:
166+
"""
167+
Gets the address of this array, for debugging.
168+
169+
Returns:
170+
This array's address.
171+
"""
165172
def append(self, value: T) -> None:
166173
"""
167174
Appends a value to the end of the array.

stubs/unrealsdk/unreal/_wrapped_multicast_delegate.pyi

+8
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ class WrappedMulticastDelegate:
5252
The string representation.
5353
"""
5454

55+
def _get_address(self) -> int:
56+
"""
57+
Gets the address of this delegate, for debugging.
58+
59+
Returns:
60+
This delegate's address.
61+
"""
62+
5563
def add(self, value: BoundFunction) -> None:
5664
"""
5765
Binds a new function to this delegate.

stubs/unrealsdk/unreal/_wrapped_struct.pyi

+7
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ class WrappedStruct:
7272
name: The name of the field to set.
7373
value: The value to write.
7474
"""
75+
def _get_address(self) -> int:
76+
"""
77+
Gets the address of this struct, for debugging.
78+
79+
Returns:
80+
This struct's address.
81+
"""
7582
def _get_field(self, field: UField) -> Any:
7683
"""
7784
Reads an unreal field off of the struct.

0 commit comments

Comments
 (0)