Skip to content

Commit f8f9577

Browse files
committed
Cleanup & update changelog
1 parent 21afc52 commit f8f9577

File tree

2 files changed

+9
-65
lines changed

2 files changed

+9
-65
lines changed

doc/changelog.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ Changelog since the version 1.5.0.
66
1.8.0
77
-----
88

9+
Bug fix
10+
~~~~~~~
11+
12+
- Fix error caused by generated copy constructor when registering a C array (``type[size]``) as value type.
13+
914
1.7.1
1015
-----
1116

include/asbind20/bind.hpp

Lines changed: 4 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -517,71 +517,10 @@ namespace detail
517517
};
518518

519519
template <typename Class, typename Arg>
520-
class copy_constructor : public constructor_base<Class>
521-
{
522-
using my_base = constructor_base<Class>;
523-
524-
public:
525-
using native_function_type =
526-
void (*)(Arg, void*);
527-
528-
template <AS_NAMESPACE_QUALIFIER asECallConvTypes CallConv>
529-
requires(CallConv == AS_NAMESPACE_QUALIFIER asCALL_GENERIC ||
530-
CallConv == AS_NAMESPACE_QUALIFIER asCALL_CDECL_OBJLAST)
531-
using wrapper_type = std::conditional_t<
532-
CallConv == AS_NAMESPACE_QUALIFIER asCALL_GENERIC,
533-
AS_NAMESPACE_QUALIFIER asGENFUNC_t,
534-
native_function_type>;
535-
536-
template <AS_NAMESPACE_QUALIFIER asECallConvTypes CallConv>
537-
static constexpr auto generate(call_conv_t<CallConv>) noexcept -> wrapper_type<CallConv>
538-
{
539-
if constexpr(CallConv == AS_NAMESPACE_QUALIFIER asCALL_GENERIC)
540-
{
541-
// if constexpr(Template)
542-
// {
543-
// return +[](AS_NAMESPACE_QUALIFIER asIScriptGeneric* gen) -> void
544-
// {
545-
// void* mem = gen->GetObject();
546-
// new(mem) Class(
547-
// *(AS_NAMESPACE_QUALIFIER asITypeInfo**)gen->GetAddressOfArg(0),
548-
// get_generic_arg<Arg>(
549-
// gen, 1
550-
// )
551-
// );
552-
553-
// my_base::destroy_if_ex(static_cast<Class*>(mem));
554-
// };
555-
// }
556-
// else
557-
{
558-
return +[](AS_NAMESPACE_QUALIFIER asIScriptGeneric* gen) -> void
559-
{
560-
void* mem = gen->GetObject();
561-
new(mem) Class(
562-
get_generic_arg<Arg>(
563-
gen, 0
564-
)
565-
);
566-
567-
my_base::destroy_if_ex(static_cast<Class*>(mem));
568-
};
569-
}
570-
}
571-
else // CallConv == asCALL_CDECL_OBJLAST
572-
{
573-
return +[](Arg arg, void* mem) -> void
574-
{
575-
new(mem) Class(std::forward<Arg>(arg));
576-
577-
my_base::destroy_if_ex(static_cast<Class*>(mem));
578-
};
579-
}
580-
}
581-
};
520+
class arr_copy_constructor;
582521

583522
template <typename ElemType, std::size_t Size, typename Arg>
584-
class copy_constructor<ElemType[Size], Arg> : public constructor_base<ElemType[Size]>
523+
class arr_copy_constructor<ElemType[Size], Arg> : public constructor_base<ElemType[Size]>
585524
{
586525
using my_base = constructor_base<ElemType[Size]>;
587526

@@ -4810,7 +4749,7 @@ class basic_value_class final : public class_register_helper_base<ForceGeneric>
48104749
{
48114750
if constexpr(std::is_array_v<Class>)
48124751
{
4813-
detail::copy_constructor<Class, const Class&> wrapper;
4752+
detail::arr_copy_constructor<Class, const Class&> wrapper;
48144753
this->behaviour_impl(
48154754
AS_NAMESPACE_QUALIFIER asBEHAVE_CONSTRUCT,
48164755
decl_copy_ctor().c_str(),
@@ -4839,7 +4778,7 @@ class basic_value_class final : public class_register_helper_base<ForceGeneric>
48394778
{
48404779
if constexpr(std::is_array_v<Class>)
48414780
{
4842-
detail::copy_constructor<Class, const Class&> wrapper;
4781+
detail::arr_copy_constructor<Class, const Class&> wrapper;
48434782
this->behaviour_impl(
48444783
AS_NAMESPACE_QUALIFIER asBEHAVE_CONSTRUCT,
48454784
decl_copy_ctor().c_str(),

0 commit comments

Comments
 (0)