|
3 | 3 |
|
4 | 4 | import BuildConfiguration from "consts:configuration"; |
5 | 5 |
|
6 | | -import { dotnetBrowserUtilsExports, dotnetApi, dotnetAssert } from "./cross-module"; |
| 6 | +import { dotnetBrowserUtilsExports, dotnetApi, dotnetAssert, Module } from "./cross-module"; |
7 | 7 |
|
8 | 8 | import type { BoundMarshalerToCs, JSMarshalerArgument, JSMarshalerArguments, JSMarshalerType, MarshalerToCs, MarshalerToJs, TypedArray } from "./types"; |
9 | 9 | import { MarshalerType } from "./types"; |
@@ -206,22 +206,11 @@ export function marshal_string_to_cs(arg: JSMarshalerArgument, value: string) { |
206 | 206 |
|
207 | 207 | // eslint-disable-next-line @typescript-eslint/no-unused-vars |
208 | 208 | function _marshal_string_to_cs_impl(arg: JSMarshalerArgument, value: string) { |
209 | | - /* TODO-WASM |
210 | | - if (WasmEnableJsInteropByValue) { |
211 | | - const bufferLen = value.length * 2; |
212 | | - const buffer = malloc(bufferLen);// together with Marshal.FreeHGlobal |
213 | | - stringToUTF16(buffer as any, buffer as any + bufferLen, value); |
214 | | - set_arg_intptr(arg, buffer); |
215 | | - set_arg_length(arg, value.length); |
216 | | - } else { |
217 | | - dotnetAssert.check(!WasmEnableThreads, "Marshaling strings by reference is not supported in multithreaded mode"); |
218 | | - const root = get_string_root(arg); |
219 | | - try { |
220 | | - stringToMonoStringRoot(value, root); |
221 | | - } finally { |
222 | | - root.release(); |
223 | | - } |
224 | | - }*/ |
| 209 | + const bufferLen = value.length * 2; |
| 210 | + const buffer = Module._malloc(bufferLen);// together with Marshal.FreeHGlobal |
| 211 | + dotnetBrowserUtilsExports.stringToUTF16(buffer as any, buffer as any + bufferLen, value); |
| 212 | + set_arg_intptr(arg, buffer); |
| 213 | + set_arg_length(arg, value.length); |
225 | 214 | } |
226 | 215 |
|
227 | 216 | function _marshal_null_to_cs(arg: JSMarshalerArgument) { |
@@ -457,27 +446,17 @@ export function marshal_array_to_cs_impl(arg: JSMarshalerArgument, value: Array< |
457 | 446 | if (element_type == MarshalerType.String) { |
458 | 447 | dotnetAssert.check(Array.isArray(value), "Value is not an Array"); |
459 | 448 | dotnetBrowserUtilsExports.zeroRegion(buffer_ptr, buffer_length); |
460 | | - throw new Error("TODO-WASM"); |
461 | | - /*if (!WasmEnableJsInteropByValue) { |
462 | | - dotnetAssert.check(!WasmEnableThreads, "Marshaling strings by reference is not supported in multithreaded mode"); |
463 | | - cwraps.SystemInteropJS_RegisterGCRoot(buffer_ptr, buffer_length, "marshal_array_to_cs"); |
464 | | - } |
465 | 449 | for (let index = 0; index < length; index++) { |
466 | 450 | const element_arg = get_arg(<any>buffer_ptr, index); |
467 | 451 | marshal_string_to_cs(element_arg, value[index]); |
468 | | - }*/ |
| 452 | + } |
469 | 453 | } else if (element_type == MarshalerType.Object) { |
470 | 454 | dotnetAssert.check(Array.isArray(value), "Value is not an Array"); |
471 | 455 | dotnetBrowserUtilsExports.zeroRegion(buffer_ptr, buffer_length); |
472 | | - throw new Error("TODO-WASM"); |
473 | | - /*TODO-WASM if (!WasmEnableJsInteropByValue) { |
474 | | - dotnetAssert.check(!WasmEnableThreads, "Marshaling objects by reference is not supported in multithreaded mode"); |
475 | | - cwraps.SystemInteropJS_RegisterGCRoot(buffer_ptr, buffer_length, "marshal_array_to_cs"); |
476 | | - } |
477 | 456 | for (let index = 0; index < length; index++) { |
478 | 457 | const element_arg = get_arg(<any>buffer_ptr, index); |
479 | 458 | marshal_cs_object_to_cs(element_arg, value[index]); |
480 | | - }*/ |
| 459 | + } |
481 | 460 | } else if (element_type == MarshalerType.JSObject) { |
482 | 461 | dotnetAssert.check(Array.isArray(value), "Value is not an Array"); |
483 | 462 | dotnetBrowserUtilsExports.zeroRegion(buffer_ptr, buffer_length); |
|
0 commit comments