Small fix

This commit is contained in:
fed 2023-11-07 18:05:10 +01:00
parent 7d4e4efc5f
commit c8cdd53912
No known key found for this signature in database
GPG Key ID: 1D2C630F04722996
2 changed files with 8 additions and 8 deletions

View File

@ -137,13 +137,13 @@ namespace gsc
} }
} }
void call_function(const function_t* function) void call_function(const function_t& function)
{ {
const auto args = get_arguments(); const auto args = get_arguments();
try try
{ {
const auto value = function->operator()(args); const auto value = function(args);
return_value(value); return_value(value);
} }
catch (const std::exception& e) catch (const std::exception& e)
@ -152,7 +152,7 @@ namespace gsc
} }
} }
void call_method(const function_t* method, const game::scr_entref_t entref) void call_method(const function_t& method, const game::scr_entref_t entref)
{ {
const auto args = get_arguments(); const auto args = get_arguments();
@ -168,7 +168,7 @@ namespace gsc
args_.push_back(arg); args_.push_back(arg);
} }
const auto value = method->operator()(args_); const auto value = method(args_);
return_value(value); return_value(value);
} }
catch (const std::exception& e) catch (const std::exception& e)

View File

@ -56,8 +56,8 @@ namespace gsc
return wrap_function(std::function(f)); return wrap_function(std::function(f));
} }
void call_function(const function_t* function); void call_function(const function_t& function);
void call_method(const function_t* method, const game::scr_entref_t entref); void call_method(const function_t& method, const game::scr_entref_t entref);
namespace function namespace function
{ {
@ -70,7 +70,7 @@ namespace gsc
const auto lower = utils::string::to_lower(name); const auto lower = utils::string::to_lower(name);
static const auto [iterator, was_inserted] = functions.insert(std::make_pair(lower, function)); static const auto [iterator, was_inserted] = functions.insert(std::make_pair(lower, function));
static const auto function_ptr = &iterator->second; static const auto& function_ptr = iterator->second;
function_wraps[lower] = []() function_wraps[lower] = []()
{ {
@ -102,7 +102,7 @@ namespace gsc
const auto lower = utils::string::to_lower(name); const auto lower = utils::string::to_lower(name);
static const auto [iterator, was_inserted] = functions.insert(std::make_pair(lower, function)); static const auto [iterator, was_inserted] = functions.insert(std::make_pair(lower, function));
static const auto function_ptr = &iterator->second; static const auto& function_ptr = iterator->second;
method_wraps[lower] = [](game::scr_entref_t entref) method_wraps[lower] = [](game::scr_entref_t entref)
{ {