File tree Expand file tree Collapse file tree 4 files changed +18
-6
lines changed Expand file tree Collapse file tree 4 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -242,8 +242,11 @@ class WeakRef : public RefCounted {
242
242
template <class T >
243
243
struct PtrToArg <Ref<T>> {
244
244
_FORCE_INLINE_ static Ref<T> convert (const void *p_ptr) {
245
+ if (p_ptr == nullptr ) {
246
+ return Ref<T>();
247
+ }
245
248
// p_ptr points to a RefCounted object
246
- return Ref<T>(const_cast <T *>(reinterpret_cast <const T *>(p_ptr)));
249
+ return Ref<T>(const_cast <T *>(* reinterpret_cast <T * const *>(p_ptr)));
247
250
}
248
251
249
252
typedef Ref<T> EncodeT;
@@ -259,8 +262,11 @@ struct PtrToArg<const Ref<T> &> {
259
262
typedef Ref<T> EncodeT;
260
263
261
264
_FORCE_INLINE_ static Ref<T> convert (const void *p_ptr) {
265
+ if (p_ptr == nullptr ) {
266
+ return Ref<T>();
267
+ }
262
268
// p_ptr points to a RefCounted object
263
- return Ref<T>(( T *)p_ptr);
269
+ return Ref<T>(*(( T *const * )p_ptr) );
264
270
}
265
271
};
266
272
Original file line number Diff line number Diff line change @@ -159,7 +159,10 @@ MAKE_PTRARG_BY_REFERENCE(Variant);
159
159
template <class T >
160
160
struct PtrToArg <T *> {
161
161
_FORCE_INLINE_ static T *convert (const void *p_ptr) {
162
- return const_cast <T *>(reinterpret_cast <const T *>(p_ptr));
162
+ if (p_ptr == nullptr ) {
163
+ return nullptr ;
164
+ }
165
+ return const_cast <T *>(*reinterpret_cast <T *const *>(p_ptr));
163
166
}
164
167
typedef Object *EncodeT;
165
168
_FORCE_INLINE_ static void encode (T *p_var, void *p_ptr) {
@@ -170,7 +173,10 @@ struct PtrToArg<T *> {
170
173
template <class T >
171
174
struct PtrToArg <const T *> {
172
175
_FORCE_INLINE_ static const T *convert (const void *p_ptr) {
173
- return reinterpret_cast <const T *>(p_ptr);
176
+ if (p_ptr == nullptr ) {
177
+ return nullptr ;
178
+ }
179
+ return *reinterpret_cast <T *const *>(p_ptr);
174
180
}
175
181
typedef const Object *EncodeT;
176
182
_FORCE_INLINE_ static void encode (T *p_var, void *p_ptr) {
Original file line number Diff line number Diff line change @@ -502,7 +502,7 @@ class VariantInternal {
502
502
case Variant::PACKED_COLOR_ARRAY:
503
503
return get_color_array (v);
504
504
case Variant::OBJECT:
505
- return v-> _get_obj (). obj ;
505
+ return get_object (v) ;
506
506
case Variant::VARIANT_MAX:
507
507
ERR_FAIL_V (nullptr );
508
508
}
Original file line number Diff line number Diff line change @@ -2889,7 +2889,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
2889
2889
2890
2890
itype.cs_out = " %5return (%2)%0(%1);" ;
2891
2891
2892
- itype.c_arg_in = " (void*) %s" ;
2892
+ itype.c_arg_in = " & %s" ;
2893
2893
itype.c_type = " IntPtr" ;
2894
2894
itype.c_type_in = itype.c_type ;
2895
2895
itype.c_type_out = " GodotObject" ;
You can’t perform that action at this time.
0 commit comments