Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryAWE committed Feb 1, 2025
1 parent cbf8f95 commit 42ff71c
Show file tree
Hide file tree
Showing 4 changed files with 293 additions and 323 deletions.
3 changes: 2 additions & 1 deletion example/asexec/asexec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ int main(int argc, char* argv[])
if(use_generic)
std::cout << "[asexec] use_generic = true" << std::endl;

using asbind20::fp;
asbind20::global g(engine);
g
.message_callback(&message_callback);
Expand All @@ -104,7 +105,7 @@ int main(int argc, char* argv[])
asbind20::ext::register_std_string(engine, use_generic);
asbind20::ext::register_string_utils(engine, use_generic);
g
.function<&script_print>(asbind20::use_generic, "void print(const string&in str, bool newline=true)");
.function(asbind20::use_generic, "void print(const string&in str, bool newline=true)", fp<&script_print>);

asIScriptModule* m = engine->GetModule("asexec", asGM_ALWAYS_CREATE);
int r = asbind20::ext::load_file(
Expand Down
2 changes: 1 addition & 1 deletion ext/container/test/test_ext_dictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using namespace asbind_test;

TEST_F(asbind_test_suite, ext_dictionary_emplace)
{
asIScriptEngine* engine = get_engine();
asIScriptEngine* engine = get_engine();
asbind20::ext::register_script_dictionary(engine);

asIScriptModule* m = engine->GetModule("dictionary_emplace", asGM_ALWAYS_CREATE);
Expand Down
84 changes: 43 additions & 41 deletions include/asbind20/bind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ namespace wrappers
);
};
}
else // CallConv == asCALL_CDECL_FISRT/LAST
else // CallConv == asCALL_CDECL_OBJFIRST/LAST
{
return +[](Class& obj) -> To
{
Expand Down Expand Up @@ -3359,46 +3359,48 @@ class reference_class : public class_register_helper_base<ForceGeneric>
return *this;
}

#define ASBIND20_REFERENCE_CLASS_BEH(func_name, as_beh, as_decl) \
template <native_function Fn> \
reference_class& func_name(Fn&& fn) requires(!ForceGeneric) \
{ \
constexpr asECallConvTypes conv = \
detail::deduce_beh_callconv<as_beh, Class, std::decay_t<Fn>>(); \
this->behaviour_impl( \
as_beh, \
as_decl, \
fn, \
call_conv<conv> \
); \
return *this; \
} \
reference_class& func_name(asGENFUNC_t gfn) \
{ \
this->behaviour( \
as_beh, \
as_decl, \
gfn, \
call_conv<asCALL_GENERIC> \
); \
return *this; \
} \
template <auto Function> \
reference_class& func_name(use_generic_t, fp_wrapper_t<Function>) \
{ \
constexpr asECallConvTypes conv = \
detail::deduce_beh_callconv<as_beh, Class, std::decay_t<decltype(Function)>>(); \
this->func_name(to_asGENFUNC_t(fp<Function>, call_conv<conv>)); \
return *this; \
} \
template <auto Function> \
reference_class& func_name(fp_wrapper_t<Function>) \
{ \
if constexpr(ForceGeneric) \
this->func_name(use_generic, fp<Function>); \
else \
this->func_name(Function); \
return *this; \
#define ASBIND20_REFERENCE_CLASS_BEH(func_name, as_beh, as_decl) \
template <native_function Fn> \
reference_class& func_name(Fn&& fn) requires(!ForceGeneric) \
{ \
using func_t = std::decay_t<Fn>; \
constexpr asECallConvTypes conv = \
detail::deduce_beh_callconv<AS_NAMESPACE_QUALIFIER as_beh, Class, func_t>(); \
this->behaviour_impl( \
AS_NAMESPACE_QUALIFIER as_beh, \
as_decl, \
fn, \
call_conv<conv> \
); \
return *this; \
} \
reference_class& func_name(asGENFUNC_t gfn) \
{ \
this->behaviour( \
AS_NAMESPACE_QUALIFIER as_beh, \
as_decl, \
gfn, \
call_conv<asCALL_GENERIC> \
); \
return *this; \
} \
template <auto Function> \
reference_class& func_name(use_generic_t, fp_wrapper_t<Function>) \
{ \
using func_t = std::decay_t<decltype(Function)>; \
constexpr asECallConvTypes conv = \
detail::deduce_beh_callconv<AS_NAMESPACE_QUALIFIER as_beh, Class, func_t>(); \
this->func_name(to_asGENFUNC_t(fp<Function>, call_conv<conv>)); \
return *this; \
} \
template <auto Function> \
reference_class& func_name(fp_wrapper_t<Function>) \
{ \
if constexpr(ForceGeneric) \
this->func_name(use_generic, fp<Function>); \
else \
this->func_name(Function); \
return *this; \
}

ASBIND20_REFERENCE_CLASS_BEH(addref, asBEHAVE_ADDREF, "void f()")
Expand Down
Loading

0 comments on commit 42ff71c

Please sign in to comment.