-
Notifications
You must be signed in to change notification settings - Fork 32
SC: Implement call wrapper to simplify making sync calls #351
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
Open
linh2931
wants to merge
30
commits into
sync_call_entry_func
Choose a base branch
from
call_wrapper
base: sync_call_entry_func
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
d3cac6a
Implement call wrapper to simplify making sync calls
linh2931 1c9cd27
tests/integration/call_tests.cpp
linh2931 f45496e
Use execution_mode and on_call_not_supported_mode enums instead of bo…
linh2931 7454073
Change parameter names of test function sum
linh2931 67b646c
Add const back to members
linh2931 de050b2
Automatically derive return type of sync call functions in wrapper
linh2931 676233a
Use set_call_return_value from C linkage
linh2931 b358459
Add tests for updating and reading from tables using sync calls and r…
linh2931 755ddc5
Refactor call_warpper
linh2931 797d5aa
Merge branch 'sync_call_entry_func' into call_wrapper
linh2931 e798246
Implement data header and validate it
linh2931 ca6f0a1
Bump llvm submodule to call_wrapper
linh2931 7cab68c
Bump cdt-llvm
linh2931 de416fd
Point antelope-spring-dev to return_status branch temporarily
linh2931 79d466e
Add type checks for arguments
linh2931 4848fb2
Rename execution_mode to access_mode, and on_call_not_supported_mode …
linh2931 8af4875
Return std::optional for support_mode::no_op calls; add comprehensive…
linh2931 58bd4c0
Add toolchain tests for the validation of arguments types and numbers…
linh2931 d7fa594
Bring llvm to latest
linh2931 aea6188
Bump cdt-llvm version to pick up entry point return status constants
linh2931 061efae
Update unknown function and invalid header tests to accommodate new e…
linh2931 aa16dcd
Use enum class instead of plain enum to define enums
linh2931 090c99f
Use std::forward_as_tuple instead of std::make_tuple to avoid making …
linh2931 0acd966
Clarify the comment about why free() is not called
linh2931 91b4b00
Use orig_ret_type explicitly to make sure return value optimization i…
linh2931 d51ad33
Use eosio::name instead of uint64_t for receiver in host function cal…
linh2931 a3ad5f6
Change spring-dev branch back to sync_call from the temporary return_…
linh2931 e1227b7
Add a comment why function name type in call_data_header is uint64_t,…
linh2931 6abb8db
Update cdt-llvm to pickup generate sync call entry point function onl…
linh2931 bc5974f
Add tests for complex parameter passing (a mix of structs and integer)
linh2931 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#pragma once | ||
|
||
#include "../../core/eosio/ignore.hpp" | ||
|
||
namespace eosio { namespace detail { | ||
|
||
/// @cond INTERNAL | ||
|
||
template <typename T> | ||
struct unwrap { typedef T type; }; | ||
|
||
template <typename T> | ||
struct unwrap<ignore<T>> { typedef T type; }; | ||
|
||
template <typename R, typename Act, typename... Args> | ||
auto get_args(R(Act::*p)(Args...)) { | ||
return std::tuple<std::decay_t<typename unwrap<Args>::type>...>{}; | ||
} | ||
|
||
template <typename R, typename Act, typename... Args> | ||
auto get_args_nounwrap(R(Act::*p)(Args...)) { | ||
return std::tuple<std::decay_t<Args>...>{}; | ||
} | ||
|
||
template <auto Function> | ||
using deduced = decltype(get_args(Function)); | ||
|
||
template <auto Function> | ||
using deduced_nounwrap = decltype(get_args_nounwrap(Function)); | ||
|
||
template <typename T> | ||
struct convert { typedef T type; }; | ||
|
||
template <> | ||
struct convert<const char*> { typedef std::string type; }; | ||
|
||
template <> | ||
struct convert<char*> { typedef std::string type; }; | ||
|
||
template <typename T, typename U> | ||
struct is_same { static constexpr bool value = std::is_convertible<T,U>::value; }; | ||
|
||
template <typename U> | ||
struct is_same<bool,U> { static constexpr bool value = std::is_integral<U>::value; }; | ||
|
||
template <typename T> | ||
struct is_same<T,bool> { static constexpr bool value = std::is_integral<T>::value; }; | ||
|
||
template <size_t N, size_t I, auto Arg, auto... Args> | ||
struct get_nth_impl { static constexpr auto value = get_nth_impl<N,I+1,Args...>::value; }; | ||
|
||
template <size_t N, auto Arg, auto... Args> | ||
struct get_nth_impl<N, N, Arg, Args...> { static constexpr auto value = Arg; }; | ||
|
||
template <size_t N, auto... Args> | ||
struct get_nth { static constexpr auto value = get_nth_impl<N,0,Args...>::value; }; | ||
|
||
template <auto Function, size_t I, typename T, typename... Rest> | ||
struct check_types { | ||
static_assert(detail::is_same<typename convert<T>::type, typename convert<typename std::tuple_element<I, deduced<Function>>::type>::type>::value); | ||
using type = check_types<Function, I+1, Rest...>; | ||
static constexpr bool value = true; | ||
}; | ||
template <auto Function, size_t I, typename T> | ||
struct check_types<Function, I, T> { | ||
static_assert(detail::is_same<typename convert<T>::type, typename convert<typename std::tuple_element<I, deduced<Function>>::type>::type>::value); | ||
static constexpr bool value = true; | ||
}; | ||
|
||
template <auto Function, typename... Ts> | ||
constexpr bool type_check() { | ||
static_assert(sizeof...(Ts) == std::tuple_size<deduced<Function>>::value); | ||
if constexpr (sizeof...(Ts) != 0) | ||
return check_types<Function, 0, Ts...>::value; | ||
return true; | ||
} | ||
|
||
/// @endcond | ||
}} // eosio detail |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.