-
Notifications
You must be signed in to change notification settings - Fork 36
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
Container tooling #885
base: main
Are you sure you want to change the base?
Container tooling #885
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #885 +/- ##
==========================================
- Coverage 77.85% 77.62% -0.24%
==========================================
Files 136 136
Lines 34670 35038 +368
Branches 34670 35038 +368
==========================================
+ Hits 26994 27199 +205
- Misses 5680 5789 +109
- Partials 1996 2050 +54 ☔ View full report in Codecov by Sentry. |
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.
🗺️ PR Tour 🧭
@@ -1047,6 +1048,15 @@ impl<'top> LazyRawValue<'top, AnyEncoding> for LazyRawAnyValue<'top> { | |||
} | |||
} | |||
|
|||
fn is_delimited(&self) -> bool { |
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.
🪧 Each encoded value kind can now report whether it is delimited. For text 1.0 and binary 1.0, this method just returns false
.
fn delimited_end_span(&self) -> Span<'top> { | ||
let bytes = self.span().bytes(); | ||
let end = bytes.len(); | ||
let range = if !self.is_delimited() { | ||
end..end | ||
} else { | ||
debug_assert!(bytes[end - 1] == 0xF0); | ||
end - 1..end | ||
}; | ||
let end_bytes = bytes.get(range).unwrap(); | ||
Span::with_offset(self.range().end - end_bytes.len(), end_bytes) | ||
} |
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.
🪧 For scalars and length-prefixed containers, this returns an empty slice.
EExp(eexp) => FieldExpr::EExp(eexp.resolve(context)?), | ||
}; | ||
Ok(field) | ||
} |
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.
🪧 A convenience method pattern used widely throughout the crate; resolve
turns a raw value (or in this case, field) into its higher-level, context-ful equivalent.
/// Creates an iterator that converts each raw struct field into an `UnexpandedField`, a | ||
/// Creates an iterator that converts each raw struct field into an `FieldExpr`, a | ||
/// common representation for both raw fields and template fields that is used in the | ||
/// expansion process. | ||
fn unexpanded_fields( | ||
fn field_exprs( |
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.
🪧 UnexpandedField
was a clunky name, hopefully this is better. The new relationship between LazyExpandedField
and FieldExpr
mirrors the existing relationship between LazyExpandedValue
and ValueExpr
.
if input.len() < flex_int_len { | ||
if input.len() <= flex_int_len { |
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.
🪧 This bug surfaced while I was working on an example file from @jobarr-amzn. This fixed it.
variable: Option<TemplateVariableReference<'top>>, | ||
pub(crate) variable: Option<TemplateVariableReference<'top>>, |
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.
🪧 Macros now remember the variable (if any) that produced them, allowing them in turn to tag the values they produce.
/// Like an [`ExpandedListIterator`], but will yield macro invocations before also yielding | ||
/// that macro's expansion. | ||
#[derive(Debug)] | ||
pub struct ListValueExprIterator<'top, D: Decoder> { |
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.
🪧 This section introduces iterators that return both the expressions and the values they expand to.
impl<'top, D: Decoder> Iterator for FieldExprIterator<'top, D> { | ||
type Item = IonResult<FieldExpr<'top, D>>; | ||
|
||
fn next(&mut self) -> Option<Self::Item> { |
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.
🪧 This is pretty close to the regular struct iterator, expect that any time we would change states and keep reading, we now return the expression that caused us to change states. The following call to next()
will resume reading.
This PR adds lots of new tooling methods and bookkeeping:
UnexpandedField
toFieldExpr
, which is much clearer.Span
accessor for the delimitedEND
byte.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.