MCPcopy Create free account
hub / github.com/covscript/covscript / invoke

Function invoke

include/covscript/core/core.hpp:462–475  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

460// Invoke
461 template <typename... ArgsT>
462 static var invoke(const var &func, ArgsT &&..._args)
463 {
464 if (func.is_type_of<callable>()) {
465 vector args{std::forward<ArgsT>(_args)...};
466 return func.const_val<callable>().call(args);
467 }
468 else if (func.is_type_of<object_method>()) {
469 const auto &om = func.const_val<object_method>();
470 vector args{om.object, std::forward<ArgsT>(_args)...};
471 return om.callable.const_val<callable>().call(args);
472 }
473 else
474 throw runtime_error("Invoke non-callable object.");
475 }
476
477// Type and struct
478 struct pointer final {

Callers 7

sortFunction · 0.85
reflection.cppFile · 0.85
operator()Method · 0.85
structureMethod · 0.85
~structureMethod · 0.85
operator==Method · 0.85
structure>Method · 0.85

Calls 2

runtime_errorClass · 0.85
callMethod · 0.45

Tested by

no test coverage detected