File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,10 @@ def f_i16_i16(x: i16) -> i16:
24
24
def f_i8_i8 (x : i8 ) -> i8 :
25
25
pass
26
26
27
+ @ccall
28
+ def f_str_i32 (x : str ) -> i32 :
29
+ pass
30
+
27
31
def test_c_callbacks ():
28
32
xf64 : f64
29
33
xf64 = 3.3
@@ -49,4 +53,13 @@ def test_c_callbacks():
49
53
xi8 = 3
50
54
assert f_i8_i8 (xi8 ) == 4
51
55
56
+ assert f_str_i32 ("Hello World!" ) == 12
57
+ assert f_str_i32 ("abc" ) == 3
58
+ assert f_str_i32 ("a" ) == 1
59
+ assert f_str_i32 ("" ) == 0
60
+ x : str = "Hello World!"
61
+ assert f_str_i32 (x ) == 12
62
+ x = "abc"
63
+ assert f_str_i32 (x ) == 3
64
+
52
65
test_c_callbacks ()
Original file line number Diff line number Diff line change
1
+ #include <string.h>
2
+
1
3
#include "test_c_interop_02b.h"
2
4
3
5
double f_f64_f64 (double x ) {
@@ -23,3 +25,7 @@ int16_t f_i16_i16(int16_t x) {
23
25
int8_t f_i8_i8 (int8_t x ) {
24
26
return x + 1 ;
25
27
}
28
+
29
+ int32_t f_str_i32 (char * x ) {
30
+ return strlen (x );
31
+ }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ int64_t f_i64_i64(int64_t x);
10
10
int32_t f_i32_i32 (int32_t x );
11
11
int16_t f_i16_i16 (int16_t x );
12
12
int8_t f_i8_i8 (int8_t x );
13
+ int32_t f_str_i32 (char * x );
13
14
14
15
15
16
#endif // TEST_C_INTEROP_02B
You can’t perform that action at this time.
0 commit comments