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

feat: add struct as marshallable field type #87

Merged
merged 1 commit into from
Jan 29, 2020

Conversation

Wodann
Copy link
Collaborator

@Wodann Wodann commented Jan 24, 2020

Depends on PR #84.

Allows getting, setting and replacing of structs in another struct:

let foo: Struct = some_foo_constructor();
let bar = foo.get<Struct>("bar");
let bar2 = some_bar_constructor();
let old_bar = foo.replace("bar", bar2);
foo.set("bar", old_bar);

@Wodann Wodann requested a review from baszalmstra January 24, 2020 11:04
@Wodann Wodann self-assigned this Jan 24, 2020
@Wodann Wodann force-pushed the feature/marshallable-struct branch 2 times, most recently from 409328c to a41ff8c Compare January 26, 2020 10:56
@Wodann
Copy link
Collaborator Author

Wodann commented Jan 26, 2020

@Wodann Wodann force-pushed the feature/marshallable-struct branch from a41ff8c to c0e5e44 Compare January 26, 2020 17:45
@codecov
Copy link

codecov bot commented Jan 26, 2020

Codecov Report

Merging #87 into master will increase coverage by 0.51%.
The diff coverage is 88.37%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #87      +/-   ##
==========================================
+ Coverage    74.8%   75.32%   +0.51%     
==========================================
  Files         121      121              
  Lines        9599     9613      +14     
==========================================
+ Hits         7181     7241      +60     
+ Misses       2418     2372      -46
Impacted Files Coverage Δ
crates/mun_runtime/src/reflection.rs 41.5% <100%> (+20.99%) ⬆️
crates/mun_runtime/src/test.rs 96.9% <100%> (+0.25%) ⬆️
crates/mun_runtime/src/struct.rs 80.59% <100%> (+29.46%) ⬆️
crates/mun_abi/src/autogen_impl.rs 94.57% <45.45%> (-1.11%) ⬇️
crates/mun_runtime/src/macros.rs 73.68% <73.33%> (+30.13%) ⬆️
crates/mun_codegen/src/ir/dispatch_table.rs 92.36% <0%> (+1.38%) ⬆️

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 8596546...ded289b. Read the comment docs.

Copy link
Collaborator

@baszalmstra baszalmstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nicely implemented!

@@ -146,6 +146,22 @@ impl StructInfo {
unsafe { slice::from_raw_parts(self.field_sizes, self.num_fields as usize) }
}
}

/// Returns the index of the field matching the specified `field_name`.
pub fn find_field_index(struct_info: &StructInfo, field_name: &str) -> Result<usize, String> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think at some point we should figure out a way to do some sort of hash lookup. Because this might become slow.

@Wodann Wodann force-pushed the feature/marshallable-struct branch from c0e5e44 to ded289b Compare January 29, 2020 20:53
@Wodann Wodann merged commit bf506d2 into mun-lang:master Jan 29, 2020
@Wodann Wodann changed the title Adds structs as a marshallable type feat: add struct as marshallable field type Jan 31, 2020
@Wodann Wodann deleted the feature/marshallable-struct branch March 25, 2020 11:25
@Wodann Wodann added this to the Mun v0.2 milestone May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants