From 41bfb66891ee0993734c9718fa081172e9f668a8 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Fri, 8 Jan 2021 16:37:37 +0100 Subject: [PATCH] [browser] White space clean up. (#46743) - Fix the white space in the file to keep VSC from creating noise every time the file is touched. - Does not change any functioning code. --- src/mono/wasm/runtime/binding_support.js | 162 +++++++++++++++---------------- src/mono/wasm/runtime/dotnet_support.js | 2 +- src/mono/wasm/runtime/library_mono.js | 6 +- 3 files changed, 85 insertions(+), 85 deletions(-) diff --git a/src/mono/wasm/runtime/binding_support.js b/src/mono/wasm/runtime/binding_support.js index b9de49a..db730c0 100644 --- a/src/mono/wasm/runtime/binding_support.js +++ b/src/mono/wasm/runtime/binding_support.js @@ -34,7 +34,7 @@ var BindingSupportLib = { // avoid infinite recursion this.init = true; - + Array.prototype[Symbol.for("wasm type")] = 1; ArrayBuffer.prototype[Symbol.for("wasm type")] = 2; DataView.prototype[Symbol.for("wasm type")] = 3; @@ -68,7 +68,7 @@ var BindingSupportLib = { this.mono_wasm_try_unbox_primitive_and_get_type = Module.cwrap ('mono_wasm_try_unbox_primitive_and_get_type', 'number', ['number', 'number']); this.mono_wasm_box_primitive = Module.cwrap ('mono_wasm_box_primitive', 'number', ['number', 'number', 'number']); this.assembly_get_entry_point = Module.cwrap ('mono_wasm_assembly_get_entry_point', 'number', ['number']); - + this._box_buffer = Module._malloc(16); this._unbox_buffer = Module._malloc(16); this._class_int32 = this.find_corlib_class ("System", "Int32"); @@ -81,7 +81,7 @@ var BindingSupportLib = { var binding_fqn_asm = this.BINDING_ASM.substring(this.BINDING_ASM.indexOf ("[") + 1, this.BINDING_ASM.indexOf ("]")).trim(); var binding_fqn_class = this.BINDING_ASM.substring (this.BINDING_ASM.indexOf ("]") + 1).trim(); - + this.binding_module = this.assembly_load (binding_fqn_asm); if (!this.binding_module) throw "Can't find bindings module assembly: " + binding_fqn_asm; @@ -195,7 +195,7 @@ var BindingSupportLib = { Module._free (buffer); return result; }, - + mono_array_to_js_array: function (mono_array) { if (mono_array === 0) return null; @@ -211,8 +211,8 @@ var BindingSupportLib = { _mono_array_to_js_array_rooted: function (arrayRoot) { if (arrayRoot.value === 0) return null; - - let elemRoot = MONO.mono_wasm_new_root (); + + let elemRoot = MONO.mono_wasm_new_root (); try { var len = this.mono_array_length (arrayRoot.value); @@ -220,7 +220,7 @@ var BindingSupportLib = { for (var i = 0; i < len; ++i) { elemRoot.value = this.mono_array_get (arrayRoot.value, i); - + if (this.is_nested_array (elemRoot.value)) res[i] = this._mono_array_to_js_array_rooted (elemRoot); else @@ -236,7 +236,7 @@ var BindingSupportLib = { js_array_to_mono_array: function (js_array) { var mono_array = this.mono_obj_array_new (js_array.length); let [arrayRoot, elemRoot] = MONO.mono_wasm_new_roots ([mono_array, 0]); - + try { for (var i = 0; i < js_array.length; ++i) { elemRoot.value = this.js_to_mono_obj (js_array [i]); @@ -322,15 +322,15 @@ var BindingSupportLib = { case 7: // ref type return this.extract_js_obj (mono_obj); case 10: // arrays - case 11: - case 12: - case 13: - case 14: - case 15: - case 16: - case 17: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: case 18: - throw new Error ("Marshalling of primitive arrays are not supported. Use the corresponding TypedArray instead."); + throw new Error ("Marshalling of primitive arrays are not supported. Use the corresponding TypedArray instead."); case 20: // clr .NET DateTime var dateValue = this.call_method(this.get_date_value, null, "md", [ mono_obj ]); return new Date(dateValue); @@ -351,7 +351,7 @@ var BindingSupportLib = { var mono_obj = root.value; if (mono_obj === 0) return undefined; - + var type = this.mono_wasm_try_unbox_primitive_and_get_type (mono_obj, this._unbox_buffer); switch (type) { case 1: // int @@ -422,15 +422,15 @@ var BindingSupportLib = { this.bindings_lazy_init (); // determines if the javascript object is a Promise or Promise like which can happen - // when using an external Promise library. The javascript object should be marshalled + // when using an external Promise library. The javascript object should be marshalled // as managed Task objects. - // - // Example is when Bluebird is included in a web page using a script tag, it overwrites the + // + // Example is when Bluebird is included in a web page using a script tag, it overwrites the // global Promise object by default with its own version of Promise. function isThenable() { // When using an external Promise library the Promise.resolve may not be sufficient // to identify the object as a Promise. - return Promise.resolve(js_obj) === js_obj || + return Promise.resolve(js_obj) === js_obj || ((typeof js_obj === "object" || typeof js_obj === "function") && typeof js_obj.then === "function") } @@ -445,7 +445,7 @@ var BindingSupportLib = { result = this._box_js_uint (js_obj); else result = this._box_js_double (js_obj); - + if (!result) throw new Error (`Boxing failed for ${js_obj}`); @@ -495,12 +495,12 @@ var BindingSupportLib = { js_typed_array_to_array : function (js_obj) { - // JavaScript typed arrays are array-like objects and provide a mechanism for accessing - // raw binary data. (...) To achieve maximum flexibility and efficiency, JavaScript typed arrays + // JavaScript typed arrays are array-like objects and provide a mechanism for accessing + // raw binary data. (...) To achieve maximum flexibility and efficiency, JavaScript typed arrays // split the implementation into buffers and views. A buffer (implemented by the ArrayBuffer object) - // is an object representing a chunk of data; it has no format to speak of, and offers no - // mechanism for accessing its contents. In order to access the memory contained in a buffer, - // you need to use a view. A view provides a context — that is, a data type, starting offset, + // is an object representing a chunk of data; it has no format to speak of, and offers no + // mechanism for accessing its contents. In order to access the memory contained in a buffer, + // you need to use a view. A view provides a context — that is, a data type, starting offset, // and number of elements — that turns the data into an actual typed array. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays if (!!(this.has_backing_array_buffer(js_obj) && js_obj.BYTES_PER_ELEMENT)) @@ -513,7 +513,7 @@ var BindingSupportLib = { } else { throw new Error("Object '" + js_obj + "' is not a typed array"); - } + } }, @@ -521,12 +521,12 @@ var BindingSupportLib = { // typed array memory -> copy to heap -> address of managed pinned array typedarray_copy_to : function (typed_array, pinned_array, begin, end, bytes_per_element) { - // JavaScript typed arrays are array-like objects and provide a mechanism for accessing - // raw binary data. (...) To achieve maximum flexibility and efficiency, JavaScript typed arrays + // JavaScript typed arrays are array-like objects and provide a mechanism for accessing + // raw binary data. (...) To achieve maximum flexibility and efficiency, JavaScript typed arrays // split the implementation into buffers and views. A buffer (implemented by the ArrayBuffer object) - // is an object representing a chunk of data; it has no format to speak of, and offers no - // mechanism for accessing its contents. In order to access the memory contained in a buffer, - // you need to use a view. A view provides a context — that is, a data type, starting offset, + // is an object representing a chunk of data; it has no format to speak of, and offers no + // mechanism for accessing its contents. In order to access the memory contained in a buffer, + // you need to use a view. A view provides a context — that is, a data type, starting offset, // and number of elements — that turns the data into an actual typed array. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays if (!!(this.has_backing_array_buffer(typed_array) && typed_array.BYTES_PER_ELEMENT)) @@ -557,19 +557,19 @@ var BindingSupportLib = { } else { throw new Error("Object '" + typed_array + "' is not a typed array"); - } + } - }, + }, // Copy the pinned array address from pinned_array allocated on the heap to the typed array. // adress of managed pinned array -> copy from heap -> typed array memory typedarray_copy_from : function (typed_array, pinned_array, begin, end, bytes_per_element) { - // JavaScript typed arrays are array-like objects and provide a mechanism for accessing - // raw binary data. (...) To achieve maximum flexibility and efficiency, JavaScript typed arrays + // JavaScript typed arrays are array-like objects and provide a mechanism for accessing + // raw binary data. (...) To achieve maximum flexibility and efficiency, JavaScript typed arrays // split the implementation into buffers and views. A buffer (implemented by the ArrayBuffer object) - // is an object representing a chunk of data; it has no format to speak of, and offers no - // mechanism for accessing its contents. In order to access the memory contained in a buffer, - // you need to use a view. A view provides a context — that is, a data type, starting offset, + // is an object representing a chunk of data; it has no format to speak of, and offers no + // mechanism for accessing its contents. In order to access the memory contained in a buffer, + // you need to use a view. A view provides a context — that is, a data type, starting offset, // and number of elements — that turns the data into an actual typed array. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays if (!!(this.has_backing_array_buffer(typed_array) && typed_array.BYTES_PER_ELEMENT)) @@ -598,9 +598,9 @@ var BindingSupportLib = { } else { throw new Error("Object '" + typed_array + "' is not a typed array"); - } + } - }, + }, // Creates a new typed array from pinned array address from pinned_array allocated on the heap to the typed array. // adress of managed pinned array -> copy from heap -> typed array memory typed_array_from : function (pinned_array, begin, end, bytes_per_element, type) { @@ -610,25 +610,25 @@ var BindingSupportLib = { switch (type) { - case 5: + case 5: newTypedArray = new Int8Array(end - begin); break; - case 6: + case 6: newTypedArray = new Uint8Array(end - begin); break; - case 7: + case 7: newTypedArray = new Int16Array(end - begin); break; - case 8: + case 8: newTypedArray = new Uint16Array(end - begin); break; - case 9: + case 9: newTypedArray = new Int32Array(end - begin); break; - case 10: + case 10: newTypedArray = new Uint32Array(end - begin); break; - case 13: + case 13: newTypedArray = new Float32Array(end - begin); break; case 14: @@ -644,10 +644,10 @@ var BindingSupportLib = { }, js_to_mono_enum: function (js_obj, method, parmIdx) { this.bindings_lazy_init (); - + if (typeof (js_obj) !== "number") throw new Error (`Expected numeric value for enum argument, got '${js_obj}'`); - + return js_obj | 0; }, wasm_binding_obj_new: function (js_obj_id, ownsHandle, type) @@ -787,9 +787,9 @@ var BindingSupportLib = { var lineBreakRE = /\r(\n?)/g; - rawFunctionText = - uriPrefix + strictPrefix + - rawFunctionText.replace(lineBreakRE, "\r\n ") + + rawFunctionText = + uriPrefix + strictPrefix + + rawFunctionText.replace(lineBreakRE, "\r\n ") + ` return ${escapedFunctionIdentifier};\r\n`; var result = null, keys = null; @@ -863,8 +863,8 @@ var BindingSupportLib = { size += conv.size; } - return { - steps: steps, size: size, args_marshal: args_marshal, + return { + steps: steps, size: size, args_marshal: args_marshal, is_result_definitely_unmarshaled: is_result_definitely_unmarshaled, is_result_possibly_unmarshaled: is_result_possibly_unmarshaled, result_unmarshaled_if_argc: result_unmarshaled_if_argc, @@ -895,7 +895,7 @@ var BindingSupportLib = { var converterName = args_marshal.replace("!", "_result_unmarshaled"); converter.name = converterName; - + var body = []; var argumentNames = ["buffer", "rootBuffer", "method"]; @@ -991,10 +991,10 @@ var BindingSupportLib = { for (let i = 0; i < converter.steps.length; i++) { body.push( - " args[" + i + + " args[" + i + ( - (i == converter.steps.length - 1) - ? "]" + (i == converter.steps.length - 1) + ? "]" : "], " ) ); @@ -1035,7 +1035,7 @@ var BindingSupportLib = { _get_buffer_for_method_call: function (converter) { if (!converter) return 0; - + var result = converter.scratchBuffer; converter.scratchBuffer = 0; return result; @@ -1109,7 +1109,7 @@ var BindingSupportLib = { return true; if ( - converter.is_result_possibly_unmarshaled && + converter.is_result_possibly_unmarshaled && (argc === converter.result_unmarshaled_if_argc) ) { if (argc < converter.result_unmarshaled_if_argc) @@ -1130,7 +1130,7 @@ var BindingSupportLib = { i: int32 j: int32 - Enum with underlying type of int32 - l: int64 + l: int64 k: int64 - Enum with underlying type of int64 f: float d: double @@ -1162,7 +1162,7 @@ var BindingSupportLib = { converter = this._compile_converter_for_marshal_string (args_marshal); is_result_marshaled = this._decide_if_result_is_marshaled (converter, args.length); - + argsRootBuffer = this._get_args_root_buffer_for_method_call (converter); var scratchBuffer = this._get_buffer_for_method_call (converter); @@ -1265,15 +1265,15 @@ var BindingSupportLib = { body.push( " " + argName + ( - (i == converter.steps.length - 1) - ? "" + (i == converter.steps.length - 1) + ? "" : ", " ) ); } body.push(");"); - + } else { body.push("var argsRootBuffer = null, buffer = 0;"); } @@ -1339,7 +1339,7 @@ var BindingSupportLib = { } var displayName = "managed_" + (friendly_name || method); - + if (this_arg) displayName += "_with_this_" + this_arg; @@ -1376,10 +1376,10 @@ var BindingSupportLib = { MONO.mono_wasm_release_roots (delegateRoot, argsRoot); } }, - + resolve_method_fqn: function (fqn) { this.bindings_lazy_init (); - + var assembly = fqn.substring(fqn.indexOf ("[") + 1, fqn.indexOf ("]")).trim(); fqn = fqn.substring (fqn.indexOf ("]") + 1).trim(); @@ -1436,7 +1436,7 @@ var BindingSupportLib = { return BINDING.bind_method (method, null, signature, fqn); }, - + bind_assembly_entry_point: function (assembly) { this.bindings_lazy_init (); @@ -1476,7 +1476,7 @@ var BindingSupportLib = { mono_wasm_register_obj: function(obj) { var gc_handle = undefined; - if (obj !== null && typeof obj !== "undefined") + if (obj !== null && typeof obj !== "undefined") { gc_handle = obj.__mono_gchandle__; @@ -1489,7 +1489,7 @@ var BindingSupportLib = { obj.__owns_handle__ = true; gc_handle = obj.__mono_gchandle__ = this.wasm_binding_obj_new(handle + 1, obj.__owns_handle__, typeof wasm_type === "undefined" ? -1 : wasm_type); this.mono_wasm_object_registry[handle] = obj; - + } } return gc_handle; @@ -1634,7 +1634,7 @@ var BindingSupportLib = { var m = obj [js_name]; if (m === Object(m) && obj.__is_mono_proxied__) m.__is_mono_proxied__ = true; - + return BINDING.js_to_mono_obj (m); } catch (e) { var res = e.toString (); @@ -1686,7 +1686,7 @@ var BindingSupportLib = { requireObject[property] = js_value; result = true; } - + } BINDING.mono_wasm_unwind_LMF(); return BINDING._box_js_bool (result); @@ -1760,12 +1760,12 @@ var BindingSupportLib = { BINDING.bindings_lazy_init (); BINDING.mono_wasm_free_handle(js_handle); - }, + }, mono_wasm_release_object: function(js_handle, is_exception) { BINDING.bindings_lazy_init (); BINDING.mono_wasm_free_raw_object(js_handle); - }, + }, mono_wasm_bind_core_object: function(js_handle, gc_handle, is_exception) { BINDING.bindings_lazy_init (); @@ -1811,9 +1811,9 @@ var BindingSupportLib = { } var js_args = BINDING.mono_wasm_parse_args(args); - + try { - + // This is all experimental !!!!!! var allocator = function(constructor, js_args) { // Not sure if we should be checking for anything here @@ -1825,7 +1825,7 @@ var BindingSupportLib = { var obj = new tempCtor (); return obj; }; - + var res = allocator(coreObj, js_args); var gc_handle = BINDING.mono_wasm_free_list.length ? BINDING.mono_wasm_free_list.pop() : BINDING.mono_wasm_ref_counter++; BINDING.mono_wasm_object_registry[gc_handle] = res; @@ -1836,7 +1836,7 @@ var BindingSupportLib = { if (res === null || res === undefined) res = "Error allocating object."; return BINDING.js_string_to_mono_string (res); - } + } }, diff --git a/src/mono/wasm/runtime/dotnet_support.js b/src/mono/wasm/runtime/dotnet_support.js index c780db5..3272b71 100644 --- a/src/mono/wasm/runtime/dotnet_support.js +++ b/src/mono/wasm/runtime/dotnet_support.js @@ -86,7 +86,7 @@ var DotNetSupportLib = { return 0; } } - + }; diff --git a/src/mono/wasm/runtime/library_mono.js b/src/mono/wasm/runtime/library_mono.js index cc8fd0f..43f76bf 100644 --- a/src/mono/wasm/runtime/library_mono.js +++ b/src/mono/wasm/runtime/library_mono.js @@ -389,7 +389,7 @@ var MonoSupportLib = { throw new Error ("capacity >= 1"); capacity = capacity | 0; - + var capacityBytes = capacity * 4; if ((offset % 4) !== 0) throw new Error ("Unaligned offset"); @@ -399,7 +399,7 @@ var MonoSupportLib = { var result = Object.create (this._mono_wasm_root_buffer_prototype); result.__offset = offset; result.__offset32 = (offset / 4) | 0; - result.__count = capacity; + result.__count = capacity; result.length = capacity; result.__handle = this.mono_wasm_register_root (offset, capacityBytes, msg || 0); result.__ownsAllocation = false; @@ -424,7 +424,7 @@ var MonoSupportLib = { } else { var index = this._mono_wasm_claim_scratch_index (); var buffer = this._scratch_root_buffer; - + result = Object.create (this._mono_wasm_root_prototype); result.__buffer = buffer; result.__index = index; -- 2.7.4