Skip to content

Commit

Permalink
Merge pull request #1336 from Wandalen/program_tools_v1
Browse files Browse the repository at this point in the history
Program tools v1
  • Loading branch information
Wandalen committed May 14, 2024
2 parents 7c05536 + 91e8ea0 commit b0c751c
Show file tree
Hide file tree
Showing 18 changed files with 208 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
#[ allow( unused_imports ) ]
use super::*;


pub mod core {}
pub mod std {}
pub mod marker {}
pub trait CloneAny{}
pub trait End{}
// pub trait Context{}
pub trait Formed{}
pub trait OnEnd{}

#[ derive( Clone, the_module::Former ) ]
pub struct Context
{
inner : std::sync::Arc< core::cell::RefCell< dyn CloneAny > >
inner : ::std::sync::Arc< ::core::cell::RefCell< dyn CloneAny > >
}
19 changes: 19 additions & 0 deletions module/core/former/tests/inc/former_tests/name_collision_core.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#![ allow( dead_code ) ]
#![ allow( non_camel_case_types ) ]

#[ allow( unused_imports ) ]
use super::*;

// pub mod core {}
pub mod std {}
pub mod marker {}
pub trait CloneAny{}
pub trait Context{}
pub trait Formed{}
pub trait OnEnd{}

#[ derive( Clone, the_module::Former ) ]
pub struct core
{
inner : ::std::sync::Arc< ::core::cell::RefCell< dyn CloneAny > >
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#[ allow( unused_imports ) ]
use super::*;

pub mod core {}
pub mod std {}
pub mod marker {}
pub trait CloneAny{}
pub trait Context{}
pub trait Formed{}
Expand All @@ -13,7 +16,7 @@ pub trait OnEnd{}
// #[ derive( Clone ) ]
pub struct End
{
inner : std::sync::Arc< core::cell::RefCell< dyn CloneAny > >
inner : ::std::sync::Arc< ::core::cell::RefCell< dyn CloneAny > >
}

// = begin_coercing of generated
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
use super::*;
use the_module::Former;

pub mod core {}
pub mod std {}
pub mod marker {}
pub trait CloneAny{}
pub trait Context{}
pub trait Formed{}
pub trait OnEnd{}

#[ derive( Debug, PartialEq ) ]
struct HashMap< T >
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
use super::*;
use the_module::Former;

pub mod core {}
pub mod std {}
pub mod marker {}
pub trait CloneAny{}
pub trait Context{}
pub trait Formed{}
pub trait OnEnd{}

#[ derive( Debug, PartialEq ) ]
struct Vec
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
#[ allow( unused_imports ) ]
use super::*;

pub mod core {}
pub mod std {}
pub mod marker {}
pub trait CloneAny{}
pub trait Context{}
pub trait End{}
pub trait Formed{}
// pub trait OnEnd{}

#[ derive( Clone, the_module::Former ) ]
pub struct OnEnd
{
inner : std::sync::Arc< core::cell::RefCell< dyn CloneAny > >
inner : ::std::sync::Arc< ::core::cell::RefCell< dyn CloneAny > >
}
11 changes: 9 additions & 2 deletions module/core/former/tests/inc/former_tests/name_collisions.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#[ allow( unused_imports ) ]
use super::*;

pub mod core {}
pub mod std {}
pub trait CloneAny{}
pub trait Context{}
pub trait Formed{}
pub trait OnEnd{}

#[ allow( dead_code ) ]
type Option = ();
#[ allow( dead_code ) ]
Expand Down Expand Up @@ -28,8 +35,8 @@ type HashMap = ();
pub struct Struct1
{
vec_1 : Vec< String >,
hashmap_1 : std::collections::HashMap< String, String >,
hashset_1 : std::collections::HashSet< String >,
hashmap_1 : ::std::collections::HashMap< String, String >,
hashset_1 : ::std::collections::HashSet< String >,
}

//
Expand Down
8 changes: 4 additions & 4 deletions module/core/former/tests/inc/former_tests/only_test/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ tests_impls!
a_id!( former.context, None );
a_id!( print!( "{:?}", former.on_end ), print!( "{:?}", Some( the_module::ReturnPreformed ) ) );
let former2 = Struct1Former::< Struct1FormerDefinition< (), Struct1, former::ReturnPreformed > >::new_coercing( former::ReturnPreformed );
a_id!( std::mem::size_of_val( &former ), std::mem::size_of_val( &former2 ) );
a_id!( ::std::mem::size_of_val( &former ), ::std::mem::size_of_val( &former2 ) );
let former2 = Struct1Former::< Struct1FormerDefinition< (), Struct1, former::ReturnPreformed > >::new( former::ReturnPreformed );
a_id!( std::mem::size_of_val( &former ), std::mem::size_of_val( &former2 ) );
a_id!( ::std::mem::size_of_val( &former ), ::std::mem::size_of_val( &former2 ) );

let command = Struct1::former().form();
a_id!( command.int_1, 0 );
Expand Down Expand Up @@ -255,7 +255,7 @@ tests_impls!
// basic case
let former = Struct1::former();
let former2 = Struct1Former::< Struct1FormerDefinition< (), Struct1, former::ReturnPreformed > >::new( former::ReturnPreformed );
a_id!( std::mem::size_of_val( &former ), std::mem::size_of_val( &former2 ) );
a_id!( ::std::mem::size_of_val( &former ), ::std::mem::size_of_val( &former2 ) );
let exp = former.form();
let got = former2.form();
a_id!( got, exp );
Expand Down Expand Up @@ -324,7 +324,7 @@ tests_impls!
// basic case
let former = Struct1::former();
let former2 = Struct1Former::< Struct1FormerDefinition< (), Struct1, former::ReturnPreformed > >::new( former::ReturnPreformed );
a_id!( std::mem::size_of_val( &former ), std::mem::size_of_val( &former2 ) );
a_id!( ::std::mem::size_of_val( &former ), ::std::mem::size_of_val( &former2 ) );
let exp = former.form();
let got = former2.form();
a_id!( got, exp );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ tests_impls!
let former = Struct1::former();
a_id!( print!( "{:?}", former.on_end ), print!( "{:?}", Some( the_module::ReturnPreformed ) ) );
let former2 = Struct1Former::< Struct1FormerDefinition >::new_coercing( former::ReturnPreformed );
a_id!( std::mem::size_of_val( &former ), std::mem::size_of_val( &former2 ) );
a_id!( ::std::mem::size_of_val( &former ), ::std::mem::size_of_val( &former2 ) );

// default parameters
let former = Struct1::former();
let former2 : Struct1Former = Struct1Former::new_coercing( former::ReturnPreformed );
a_id!( std::mem::size_of_val( &former ), std::mem::size_of_val( &former2 ) );
a_id!( ::std::mem::size_of_val( &former ), ::std::mem::size_of_val( &former2 ) );

// closure without helper
let got : Struct1 = Struct1Former
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tests_impls!
a_id!( former.context, None );
a_id!( print!( "{:?}", former.on_end ), print!( "{:?}", Some( the_module::ReturnPreformed ) ) );
let former2 = Struct1Former::< Struct1FormerDefinition >::new_coercing( the_module::ReturnPreformed );
a_id!( std::mem::size_of_val( &former ), std::mem::size_of_val( &former2 ) );
a_id!( ::std::mem::size_of_val( &former ), ::std::mem::size_of_val( &former2 ) );

let command = Struct1::former().form();
a_id!( command.vec_1, Vec::< String >::new() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// ;
// ca.execute( input ).unwrap();

// qqq : for Antont : zzz : here and in all similar tests remove `#[ cfg( not( feature = "use_alloc" ) ) ]`
// qqq : for Anton : zzz : here and in all similar tests remove `#[ cfg( not( feature = "use_alloc" ) ) ]`
#[ cfg( not( feature = "use_alloc" ) ) ]
#[ test ]
fn command_with_closure()
Expand Down
1 change: 1 addition & 0 deletions module/core/former/tests/inc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ mod former_tests
mod name_collision_context;
mod name_collision_end;
mod name_collision_on_end;
mod name_collision_core;

// = parametrization

Expand Down
24 changes: 12 additions & 12 deletions module/core/former_meta/src/derive_former.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ specific needs of the broader forming context. It mandates the implementation of
where
#former_definition_types_generics_where
{
// _phantom : core::marker::PhantomData< ( __Context, __Formed ) >,
// _phantom : ::core::marker::PhantomData< ( __Context, __Formed ) >,
_phantom : #former_definition_types_phantom,
}

Expand All @@ -413,7 +413,7 @@ specific needs of the broader forming context. It mandates the implementation of
{
Self
{
_phantom : core::marker::PhantomData,
_phantom : ::core::marker::PhantomData,
}
}
}
Expand All @@ -436,7 +436,7 @@ specific needs of the broader forming context. It mandates the implementation of
where
#former_definition_generics_where
{
// _phantom : core::marker::PhantomData< ( __Context, __Formed, __End ) >,
// _phantom : ::core::marker::PhantomData< ( __Context, __Formed, __End ) >,
_phantom : #former_definition_phantom,
}

Expand All @@ -449,7 +449,7 @@ specific needs of the broader forming context. It mandates the implementation of
{
Self
{
_phantom : core::marker::PhantomData,
_phantom : ::core::marker::PhantomData,
}
}
}
Expand Down Expand Up @@ -544,10 +544,10 @@ specific needs of the broader forming context. It mandates the implementation of
pub storage : Definition::Storage,
/// An optional context providing additional data or state necessary for custom
/// formation logic or to facilitate this former's role as a subformer within another former.
pub context : core::option::Option< Definition::Context >,
pub context : ::core::option::Option< Definition::Context >,
/// An optional closure or handler that is invoked to transform the accumulated
/// temporary storage into the final object structure once formation is complete.
pub on_end : core::option::Option< Definition::End >,
pub on_end : ::core::option::Option< Definition::End >,
}

