1
1
#![ feature( const_raw_ptr_to_usize_cast) ]
2
2
use std:: os:: raw:: c_void;
3
3
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 } ;
8
8
use std:: marker:: PhantomData ;
9
9
10
- #[ duckasm_func ]
10
+ #[ reflect_func ]
11
11
#[ export_name = "better_name" ]
12
12
extern "C" fn stupid_name ( first : f32 , second : f32 ) {
13
13
eprintln ! ( "Test {}: {}" , first, second) ;
14
14
}
15
15
16
16
#[ no_mangle]
17
- #[ duckasm_func ]
17
+ #[ reflect_func ]
18
18
unsafe extern "C" fn dynamically_linked ( first : u32 , second : * mut String ) -> f32 {
19
19
eprintln ! ( "Test {}: {}" , first, & * second) ;
20
20
3.14
21
21
}
22
22
23
- #[ duckasm_func (
23
+ #[ reflect_func (
24
24
absolute // NOTE: This removes the requirement for #[no_mangle]
25
25
) ]
26
26
extern "C" fn absolute_address_example ( x : f64 , y : f64 ) -> f64 {
27
27
( x * x + y * y) . sqrt ( )
28
28
}
29
29
30
- #[ duckasm_func ]
30
+ #[ reflect_func ]
31
31
extern "C" {
32
32
/*
33
33
* TODO: These are considered 'dead' even though DuckAsm uses them
34
34
* 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.....
36
36
*/
37
37
#[ allow( dead_code) ]
38
38
#[ link_name = "sqrtf" ]
@@ -48,10 +48,10 @@ fn extern_block() {
48
48
FunctionDeclaration :: <* mut c_void, ( usize , ) > {
49
49
name: "malloc" ,
50
50
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 } ) ,
52
52
signature: SignatureDef {
53
- argument_types: & [ usize :: STATIC_TYPE ] ,
54
- return_type: & AsmType :: Pointer ,
53
+ argument_types: & [ usize :: TYPE_INFO ] ,
54
+ return_type: & TypeInfo :: Pointer ,
55
55
calling_convention: Default :: default ( )
56
56
} ,
57
57
return_type: PhantomData ,
@@ -63,10 +63,10 @@ fn extern_block() {
63
63
FunctionDeclaration :: <f32 , ( f32 , ) > {
64
64
name: "sqrt" ,
65
65
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( ) ) } ) ,
67
67
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 ,
70
70
calling_convention: Default :: default ( )
71
71
} ,
72
72
return_type: PhantomData ,
@@ -84,10 +84,10 @@ fn rust_funcs() {
84
84
FunctionDeclaration :: <f32 , ( u32 , * mut String ) > {
85
85
name: "dynamically_linked" ,
86
86
is_unsafe: true ,
87
- location: FunctionLocation :: DynamicallyLinked { link_name: None } ,
87
+ location: Some ( FunctionLocation :: DynamicallyLinked { link_name: None } ) ,
88
88
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 ,
91
91
calling_convention: Default :: default ( )
92
92
} ,
93
93
return_type: PhantomData ,
@@ -99,10 +99,10 @@ fn rust_funcs() {
99
99
FunctionDeclaration :: <( ) , ( f32 , f32 ) > {
100
100
name: "stupid_name" ,
101
101
is_unsafe: false ,
102
- location: FunctionLocation :: DynamicallyLinked { link_name: Some ( "better_name" . into( ) ) } ,
102
+ location: Some ( FunctionLocation :: DynamicallyLinked { link_name: Some ( "better_name" . into( ) ) } ) ,
103
103
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 ,
106
106
calling_convention: Default :: default ( )
107
107
} ,
108
108
return_type: PhantomData ,
@@ -114,10 +114,10 @@ fn rust_funcs() {
114
114
FunctionDeclaration :: <f64 , ( f64 , f64 ) > {
115
115
name: "absolute_address_example" ,
116
116
is_unsafe: false ,
117
- location: FunctionLocation :: AbsoluteAddress ( absolute_address_example as * const ( ) ) ,
117
+ location: Some ( FunctionLocation :: AbsoluteAddress ( absolute_address_example as * const ( ) ) ) ,
118
118
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 ,
121
121
calling_convention: Default :: default ( )
122
122
} ,
123
123
return_type: PhantomData ,
0 commit comments