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 76fd851 commit c506309
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ where
pub type Struct1Subformer< __Superformer, __End >
= Struct1Former< Struct1FormerDefinition< __Superformer, __Superformer, __End, >, >;

// // xxx : remove maybe
// pub type Struct1FormerWithClosure< __Context, __Formed, > = Struct1FormerDefinition< __Context, __Formed, former::FormingEndClosure< Struct1FormerDefinitionTypes< __Context, __Formed, > > >;

// = subformer end
Expand Down
61 changes: 16 additions & 45 deletions module/core/former/tests/inc/former_tests/subformer_shortcut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,6 @@ 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._descriptor_former2::
<
TemplateParameterDescriptorFormer< _ >,
_,
_,
>()
.name( name )
}

#[ inline( always ) ]
pub fn _descriptor_former< Former2, Definition2, Types2 >( self ) ->
Expand Down Expand Up @@ -123,6 +100,22 @@ where
Former2::_begin( None, Some( self ), TemplateParameterDescriptorEnd::< Definition, Types2 >::default() )
}

// 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 ) ->
TemplateParameterDescriptorSubformer< Self, impl TemplateParameterDescriptorSubformerEnd< Self > >
{
self._descriptor_former2
::
<
TemplateParameterDescriptorFormer< _ >,
_,
_,
>
()
.name( name )
}
}

/// Handles the completion of the subformer for `TemplateParameterDescriptor`.
Expand All @@ -147,38 +140,24 @@ for TemplateParameterDescriptorEnd< Definition, Types2 >
impl< Definition, Types2 > former::FormingEnd< Types2, >
for TemplateParameterDescriptorEnd< Definition, 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 = TemplateParametersFormer< Definition >,
Context = TemplateParametersFormer< Definition >,
>,
// 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< TemplateParametersFormer< Definition > >,
// descriptor : TemplateParameterDescriptorFormerStorage,
// super_former : Option< TemplateParametersFormer< Self > >,
)
-> TemplateParametersFormer< Definition >
{
Expand All @@ -192,14 +171,6 @@ where
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
}
}

Expand Down
2 changes: 1 addition & 1 deletion module/core/former_meta/src/derive/former.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream >
let former_definition_types_name = format!( "{}FormerDefinitionTypes", stru );
let former_definition_types = syn::Ident::new( &former_definition_types_name, stru.span() );
// let former_with_closure_name = format!( "{}FormerWithClosure", stru );
// let former_with_closure = syn::Ident::new( &former_with_closure_name, stru.span() ); // xxx : maybe remove
// let former_with_closure = syn::Ident::new( &former_with_closure_name, stru.span() );
let subformer_name = format!( "{}Subformer", stru );
let subformer = syn::Ident::new( &subformer_name, stru.span() );
let subformer_end_name = format!( "{}SubformerEnd", stru );
Expand Down

0 comments on commit c506309

Please sign in to comment.