#[ automatically_derived ]
Expand Down Expand Up @@ -587,8 +587,8 @@ specific needs of the broader forming context. It mandates the implementation of
#[ inline( always ) ]
pub fn begin
(
mut storage : core::option::Option< Definition::Storage >,
context : core::option::Option< Definition::Context >,
mut storage : ::core::option::Option< Definition::Storage >,
context : ::core::option::Option< Definition::Context >,
on_end : < Definition as former::FormerDefinition >::End,
)
-> Self
Expand All @@ -611,8 +611,8 @@ specific needs of the broader forming context. It mandates the implementation of
#[ inline( always ) ]
pub fn begin_coercing< IntoEnd >
(
mut storage : core::option::Option< Definition::Storage >,
context : core::option::Option< Definition::Context >,
mut storage : ::core::option::Option< Definition::Storage >,
context : ::core::option::Option< Definition::Context >,
on_end : IntoEnd,
) -> Self
where
Expand Down Expand Up @@ -714,8 +714,8 @@ specific needs of the broader forming context. It mandates the implementation of
#[ inline( always ) ]
fn former_begin
(
storage : core::option::Option< Definition::Storage >,
context : core::option::Option< Definition::Context >,
storage : ::core::option::Option< Definition::Storage >,
context : ::core::option::Option< Definition::Context >,
on_end : Definition::End,
)
-> Self
Expand Down
4 changes: 2 additions & 2 deletions module/core/macro_tools/src/phantom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub( crate ) mod private
/// let generics: Punctuated< GenericParam, Comma > = parse_quote! { 'a, T, const N : usize };
/// let phantom_type = tuple( &generics );
/// println!( "{}", quote::quote! { #phantom_type } );
/// // Output: core::marker::PhantomData< ( &'a (), *const T, N ) >
/// // Output : ::core::marker::PhantomData< ( &'a (), *const T, N ) >
/// ```
///
pub fn tuple( input : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma > ) -> syn::Type
Expand Down Expand Up @@ -165,7 +165,7 @@ pub( crate ) mod private

let result : syn::Type = syn::parse_quote!
{
core::marker::PhantomData< #generics_tuple_type >
::core::marker::PhantomData< #generics_tuple_type >
};

result
Expand Down

0 comments on commit b0c751c

Please sign in to comment.