File tree 4 files changed +17
-3
lines changed
4 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,9 @@ let package = Package(
19
19
" -Xlinker " ,
20
20
" --export=swjs_prepare_host_function_call " ,
21
21
" -Xlinker " ,
22
- " --export=swjs_cleanup_host_function_call "
22
+ " --export=swjs_cleanup_host_function_call " ,
23
+ " -Xlinker " ,
24
+ " --export=swjs_library_version " ,
23
25
] ,
24
26
. when( platforms: [ . wasi] )
25
27
)
Original file line number Diff line number Diff line change @@ -19,7 +19,9 @@ let package = Package(
19
19
" -Xlinker " ,
20
20
" --export=swjs_prepare_host_function_call " ,
21
21
" -Xlinker " ,
22
- " --export=swjs_cleanup_host_function_call "
22
+ " --export=swjs_cleanup_host_function_call " ,
23
+ " -Xlinker " ,
24
+ " --export=swjs_library_version " ,
23
25
]
24
26
)
25
27
] ) ,
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ declare const window: GlobalVariable;
10
10
declare const global : GlobalVariable ;
11
11
12
12
interface SwiftRuntimeExportedFunctions {
13
+ swjs_library_version ( ) : number ;
13
14
swjs_prepare_host_function_call ( size : number ) : pointer ;
14
15
swjs_cleanup_host_function_call ( argv : pointer ) : void ;
15
16
swjs_call_host_function (
@@ -84,6 +85,7 @@ class SwiftRuntimeHeap {
84
85
export class SwiftRuntime {
85
86
private instance : WebAssembly . Instance | null ;
86
87
private heap : SwiftRuntimeHeap
88
+ private version : number = 400
87
89
88
90
constructor ( ) {
89
91
this . instance = null ;
@@ -92,6 +94,10 @@ export class SwiftRuntime {
92
94
93
95
setInstance ( instance : WebAssembly . Instance ) {
94
96
this . instance = instance
97
+ const exports = this . instance . exports as any as SwiftRuntimeExportedFunctions ;
98
+ if ( exports . swjs_library_version ( ) != this . version ) {
99
+ throw new Error ( "The versions of JavaScriptKit are incompatible." )
100
+ }
95
101
}
96
102
97
103
importObjects ( ) {
@@ -351,4 +357,4 @@ export class SwiftRuntime {
351
357
}
352
358
}
353
359
}
354
- }
360
+ }
Original file line number Diff line number Diff line change
1
+ @_cdecl ( " swjs_library_version " )
2
+ func _library_version( ) -> Double {
3
+ return 400
4
+ }
You can’t perform that action at this time.
0 commit comments