-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0363e8b
commit 74cef5e
Showing
46 changed files
with
4,594 additions
and
6,401 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,20 @@ | ||
#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize)] | ||
pub struct Expression { | ||
pub expression: fastn_grammar::evalexpr::ExprNode, | ||
pub references: fastn_type::Map<fastn_type::PropertyValue>, | ||
pub line_number: usize, | ||
} | ||
|
||
impl Expression { | ||
pub fn new( | ||
expression: fastn_grammar::evalexpr::ExprNode, | ||
references: fastn_type::Map<fastn_type::PropertyValue>, | ||
line_number: usize, | ||
) -> Expression { | ||
Expression { | ||
expression, | ||
references, | ||
line_number, | ||
} | ||
} | ||
} |
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,85 @@ | ||
#[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)] | ||
pub enum ModuleThing { | ||
Component(ComponentModuleThing), | ||
Variable(VariableModuleThing), | ||
Formula(FormulaModuleThing), | ||
} | ||
|
||
impl ModuleThing { | ||
pub fn component( | ||
name: String, | ||
kind: fastn_type::KindData, | ||
arguments: Vec<fastn_type::Argument>, | ||
) -> Self { | ||
ModuleThing::Component(ComponentModuleThing::new(name, kind, arguments)) | ||
} | ||
|
||
pub fn variable(name: String, kind: fastn_type::KindData) -> Self { | ||
ModuleThing::Variable(VariableModuleThing::new(name, kind)) | ||
} | ||
|
||
pub fn function(name: String, kind: fastn_type::KindData) -> Self { | ||
ModuleThing::Formula(FormulaModuleThing::new(name, kind)) | ||
} | ||
|
||
pub fn get_kind(&self) -> fastn_type::KindData { | ||
match self { | ||
fastn_type::ModuleThing::Component(c) => c.kind.clone(), | ||
fastn_type::ModuleThing::Variable(v) => v.kind.clone(), | ||
fastn_type::ModuleThing::Formula(f) => f.kind.clone(), | ||
} | ||
} | ||
|
||
pub fn get_name(&self) -> String { | ||
match self { | ||
fastn_type::ModuleThing::Component(c) => c.name.clone(), | ||
fastn_type::ModuleThing::Variable(v) => v.name.clone(), | ||
fastn_type::ModuleThing::Formula(f) => f.name.clone(), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)] | ||
pub struct ComponentModuleThing { | ||
pub name: String, | ||
pub kind: fastn_type::KindData, | ||
pub arguments: Vec<fastn_type::Argument>, | ||
} | ||
|
||
impl ComponentModuleThing { | ||
pub fn new( | ||
name: String, | ||
kind: fastn_type::KindData, | ||
arguments: Vec<fastn_type::Argument>, | ||
) -> Self { | ||
ComponentModuleThing { | ||
name, | ||
kind, | ||
arguments, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)] | ||
pub struct FormulaModuleThing { | ||
pub name: String, | ||
pub kind: fastn_type::KindData, | ||
} | ||
|
||
impl FormulaModuleThing { | ||
pub fn new(name: String, kind: fastn_type::KindData) -> Self { | ||
FormulaModuleThing { name, kind } | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)] | ||
pub struct VariableModuleThing { | ||
pub name: String, | ||
pub kind: fastn_type::KindData, | ||
} | ||
|
||
impl VariableModuleThing { | ||
pub fn new(name: String, kind: fastn_type::KindData) -> Self { | ||
VariableModuleThing { name, kind } | ||
} | ||
} |
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,122 @@ | ||
#[derive(Debug, Default, Clone, PartialEq, serde::Deserialize, serde::Serialize)] | ||
pub struct Record { | ||
pub name: String, | ||
pub fields: Vec<fastn_type::Field>, | ||
pub line_number: usize, | ||
} | ||
|
||
impl Record { | ||
pub fn new(name: &str, fields: Vec<Field>, line_number: usize) -> Record { | ||
Record { | ||
name: name.to_string(), | ||
fields, | ||
line_number, | ||
} | ||
} | ||
} | ||
#[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)] | ||
pub struct Field { | ||
pub name: String, | ||
pub kind: fastn_type::KindData, | ||
pub mutable: bool, | ||
pub value: Option<fastn_type::PropertyValue>, | ||
pub line_number: usize, | ||
pub access_modifier: AccessModifier, | ||
} | ||
|
||
impl Field { | ||
pub fn new( | ||
name: &str, | ||
kind: fastn_type::KindData, | ||
mutable: bool, | ||
value: Option<fastn_type::PropertyValue>, | ||
line_number: usize, | ||
) -> Field { | ||
Field { | ||
name: name.to_string(), | ||
kind, | ||
mutable, | ||
value, | ||
line_number, | ||
access_modifier: Default::default(), | ||
} | ||
} | ||
|
||
pub fn to_sources(&self) -> Vec<fastn_type::PropertySource> { | ||
let mut sources = vec![fastn_type::PropertySource::Header { | ||
name: self.name.to_string(), | ||
mutable: self.mutable, | ||
}]; | ||
if self.is_caption() { | ||
sources.push(fastn_type::PropertySource::Caption); | ||
} | ||
|
||
if self.is_body() { | ||
sources.push(fastn_type::PropertySource::Body); | ||
} | ||
|
||
if self.is_subsection_ui() { | ||
sources.push(fastn_type::PropertySource::Subsection); | ||
} | ||
|
||
sources | ||
} | ||
|
||
pub fn default(name: &str, kind: fastn_type::KindData) -> fastn_type::Field { | ||
fastn_type::Field { | ||
name: name.to_string(), | ||
kind, | ||
mutable: false, | ||
value: None, | ||
line_number: 0, | ||
access_modifier: Default::default(), | ||
} | ||
} | ||
|
||
pub fn default_with_value( | ||
name: &str, | ||
kind: fastn_type::KindData, | ||
value: fastn_type::PropertyValue, | ||
) -> Field { | ||
Field { | ||
name: name.to_string(), | ||
kind, | ||
mutable: false, | ||
value: Some(value), | ||
line_number: 0, | ||
access_modifier: Default::default(), | ||
} | ||
} | ||
|
||
pub fn is_caption(&self) -> bool { | ||
self.kind.caption | ||
} | ||
|
||
pub fn is_subsection_ui(&self) -> bool { | ||
self.kind.kind.clone().inner_list().is_subsection_ui() | ||
} | ||
|
||
pub fn is_body(&self) -> bool { | ||
self.kind.body | ||
} | ||
|
||
pub fn is_value_required(&self) -> bool { | ||
if self.kind.is_optional() || self.kind.is_list() { | ||
return false; | ||
} | ||
self.value.is_none() | ||
} | ||
} | ||
|
||
#[derive(Debug, Default, PartialEq, Clone, serde::Serialize, serde::Deserialize)] | ||
pub enum AccessModifier { | ||
#[default] | ||
Public, | ||
Private, | ||
} | ||
|
||
impl AccessModifier { | ||
pub fn is_public(&self) -> bool { | ||
matches!(self, AccessModifier::Public) | ||
} | ||
} |
Oops, something went wrong.