@@ -4,6 +4,17 @@ struct BridgeJSLink {
44 /// The exported skeletons
55 var exportedSkeletons : [ ExportedSkeleton ] = [ ]
66 var importedSkeletons : [ ImportedModuleSkeleton ] = [ ]
7+ let sharedMemory : Bool
8+
9+ init (
10+ exportedSkeletons: [ ExportedSkeleton ] = [ ] ,
11+ importedSkeletons: [ ImportedModuleSkeleton ] = [ ] ,
12+ sharedMemory: Bool
13+ ) {
14+ self . exportedSkeletons = exportedSkeletons
15+ self . importedSkeletons = importedSkeletons
16+ self . sharedMemory = sharedMemory
17+ }
718
819 mutating func addExportedSkeletonFile( data: Data ) throws {
920 let skeleton = try JSONDecoder ( ) . decode ( ExportedSkeleton . self, from: data)
@@ -118,7 +129,7 @@ struct BridgeJSLink {
118129 const bjs = {};
119130 importObject[ " bjs " ] = bjs;
120131 bjs[ " return_string " ] = function(ptr, len) {
121- const bytes = new Uint8Array(memory.buffer, ptr, len);
132+ const bytes = new Uint8Array(memory.buffer, ptr, len) \( sharedMemory ? " .slice() " : " " ) ;
122133 tmpRetString = textDecoder.decode(bytes);
123134 }
124135 bjs[ " init_memory " ] = function(sourceId, bytesPtr) {
@@ -127,7 +138,7 @@ struct BridgeJSLink {
127138 bytes.set(source);
128139 }
129140 bjs[ " make_jsstring " ] = function(ptr, len) {
130- const bytes = new Uint8Array(memory.buffer, ptr, len);
141+ const bytes = new Uint8Array(memory.buffer, ptr, len) \( sharedMemory ? " .slice() " : " " ) ;
131142 return swift.memory.retain(textDecoder.decode(bytes));
132143 }
133144 bjs[ " init_memory_with_result " ] = function(ptr, len) {
0 commit comments