11#![ feature( const_raw_ptr_to_usize_cast) ]
22use std:: os:: raw:: c_void;
33
4- use duckasm_derive :: duckasm_func ;
5- use static_repr :: AsmRepr ;
6- use duckasm_repr :: funcs:: { FunctionDeclaration , FunctionLocation , SignatureDef } ;
7- use duckasm_repr :: types:: AsmType ;
4+ use static_reflect_derive :: reflect_func ;
5+ use static_reflect :: StaticReflect ;
6+ use static_reflect :: funcs:: { FunctionDeclaration , FunctionLocation , SignatureDef } ;
7+ use static_reflect :: types:: { TypeInfo , FloatSize } ;
88use std:: marker:: PhantomData ;
99
10- #[ duckasm_func ]
10+ #[ reflect_func ]
1111#[ export_name = "better_name" ]
1212extern "C" fn stupid_name ( first : f32 , second : f32 ) {
1313 eprintln ! ( "Test {}: {}" , first, second) ;
1414}
1515
1616#[ no_mangle]
17- #[ duckasm_func ]
17+ #[ reflect_func ]
1818unsafe extern "C" fn dynamically_linked ( first : u32 , second : * mut String ) -> f32 {
1919 eprintln ! ( "Test {}: {}" , first, & * second) ;
2020 3.14
2121}
2222
23- #[ duckasm_func (
23+ #[ reflect_func (
2424 absolute // NOTE: This removes the requirement for #[no_mangle]
2525) ]
2626extern "C" fn absolute_address_example ( x : f64 , y : f64 ) -> f64 {
2727 ( x * x + y * y) . sqrt ( )
2828}
2929
30- #[ duckasm_func ]
30+ #[ reflect_func ]
3131extern "C" {
3232 /*
3333 * TODO: These are considered 'dead' even though DuckAsm uses them
3434 * Just because they're not invoked directly by Rust code,
35- * doesn't mean their are actually unused.....
35+ * doesn't mean they are actually unused.....
3636 */
3737 #[ allow( dead_code) ]
3838 #[ link_name = "sqrtf" ]
@@ -48,10 +48,10 @@ fn extern_block() {
4848 FunctionDeclaration :: <* mut c_void, ( usize , ) > {
4949 name: "malloc" ,
5050 is_unsafe: true , // Foreign functions are always unsafe (in spite of lack of keyword)
51- location: FunctionLocation :: DynamicallyLinked { link_name: None } ,
51+ location: Some ( FunctionLocation :: DynamicallyLinked { link_name: None } ) ,
5252 signature: SignatureDef {
53- argument_types: & [ usize :: STATIC_TYPE ] ,
54- return_type: & AsmType :: Pointer ,
53+ argument_types: & [ usize :: TYPE_INFO ] ,
54+ return_type: & TypeInfo :: Pointer ,
5555 calling_convention: Default :: default ( )
5656 } ,
5757 return_type: PhantomData ,
@@ -63,10 +63,10 @@ fn extern_block() {
6363 FunctionDeclaration :: <f32 , ( f32 , ) > {
6464 name: "sqrt" ,
6565 is_unsafe: true , // NOTE: Foreign function
66- location: FunctionLocation :: DynamicallyLinked { link_name: Some ( "sqrtf" . into( ) ) } ,
66+ location: Some ( FunctionLocation :: DynamicallyLinked { link_name: Some ( "sqrtf" . into( ) ) } ) ,
6767 signature: SignatureDef {
68- argument_types: & [ f32 :: STATIC_TYPE ] ,
69- return_type: & f32 :: STATIC_TYPE ,
68+ argument_types: & [ f32 :: TYPE_INFO ] ,
69+ return_type: & f32 :: TYPE_INFO ,
7070 calling_convention: Default :: default ( )
7171 } ,
7272 return_type: PhantomData ,
@@ -84,10 +84,10 @@ fn rust_funcs() {
8484 FunctionDeclaration :: <f32 , ( u32 , * mut String ) > {
8585 name: "dynamically_linked" ,
8686 is_unsafe: true ,
87- location: FunctionLocation :: DynamicallyLinked { link_name: None } ,
87+ location: Some ( FunctionLocation :: DynamicallyLinked { link_name: None } ) ,
8888 signature: SignatureDef {
89- argument_types: & [ u32 :: STATIC_TYPE , AsmType :: Pointer ] ,
90- return_type: & AsmType :: Float { bytes : 4 } ,
89+ argument_types: & [ u32 :: TYPE_INFO , TypeInfo :: Pointer ] ,
90+ return_type: & TypeInfo :: F32 ,
9191 calling_convention: Default :: default ( )
9292 } ,
9393 return_type: PhantomData ,
@@ -99,10 +99,10 @@ fn rust_funcs() {
9999 FunctionDeclaration :: <( ) , ( f32 , f32 ) > {
100100 name: "stupid_name" ,
101101 is_unsafe: false ,
102- location: FunctionLocation :: DynamicallyLinked { link_name: Some ( "better_name" . into( ) ) } ,
102+ location: Some ( FunctionLocation :: DynamicallyLinked { link_name: Some ( "better_name" . into( ) ) } ) ,
103103 signature: SignatureDef {
104- argument_types: & [ f32 :: STATIC_TYPE , AsmType :: Float { bytes : 4 } ] ,
105- return_type: & AsmType :: Unit ,
104+ argument_types: & [ f32 :: TYPE_INFO , TypeInfo :: Float { size : FloatSize :: Single } ] ,
105+ return_type: & TypeInfo :: Unit ,
106106 calling_convention: Default :: default ( )
107107 } ,
108108 return_type: PhantomData ,
@@ -114,10 +114,10 @@ fn rust_funcs() {
114114 FunctionDeclaration :: <f64 , ( f64 , f64 ) > {
115115 name: "absolute_address_example" ,
116116 is_unsafe: false ,
117- location: FunctionLocation :: AbsoluteAddress ( absolute_address_example as * const ( ) ) ,
117+ location: Some ( FunctionLocation :: AbsoluteAddress ( absolute_address_example as * const ( ) ) ) ,
118118 signature: SignatureDef {
119- argument_types: & [ f64 :: STATIC_TYPE , f64 :: STATIC_TYPE ] ,
120- return_type: & f64 :: STATIC_TYPE ,
119+ argument_types: & [ f64 :: TYPE_INFO , f64 :: TYPE_INFO ] ,
120+ return_type: & f64 :: TYPE_INFO ,
121121 calling_convention: Default :: default ( )
122122 } ,
123123 return_type: PhantomData ,
0 commit comments