diff --git a/rox_compiler/src/common.rs b/rox_compiler/src/common.rs index 9828830..970aec9 100644 --- a/rox_compiler/src/common.rs +++ b/rox_compiler/src/common.rs @@ -1,3 +1,33 @@ +#[derive(Clone,Copy,Debug)] +pub enum Style{ + Rox, + Rojo, + RoxRojo, +} + +#[derive(Default)] +pub(crate) struct PropertiesOverride{ + pub name:Option, + pub class:Option, +} +impl PropertiesOverride{ + pub fn is_some(&self)->bool{ + self.name.is_some() + ||self.class.is_some() + } +} +impl std::fmt::Display for PropertiesOverride{ + fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{ + if let Some(name)=self.name.as_deref(){ + writeln!(f,"--!Properties.Name = \"{}\"",name)?; + } + if let Some(class)=self.class.as_deref(){ + writeln!(f,"--!Properties.ClassName = \"{}\"",class)?; + } + Ok(()) + } +} + pub(crate) fn sanitize<'a>(s:&'a str)->std::borrow::Cow<'a,str>{ lazy_regex::regex!(r"[^A-z0-9.-]").replace_all(s,"_") } diff --git a/rox_compiler/src/compile.rs b/rox_compiler/src/compile.rs index 55afcee..7fccd1a 100644 --- a/rox_compiler/src/compile.rs +++ b/rox_compiler/src/compile.rs @@ -400,7 +400,7 @@ pub struct CompileConfig{ style:Option