Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDExtension: PtrToArg::convert() uses const-reference where possible #80075

Merged
merged 1 commit into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions core/variant/method_ptrcall.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,26 @@
template <class T>
struct PtrToArg {};

#define MAKE_PTRARG(m_type) \
template <> \
struct PtrToArg<m_type> { \
_FORCE_INLINE_ static m_type convert(const void *p_ptr) { \
return *reinterpret_cast<const m_type *>(p_ptr); \
} \
typedef m_type EncodeT; \
_FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \
*((m_type *)p_ptr) = p_val; \
} \
}; \
template <> \
struct PtrToArg<const m_type &> { \
_FORCE_INLINE_ static m_type convert(const void *p_ptr) { \
return *reinterpret_cast<const m_type *>(p_ptr); \
} \
typedef m_type EncodeT; \
_FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \
*((m_type *)p_ptr) = p_val; \
} \
#define MAKE_PTRARG(m_type) \
template <> \
struct PtrToArg<m_type> { \
_FORCE_INLINE_ static const m_type &convert(const void *p_ptr) { \
return *reinterpret_cast<const m_type *>(p_ptr); \
} \
typedef m_type EncodeT; \
_FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \
*((m_type *)p_ptr) = p_val; \
} \
}; \
template <> \
struct PtrToArg<const m_type &> { \
_FORCE_INLINE_ static const m_type &convert(const void *p_ptr) { \
return *reinterpret_cast<const m_type *>(p_ptr); \
} \
typedef m_type EncodeT; \
_FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \
*((m_type *)p_ptr) = p_val; \
} \
}

#define MAKE_PTRARGCONV(m_type, m_conv) \
Expand Down Expand Up @@ -85,7 +85,7 @@ struct PtrToArg {};
#define MAKE_PTRARG_BY_REFERENCE(m_type) \
template <> \
struct PtrToArg<m_type> { \
_FORCE_INLINE_ static m_type convert(const void *p_ptr) { \
_FORCE_INLINE_ static const m_type &convert(const void *p_ptr) { \
return *reinterpret_cast<const m_type *>(p_ptr); \
} \
typedef m_type EncodeT; \
Expand All @@ -95,7 +95,7 @@ struct PtrToArg {};
}; \
template <> \
struct PtrToArg<const m_type &> { \
_FORCE_INLINE_ static m_type convert(const void *p_ptr) { \
_FORCE_INLINE_ static const m_type &convert(const void *p_ptr) { \
return *reinterpret_cast<const m_type *>(p_ptr); \
} \
typedef m_type EncodeT; \
Expand Down
3 changes: 1 addition & 2 deletions core/variant/typed_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ struct PtrToArg<TypedArray<T>> {
template <class T>
struct PtrToArg<const TypedArray<T> &> {
typedef Array EncodeT;
_FORCE_INLINE_ static TypedArray<T>
convert(const void *p_ptr) {
_FORCE_INLINE_ static TypedArray<T> convert(const void *p_ptr) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is purely a whitespace change (should be more readable and still OK for clang-format) 🙂

return TypedArray<T>(*reinterpret_cast<const Array *>(p_ptr));
}
};
Expand Down