Skip to content

Commit

Permalink
former : experimenting
Browse files Browse the repository at this point in the history
  • Loading branch information
Wandalen committed Apr 23, 2024
1 parent 52e6963 commit 5a5a615
Showing 1 changed file with 103 additions and 22 deletions.
125 changes: 103 additions & 22 deletions module/core/former/tests/inc/former_tests/subformer_shortcut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,30 @@ where
Definition::Types : former::FormerDefinitionTypes< Storage = TemplateParametersFormerStorage >,
{

// xxx2 : move to a trait and make easier to use subformer, trait with generic interface of a container should help

#[ inline( always ) ]
pub fn descriptor( self, name : &str ) ->
TemplateParameterDescriptorFormer
<
TemplateParameterDescriptorFormerDefinition
<
Self,
Self,
impl TemplateParameterDescriptorSubformerEnd< Self >,
// former::FormingEndClosure< TemplateParameterDescriptorFormerDefinitionTypes< Self, Self > >,
>
>
{
self.descriptor3::
<
TemplateParameterDescriptorFormer< _ >,
_,
_,
>()
.name( name )
}

#[ inline( always ) ]
pub fn descriptor3< Former2, Definition2, Types2 >( self ) ->
Former2
Expand All @@ -63,7 +87,7 @@ where
Definition2,
>,
{
let on_end = | descriptor : TemplateParameterDescriptorFormerStorage, super_former : core::option::Option< Self > | -> Self
let on_end = | substorage : TemplateParameterDescriptorFormerStorage, super_former : core::option::Option< Self > | -> Self
{
let mut super_former = super_former.unwrap();
if super_former.storage.descriptors.is_none()
Expand All @@ -72,40 +96,97 @@ where
}
if let Some( ref mut descriptors ) = super_former.storage.descriptors
{
former::ContainerAdd::add( descriptors, former::StoragePreform::preform( descriptor ) );
former::ContainerAdd::add( descriptors, former::StoragePreform::preform( substorage ) );
}
super_former
};
Former2::_begin( None, Some( self ), former::FormingEndClosure::new( on_end ) )
// Former2::_begin( None, Some( self ), on_end )
}

// xxx2 : move to a trait and make easier to use subformer, trait with generic interface of a container should help
}

/// Handles the completion of the subformer for `TemplateParameterDescriptor`.
pub struct TemplateParameterDescriptorEnd< Definition, Former2, Definition2, Types2 >
{
_phantom : core::marker::PhantomData< fn( Definition, Former2, Definition2, Types2 ) >,
}

impl< Definition, Former2, Definition2, Types2 > Default
for TemplateParameterDescriptorEnd< Definition, Former2, Definition2, Types2 >
{
#[ inline( always ) ]
pub fn descriptor( self, name : &str ) ->
TemplateParameterDescriptorFormer
<
TemplateParameterDescriptorFormerDefinition
<
Self,
Self,
impl TemplateParameterDescriptorSubformerEnd< Self >,
// former::FormingEndClosure< TemplateParameterDescriptorFormerDefinitionTypes< Self, Self > >,
>
>
fn default() -> Self
{
self.descriptor3::
<
TemplateParameterDescriptorFormer< _ >,
_,
_,
>()
.name( name )
Self
{
_phantom : core::marker::PhantomData,
}
}

}

// impl< Definition, Former2, Definition2, Types2 > former::FormingEnd
// <
// Types2,
// >
// for TemplateParameterDescriptorEnd< Definition, Former2, Definition2, Types2 >
// where
//
// Definition : former::FormerDefinition,
// Definition::Types : former::FormerDefinitionTypes
// <
// Storage = TemplateParametersFormerStorage
// >,
//
// // Self : former::FormerDefinition,
// // Self::Types : former::FormerDefinitionTypes< Storage = TemplateParametersFormerStorage, >
// Types2 : former::FormerDefinitionTypes
// <
// Storage = TemplateParameterDescriptorFormerStorage,
// Formed = Self,
// Context = Self,
// >,
// Definition2 : former::FormerDefinition< Types = Types2, End = former::FormingEndClosure< Types2 > >,
// // Definition2 : former::FormerDefinition< Types = Types2 >,
// Definition2::End : former::FormingEnd< Definition2::Types >,
// Former2 : former::FormerBegin
// <
// Definition2,
// >,
//
// {
// #[ inline( always ) ]
// fn call
// (
// &self,
// substorage : TemplateParameterDescriptorFormerStorage,
// super_former : core::option::Option< Self >,
// // descriptor : TemplateParameterDescriptorFormerStorage,
// // super_former : Option< TemplateParametersFormer< Self > >,
// )
// -> TemplateParametersFormer< Definition >
// {
// let mut super_former = super_former.unwrap();
// if super_former.storage.descriptors.is_none()
// {
// super_former.storage.descriptors = Some( Default::default() );
// }
// if let Some( ref mut descriptors ) = super_former.storage.descriptors
// {
// former::ContainerAdd::add( descriptors, former::StoragePreform::preform( substorage ) );
// }
// super_former
// // let mut super_former = super_former.unwrap();
// // if super_former.storage.descriptors.is_none()
// // {
// // super_former.storage.descriptors = Some( Vec::new() );
// // }
// // let preformed_descriptor = former::StoragePreform::preform( substorage );
// // super_former.storage.descriptors.as_mut().unwrap().push( preformed_descriptor );
// // super_former
// }
// }

#[ test ]
fn basic()
{
Expand Down

0 comments on commit 5a5a615

Please sign in to comment.