Skip to content
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

refactor: simplified invoke syntax #347

Merged
merged 2 commits into from
Sep 3, 2021

Conversation

baszalmstra
Copy link
Collaborator

Refactors the invoke syntax of a runtime to be simpler and with less magic.

Previously calling a mun function looked like:

let runtime_ref = runtime.borrow();
let arg: i64 = invoke_fn!(runtime_ref, "arg", a, b).unwrap();

WIth this MR this becomes:

let runtime_ref = runtime.borrow();
let arg: i64 = runtime_ref.invoke("arg", (a,b)).unwrap();

Arguments are passed in as a single tuple. No more macros. A single entry point to call functions which is also properly suggested by language servers and the like. And the code became much simpler. The only downside is that calling a function with a single argument requires a bit of strange rust syntax: (a,). Note the comma. Without it, the parentheses are seen as an expression instead of a tuple declaration.

@baszalmstra baszalmstra added the type: refactor Refactor existing code label Aug 23, 2021
@baszalmstra baszalmstra self-assigned this Aug 23, 2021
@codecov
Copy link

codecov bot commented Aug 23, 2021

Codecov Report

Merging #347 (80610c0) into main (5953a7b) will decrease coverage by 0.10%.
The diff coverage is 71.42%.

❗ Current head 80610c0 differs from pull request most recent head dd358f1. Consider uploading reports for the commit dd358f1 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main     #347      +/-   ##
==========================================
- Coverage   80.21%   80.11%   -0.11%     
==========================================
  Files         262      261       -1     
  Lines       15667    15703      +36     
==========================================
+ Hits        12567    12580      +13     
- Misses       3100     3123      +23     
Impacted Files Coverage Δ
crates/mun/src/ops/start.rs 0.00% <0.00%> (ø)
crates/mun_runtime/src/adt.rs 76.00% <ø> (ø)
crates/mun_runtime/src/lib.rs 66.82% <58.33%> (-4.52%) ⬇️
crates/mun/tests/integration.rs 100.00% <100.00%> (ø)
crates/mun_runtime/tests/marshalling.rs 98.27% <100.00%> (+0.06%) ⬆️
crates/mun_runtime/tests/memory.rs 100.00% <100.00%> (ø)
crates/mun_runtime/tests/runtime.rs 100.00% <100.00%> (ø)
crates/mun_skeptic/src/runtime.rs 88.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5953a7b...dd358f1. Read the comment docs.

crates/mun_runtime/src/lib.rs Outdated Show resolved Hide resolved
crates/mun_runtime/src/lib.rs Outdated Show resolved Hide resolved
@Wodann Wodann merged commit 94ffbb2 into mun-lang:main Sep 3, 2021
@Wodann Wodann added this to the Mun v0.4.0 milestone Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: refactor Refactor existing code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants