-
Notifications
You must be signed in to change notification settings - Fork 0
Object terminology rework #71
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
dd13cdf
Document new terminology that will be used for bauble objects and ext…
Imberflur 03e2d60
Replace uses of old bauble object terminology
Imberflur 54e4384
Rename top_level_trait_dependency methods & field to better reflect t…
Imberflur b2801a0
Clarify what external assets are
Imberflur 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
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 |
|---|---|---|
|
|
@@ -115,7 +115,7 @@ pub struct TypeRegistry { | |
| type_from_rust: HashMap<std::any::TypeId, TypeId>, | ||
| to_be_assigned: HashSet<TypeId>, | ||
|
|
||
| top_level_trait_dependency: TraitId, | ||
| object_trait_dependency: TraitId, | ||
|
|
||
| primitive_types: [TypeId; 5], | ||
| } | ||
|
|
@@ -269,8 +269,8 @@ impl TypeRegistry { | |
|
|
||
| asset_refs: Default::default(), | ||
|
|
||
| // NOTE: Top level values always have to derive from this trait. | ||
| top_level_trait_dependency: Self::any_trait(), | ||
| // NOTE: Top level value in an object must always implement this trait. | ||
| object_trait_dependency: Self::any_trait(), | ||
|
|
||
| to_be_assigned: Default::default(), | ||
|
|
||
|
|
@@ -304,14 +304,14 @@ impl TypeRegistry { | |
| this | ||
| } | ||
|
|
||
| /// If a type implements the required top-level trait. | ||
| pub fn impls_top_level_trait(&self, id: TypeId) -> bool { | ||
| self.key_trait(self.top_level_trait_dependency).contains(id) | ||
| /// If a type implements the required trait for all objects. | ||
| pub fn impls_object_trait(&self, id: TypeId) -> bool { | ||
| self.key_trait(self.object_trait_dependency).contains(id) | ||
| } | ||
|
|
||
| /// The trait that's expected for all top-level bauble assets to have. | ||
| pub fn top_level_trait(&self) -> TraitId { | ||
| self.top_level_trait_dependency | ||
| /// The trait that's expected for all bauble objects to have. | ||
| pub fn object_trait(&self) -> TraitId { | ||
| self.object_trait_dependency | ||
| } | ||
|
|
||
| /// This is present in all `TypeRegistry` | ||
|
|
@@ -574,7 +574,7 @@ impl TypeRegistry { | |
| // If the path is not writable then it cannot be validated | ||
| // as it cannot be written out as Bauble source. | ||
| || !ty.meta.path.is_representable_type() | ||
| || !ty.meta.traits.contains(&self.top_level_trait_dependency) | ||
| || !ty.meta.traits.contains(&self.object_trait_dependency) | ||
| { | ||
| continue; | ||
| } | ||
|
|
@@ -607,8 +607,8 @@ impl TypeRegistry { | |
| // Check that instantiated objects match after being serialized to bauble text and | ||
| // parsed. | ||
| // | ||
| // Changes in sub-asset paths are specifically ignored, only the content of the | ||
| // sub-assets must match. | ||
| // Changes in inline object paths are specifically ignored, only the content of the | ||
| // inline objects must match. | ||
|
|
||
| // dummy top level object | ||
| let mut source = "0 = ()\n".to_string(); | ||
|
|
@@ -772,9 +772,10 @@ impl TypeRegistry { | |
| } | ||
| } | ||
|
|
||
| /// Sets the trait all top-level assets are expected to have. By default this is the any trait. | ||
| pub fn set_top_level_trait_dependency(&mut self, tr: TraitId) { | ||
| self.top_level_trait_dependency = tr; | ||
| /// Sets the trait all types used for objects are expected to have. By default this is the any | ||
| /// trait. | ||
| pub fn set_object_trait_dependency(&mut self, tr: TraitId) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The "top level" here referred to the value at the top of the value tree within a bauble object. I renamed this to avoid confusion with top level objects. |
||
| self.object_trait_dependency = tr; | ||
| } | ||
|
|
||
| /// Registers `ty` as implementing `tr`. | ||
|
|
@@ -1039,8 +1040,9 @@ pub type ValidationFunction = | |
|
|
||
| /// Function that creates a instance of the default value. Stored in [`TypeMeta`]. | ||
| /// | ||
| /// * `&mut AdditionalUnspannedObjects` allows creating sub-assets if the new value needs to | ||
| /// reference sub-assets. | ||
| /// * `&mut AdditionalUnspannedObjects` allows creating objects if the new value needs to | ||
| /// reference additional objects (depending on configuration of the `AdditionalUnspannedObjects` | ||
| /// these can be created as inline objects or as new local objects). | ||
| /// * `&TypeRegistry` allows calling [`TypeRegistry::instantiate`] to create new default instances | ||
| /// of contained types and is used to get type information of contained types. | ||
| /// * `TypeId` is the ID of the type. This allows the function to retrieve information about the | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new documentation in this file would probably benefit from being the focus of review efforts.