File tree 5 files changed +34
-5
lines changed
5 files changed +34
-5
lines changed Original file line number Diff line number Diff line change 1
1
.DS_Store
2
- / .build
2
+ .build
3
3
/Packages
4
4
/* .xcodeproj
5
5
xcuserdata /
Original file line number Diff line number Diff line change
1
+ // swift-tools-version: 5.6
2
+ // The swift-tools-version declares the minimum version of Swift required to build this package.
3
+
4
+ import PackageDescription
5
+
6
+ let package = Package (
7
+ name: " api " ,
8
+ products: [
9
+ . executable( name: " API " , targets: [ " API " ] )
10
+ ] ,
11
+ dependencies: [
12
+ . package ( name: " CDK " , path: " ../../ " )
13
+ ] ,
14
+ targets: [
15
+ . executableTarget( name: " API " , dependencies: [ " CDK " ] )
16
+ ]
17
+ )
Original file line number Diff line number Diff line change
1
+ import CDK
2
+
3
+ @_cdecl ( " ic_init " )
4
+ func `init`( ) {
5
+ CDK . print ( " Hello Swift! " )
6
+ }
Original file line number Diff line number Diff line change 1
1
import IC
2
2
3
- @_cdecl ( " time " )
3
+ public func print( _ message: String ) {
4
+ withUnsafePointer ( to: message) { src in
5
+ let size = Int32 ( MemoryLayout . size ( ofValue: message) )
6
+ IC . debug_print ( src, size)
7
+ }
8
+ }
9
+
4
10
public func time( ) -> Int64 {
5
11
IC . time ( )
6
12
}
Original file line number Diff line number Diff line change 5
5
6
6
#if __wasm32__
7
7
8
+ __attribute__((__import_module__ ("ic0" ),__import_name__ ("debug_print" )))
9
+ extern void debug_print (const void * src , int32_t size );
10
+
8
11
__attribute__((__import_module__ ("ic0" ),__import_name__ ("time" )))
9
12
extern int64_t time (void );
10
13
11
- __attribute__((__import_module__ ("ic0" ),__import_name__ ("debug_print" )))
12
- extern void debug_print (int32_t src , int32_t size );
13
-
14
14
#endif
15
15
#endif /* ic_h */
You can’t perform that action at this time.
0 commit comments