-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update lookup table to handle arbitrary types
It turns out that cloudformation actually allows arbitrary types in Fn::Mappings. Within that, it's also not uniform types as well. This update handles the arbitrary types for non-array-based inputs and will "opt out" for non-array-based complex structures with an `any` mode, leaving it up to the user to resolve that problem in typescript. Also, in order to reuse f64 types, moved WrapperF64 to a primitives folder that spans the gap of parser and ir.
- Loading branch information
Showing
8 changed files
with
96 additions
and
43 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,34 @@ | ||
/** | ||
* Primitives are for things that can be outside the scope of parsing and IR and used heavily across both | ||
* Generally, attempt to keep this section to a minimu | ||
* | ||
*/ | ||
use std::fmt; | ||
|
||
/// WrapperF64 exists because compraisons and outputs into typescripts are annoying with the | ||
/// default f64. Use this whenever referring to a floating point number in CFN standard. | ||
#[derive(Debug, Clone, Copy)] | ||
pub struct WrapperF64 { | ||
num: f64, | ||
} | ||
|
||
impl WrapperF64 { | ||
pub fn new(num: f64) -> WrapperF64 { | ||
WrapperF64 { num } | ||
} | ||
} | ||
|
||
impl PartialEq for WrapperF64 { | ||
fn eq(&self, other: &Self) -> bool { | ||
// It's equal if the diff is very small | ||
(self.num - other.num).abs() < 0.0000001 | ||
} | ||
} | ||
|
||
impl fmt::Display for WrapperF64 { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
write!(f, "{}", self.num) | ||
} | ||
} | ||
|
||
impl Eq for WrapperF64 {} |
This file contains 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 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