Skip to content

Commit

Permalink
former : experimenting
Browse files Browse the repository at this point in the history
  • Loading branch information
Wandalen committed Mar 23, 2024
1 parent 4094317 commit 058554b
Show file tree
Hide file tree
Showing 6 changed files with 348 additions and 86 deletions.
3 changes: 2 additions & 1 deletion module/core/former/src/vector3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ where
storage : core::option::Option< Descriptor::Storage >,
context : core::option::Option< Context >,
on_end : End,
) -> Self
)
-> Self
{
Self::begin( storage, context, on_end )
}
Expand Down
241 changes: 241 additions & 0 deletions module/core/former/tests/inc/former_tests/a_primitives.rs
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 module/core/former/tests/inc/former_tests/a_primitives_expanded.rs
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" );
Loading

0 comments on commit 058554b

Please sign in to comment.