Skip to content

Commit

Permalink
former : experimenting
Browse files Browse the repository at this point in the history
  • Loading branch information
Wandalen committed Mar 30, 2024
1 parent 45f23d9 commit 5763010
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 33 deletions.
21 changes: 7 additions & 14 deletions module/core/former/src/axiomatic.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@

/// xxx
/// zzz : write description
pub trait Storage : ::core::default::Default
{
// type Types : FormerDefinitionTypes< Storage = Self >;
type Formed;
}

/// xxx
/// zzz : write description
pub trait StoragePerform : Storage
{
// fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinitionTypes >::Formed;
/// Default implementation of routine transforming storage into formed structure.
/// Does not have to be implemented and does not have to be used, especially if there is complex logic behind tranfromation, but can be used if algorithm is traight-forward and does not require any context.
///
/// `former::ReturnPreformed` rely on `StoragePerform::preform` returning its result.
///
fn preform( self ) -> Self::Formed;
}

/// xxx
/// zzz : write description
pub trait FormerDefinitionTypes : Sized
{
// type Storage : Storage< Definition = Self >;
Expand All @@ -31,7 +24,7 @@ pub trait FormerDefinitionTypes : Sized

}

/// xxx
/// zzz : write description
pub trait FormerDefinition : Sized
{
type Types : FormerDefinitionTypes;
Expand Down Expand Up @@ -94,7 +87,7 @@ where
}
}

/// xxx : update description
/// zzz : update description
#[ derive( Debug, Default ) ]
pub struct ReturnStorage;

Expand All @@ -113,7 +106,7 @@ where
}
}

// xxx : improve description
// zzz : improve description
/// Use `NoEnd` to fill parameter FormingEnd in struct where parameter exists, but it is not needed.
/// It might be needed if the same struct is used as `FormerDefinitionTypes` and as `FormerDefinition`, because the first one does not have information aboud End function.
/// Similar logic which `std::marker::PhantomData` has behind.
Expand Down Expand Up @@ -223,7 +216,7 @@ for FormingEndWrapper< Definition >
/// sophisticated and flexible construction patterns conducive to complex data transformations or object creation
/// sequences within builder patterns.
// xxx : update description
// zzz : update description
pub trait FormerBegin< Definition : FormerDefinition >
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ pub struct Struct1
hashset_strings_1 : std::collections::HashSet< String >,
}

include!( "./only_test/containers_with_runtime.rs" );
include!( "./only_test/containers_with_subformer.rs" );
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,4 @@ where

//

include!( "./only_test/containers_with_runtime.rs" );
include!( "./only_test/containers_with_subformer.rs" );
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ pub struct Struct1

//

include!( "./only_test/containers_without_runtime.rs" );
include!( "./only_test/containers_without_subformer.rs" );
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,4 @@ where

//

include!( "./only_test/containers_without_runtime.rs" );
include!( "./only_test/containers_without_subformer.rs" );
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ pub struct Struct1

//

include!( "./only_test/containers_without_runtime.rs" );
include!( "./only_test/containers_without_subformer.rs" );
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ where
#[ inline( always ) ]
fn _begin
(
storage : core::option::Option< TemplateParameterDefinitionFormerStorage >, /* xxx2 : that should be storage */
storage : core::option::Option< TemplateParameterDefinitionFormerStorage >,
context : core::option::Option< Context >,
on_end : End,
) -> Self
Expand Down
8 changes: 4 additions & 4 deletions module/core/former/tests/inc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ mod former_tests
mod a_primitives_manual;
// mod a_primitives_expanded;
mod a_primitives;
// mod a_containers_without_runtime_manual;
// mod a_containers_without_runtime;
// mod a_containers_without_subformer_manual;
// mod a_containers_without_subformer;
// #[ cfg( not( feature = "no_std" ) ) ]
// mod a_containers_with_runtime_manual;
// mod a_containers_with_subformer_manual;
// #[ cfg( not( feature = "no_std" ) ) ]
// mod a_containers_with_runtime ;
// mod a_containers_with_subformer ;
//
// mod attribute_default_container;
// mod attribute_default_primitive;
Expand Down
14 changes: 5 additions & 9 deletions module/core/former_meta/src/derive/former.rs
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream >

let generics = &ast.generics;
let ( generics_impl, generics_ty, generics_where ) = generics.split_for_impl();
// xxx : eliminate generics_params maybe
// zzz : eliminate generics_params maybe
let _generics_params = generics::params_names( generics ).params;
let generics_params = if _generics_params.len() == 0
{
Expand All @@ -859,7 +859,7 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream >
< Definition::Types as former::FormerDefinitionTypes >::Storage : former::StoragePerform,
Definition::Types : former::FormerDefinitionTypes< Storage = #former_storage_name_ident #generics_ty >,
};
// xxx : write helper to fix bug with where
// zzz : write helper to fix bug with where
let generics_of_former = generics::merge( &generics, &extra_generics );
let ( generics_of_former_impl, generics_of_former_ty, generics_of_former_where ) = generics_of_former.split_for_impl();
let generics_of_former_with_defaults = generics_of_former.params.clone();
Expand Down Expand Up @@ -1002,7 +1002,6 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream >

// = storage

// xxx : rename to storage
#[ doc = "Container of a corresponding former." ]
pub struct #former_storage_name_ident #generics_ty
#generics_where
Expand Down Expand Up @@ -1068,10 +1067,7 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream >
storage : < Definition::Types as former::FormerDefinitionTypes >::Storage,
context : core::option::Option< < Definition::Types as former::FormerDefinitionTypes >::Context >,
on_end : core::option::Option< Definition::End >,
// storage : #former_storage_name_ident #generics_ty,
// context : core::option::Option< __FormerContext >,
// on_end : core::option::Option< __FormerEnd >,
// xxx : should on_end be optional?
// zzz : should on_end be optional?
}

#[ automatically_derived ]
Expand Down Expand Up @@ -1209,7 +1205,7 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream >
diag::debug_report_print( "derive : Former", original_input, &result );
}

// xxx : implement
// zzz : implement hints
if example_of_custom_setter
{
let _example =
Expand All @@ -1233,4 +1229,4 @@ where
Ok( result )
}

// xxx : explain concept of Storage
// zzz : explain concept of Storage

0 comments on commit 5763010

Please sign in to comment.