-
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
Showing
6 changed files
with
348 additions
and
86 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
241 changes: 241 additions & 0 deletions
241
module/core/former/tests/inc/former_tests/a_primitives.rs
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,241 @@ | ||
#[ allow( unused_imports ) ] | ||
use super::*; | ||
|
||
#[ derive( Debug, PartialEq, the_module::Former ) ] | ||
pub struct Struct1 | ||
{ | ||
pub int_1 : i32, | ||
string_1 : String, | ||
int_optional_1 : core::option::Option< i32 >, | ||
string_optional_1 : Option< String >, | ||
} | ||
|
||
// | ||
|
||
// // generated by former | ||
// impl Struct1 | ||
// { | ||
// pub fn former() -> Struct1Former< (), the_module::ReturnStorage > | ||
// { | ||
// Struct1Former::new() | ||
// } | ||
// } | ||
// | ||
// // | ||
// | ||
// // generated by former | ||
// pub struct Struct1FormerStorage | ||
// { | ||
// pub int_1 : core::option::Option< i32 >, | ||
// pub string_1 : core::option::Option< String >, | ||
// pub int_optional_1 : core::option::Option< i32 >, | ||
// pub string_optional_1 : core::option::Option< String >, | ||
// } | ||
// | ||
// impl Default for Struct1FormerStorage | ||
// { | ||
// | ||
// #[ inline( always ) ] | ||
// fn default() -> Self | ||
// { | ||
// Self | ||
// { | ||
// int_1 : core::option::Option::None, | ||
// string_1 : core::option::Option::None, | ||
// int_optional_1 : core::option::Option::None, | ||
// string_optional_1 : core::option::Option::None, | ||
// } | ||
// } | ||
// | ||
// } | ||
// | ||
// #[ derive( Debug ) ] | ||
// pub struct Struct1FormerDescriptor; | ||
// | ||
// impl Struct1FormerDescriptor | ||
// { | ||
// pub fn new() -> Self | ||
// { | ||
// Self | ||
// } | ||
// } | ||
// | ||
// impl former::FormerDescriptor | ||
// for Struct1FormerDescriptor | ||
// { | ||
// type Storage = Struct1FormerStorage; | ||
// type Formed = Struct1; | ||
// } | ||
// | ||
// impl former::Storage | ||
// for Struct1FormerStorage | ||
// { | ||
// type Descriptor = Struct1FormerDescriptor; | ||
// } | ||
// | ||
// impl former::StoragePerform | ||
// for Struct1FormerStorage | ||
// { | ||
// | ||
// fn preform( mut self ) -> < < Self as former::Storage >::Descriptor as former::FormerDescriptor >::Formed | ||
// { | ||
// | ||
// let int_1 = if self.int_1.is_some() | ||
// { | ||
// self.int_1.take().unwrap() | ||
// } | ||
// else | ||
// { | ||
// let val : i32 = Default::default(); | ||
// val | ||
// }; | ||
// | ||
// let string_1 = if self.string_1.is_some() | ||
// { | ||
// self.string_1.take().unwrap() | ||
// } | ||
// else | ||
// { | ||
// let val : String = Default::default(); | ||
// val | ||
// }; | ||
// | ||
// let int_optional_1 = if self.int_optional_1.is_some() | ||
// { | ||
// Some( self.int_optional_1.take().unwrap() ) | ||
// } | ||
// else | ||
// { | ||
// None | ||
// }; | ||
// | ||
// let string_optional_1 = if self.string_optional_1.is_some() | ||
// { | ||
// Some( self.string_optional_1.take().unwrap() ) | ||
// } | ||
// else | ||
// { | ||
// None | ||
// }; | ||
// | ||
// // xxx : Rust failt to use parameter here | ||
// // < < Self as former::Storage >::Descriptor as former::FormerDescriptor >::Formed | ||
// Struct1 | ||
// { | ||
// int_1, | ||
// string_1, | ||
// int_optional_1, | ||
// string_optional_1, | ||
// } | ||
// | ||
// } | ||
// | ||
// } | ||
// | ||
// // | ||
// | ||
// pub struct Struct1Former | ||
// < | ||
// FormerContext = Struct1, | ||
// FormerEnd = the_module::ReturnStorage, | ||
// > | ||
// where | ||
// FormerEnd : the_module::FormingEnd< Struct1FormerDescriptor, FormerContext >, | ||
// { | ||
// storage : Struct1FormerStorage, | ||
// context : core::option::Option< FormerContext >, | ||
// on_end : core::option::Option< FormerEnd >, | ||
// } | ||
// | ||
// impl< FormerContext, FormerEnd > Struct1Former< FormerContext, FormerEnd > | ||
// where | ||
// FormerEnd: the_module::FormingEnd< Struct1FormerDescriptor, FormerContext >, | ||
// { | ||
// | ||
// fn preform( self ) -> < Struct1FormerDescriptor as former::FormerDescriptor >::Formed | ||
// { | ||
// former::StoragePerform::preform( self.storage ) | ||
// } | ||
// | ||
// #[ inline( always ) ] | ||
// pub fn perform(self) -> < Struct1FormerDescriptor as former::FormerDescriptor >::Formed | ||
// { | ||
// let result = self.form(); | ||
// return result; | ||
// } | ||
// | ||
// #[ inline( always ) ] | ||
// pub fn begin | ||
// ( | ||
// mut storage : core::option::Option< < Struct1FormerDescriptor as former::FormerDescriptor >::Storage >, | ||
// // xxx : cover by test existance of these 3 parameters in the function | ||
// context : core::option::Option< FormerContext >, | ||
// on_end : FormerEnd, | ||
// ) -> Self | ||
// { | ||
// if storage.is_none() | ||
// { | ||
// storage = Some( core::default::Default::default() ); | ||
// } | ||
// Self | ||
// { | ||
// storage : storage.unwrap(), | ||
// context : context, | ||
// on_end : ::core::option::Option::Some( on_end ), | ||
// } | ||
// } | ||
// | ||
// #[ inline( always ) ] | ||
// pub fn end( mut self ) -> < Struct1FormerDescriptor as former::FormerDescriptor >::Formed | ||
// { | ||
// let on_end = self.on_end.take().unwrap(); | ||
// let context = self.context.take(); | ||
// on_end.call( self.storage, context ) | ||
// } | ||
// | ||
// #[ inline( always ) ] | ||
// pub fn form( self ) -> < Struct1FormerDescriptor as former::FormerDescriptor >::Formed | ||
// { | ||
// self.end() | ||
// } | ||
// | ||
// pub fn int_1< Src >( mut self, src : Src ) -> Self | ||
// where Src : core::convert::Into< i32 >, | ||
// { | ||
// debug_assert!( self.storage.int_1.is_none() ); | ||
// self.storage.int_1 = Some( src.into() ); | ||
// self | ||
// } | ||
// | ||
// pub fn string_1< Src >( mut self, src : Src ) -> Self | ||
// where Src : core::convert::Into< String >, | ||
// { | ||
// debug_assert!( self.storage.string_1.is_none() ); | ||
// self.storage.string_1 = Some( src.into() ); | ||
// self | ||
// } | ||
// | ||
// pub fn string_optional_1< Src >( mut self, src : Src ) -> Self | ||
// where Src : core::convert::Into< String > | ||
// { | ||
// debug_assert!( self.storage.string_optional_1.is_none() ); | ||
// self.storage.string_optional_1 = Some( src.into() ); | ||
// self | ||
// } | ||
// | ||
// } | ||
// | ||
// impl Struct1Former< (), the_module::ReturnStorage > | ||
// { | ||
// | ||
// #[ inline( always ) ] | ||
// pub fn new() -> Struct1Former< (), the_module::ReturnStorage > | ||
// { | ||
// Struct1Former::< (), the_module::ReturnStorage >::begin( None, None, the_module::ReturnStorage ) | ||
// } | ||
// | ||
// } | ||
|
||
// | ||
|
||
// include!( "./only_test/primitives.rs" ); |
18 changes: 18 additions & 0 deletions
18
module/core/former/tests/inc/former_tests/a_primitives_expanded.rs
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,18 @@ | ||
#[ allow( unused_imports ) ] | ||
use super::*; | ||
|
||
#[ derive( Debug, PartialEq, the_module::Former ) ] | ||
#[ debug ] | ||
pub struct Struct1 | ||
{ | ||
pub int_1 : i32, | ||
string_1 : String, | ||
int_optional_1 : core::option::Option< i32 >, | ||
string_optional_1 : Option< String >, | ||
} | ||
|
||
// | ||
|
||
// | ||
|
||
// include!( "./only_test/primitives.rs" ); |
Oops, something went wrong.