@digicatapult/dtdl-parser 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/interop/_framework/DTDLParserJSInterop.pdb +0 -0
- package/build/interop/_framework/DTDLParserJSInterop.wasm +0 -0
- package/build/interop/_framework/blazor.boot.json +3 -3
- package/package.json +4 -5
- package/.depcheckrc +0 -6
- package/.github/CODEOWNERS +0 -4
- package/.github/workflows/release.yml +0 -198
- package/.github/workflows/test.yml +0 -92
- package/.gitignore +0 -4
- package/.prettierrc +0 -9
- package/.swcrc +0 -32
- package/dtdl/error/error.json +0 -11
- package/dtdl/simple/simple.json +0 -9
- package/eslint.config.mjs +0 -52
- package/src/__tests__/fixtures/empty.json +0 -1
- package/src/__tests__/fixtures/nested/nested.json +0 -1
- package/src/__tests__/index.test.ts +0 -119
- package/src/error.ts +0 -25
- package/src/index.ts +0 -134
- package/src/interop/DTDLParserJSInterop.csproj +0 -26
- package/src/interop/LICENSE +0 -21
- package/src/interop/ModelParserInterop.cs +0 -19
- package/src/interop/README.md +0 -1
- package/src/interop/bin/Release/net8.0/browser-wasm/DTDLParser.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/DTDLParserJSInterop.deps.json +0 -921
- package/src/interop/bin/Release/net8.0/browser-wasm/DTDLParserJSInterop.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/DTDLParserJSInterop.pdb +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/DTDLParserJSInterop.runtimeconfig.json +0 -40
- package/src/interop/bin/Release/net8.0/browser-wasm/Microsoft.CSharp.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/Microsoft.VisualBasic.Core.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/Microsoft.VisualBasic.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/Microsoft.Win32.Primitives.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/Microsoft.Win32.Registry.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.AppContext.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Buffers.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Collections.Concurrent.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Collections.Immutable.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Collections.NonGeneric.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Collections.Specialized.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Collections.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.ComponentModel.Annotations.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.ComponentModel.DataAnnotations.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.ComponentModel.EventBasedAsync.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.ComponentModel.Primitives.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.ComponentModel.TypeConverter.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.ComponentModel.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Configuration.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Console.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Core.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Data.Common.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Data.DataSetExtensions.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Data.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Diagnostics.Contracts.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Diagnostics.Debug.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Diagnostics.DiagnosticSource.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Diagnostics.FileVersionInfo.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Diagnostics.Process.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Diagnostics.StackTrace.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Diagnostics.TextWriterTraceListener.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Diagnostics.Tools.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Diagnostics.TraceSource.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Diagnostics.Tracing.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Drawing.Primitives.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Drawing.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Dynamic.Runtime.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Formats.Asn1.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Formats.Tar.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Globalization.Calendars.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Globalization.Extensions.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Globalization.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.IO.Compression.Brotli.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.IO.Compression.FileSystem.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.IO.Compression.ZipFile.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.IO.Compression.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.IO.FileSystem.AccessControl.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.IO.FileSystem.DriveInfo.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.IO.FileSystem.Primitives.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.IO.FileSystem.Watcher.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.IO.FileSystem.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.IO.IsolatedStorage.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.IO.MemoryMappedFiles.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.IO.Pipes.AccessControl.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.IO.Pipes.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.IO.UnmanagedMemoryStream.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.IO.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Linq.Expressions.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Linq.Parallel.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Linq.Queryable.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Linq.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Memory.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Net.Http.Json.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Net.Http.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Net.HttpListener.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Net.Mail.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Net.NameResolution.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Net.NetworkInformation.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Net.Ping.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Net.Primitives.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Net.Quic.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Net.Requests.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Net.Security.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Net.ServicePoint.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Net.Sockets.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Net.WebClient.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Net.WebHeaderCollection.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Net.WebProxy.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Net.WebSockets.Client.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Net.WebSockets.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Net.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Numerics.Vectors.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Numerics.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.ObjectModel.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Private.CoreLib.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Private.DataContractSerialization.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Private.Uri.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Private.Xml.Linq.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Private.Xml.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Reflection.DispatchProxy.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Reflection.Emit.ILGeneration.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Reflection.Emit.Lightweight.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Reflection.Emit.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Reflection.Extensions.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Reflection.Metadata.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Reflection.Primitives.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Reflection.TypeExtensions.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Reflection.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Resources.Reader.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Resources.ResourceManager.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Resources.Writer.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Runtime.CompilerServices.Unsafe.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Runtime.CompilerServices.VisualC.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Runtime.Extensions.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Runtime.Handles.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Runtime.InteropServices.JavaScript.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Runtime.InteropServices.RuntimeInformation.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Runtime.InteropServices.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Runtime.Intrinsics.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Runtime.Loader.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Runtime.Numerics.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Runtime.Serialization.Formatters.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Runtime.Serialization.Json.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Runtime.Serialization.Primitives.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Runtime.Serialization.Xml.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Runtime.Serialization.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Runtime.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Security.AccessControl.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Security.Claims.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Security.Cryptography.Algorithms.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Security.Cryptography.Cng.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Security.Cryptography.Csp.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Security.Cryptography.Encoding.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Security.Cryptography.OpenSsl.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Security.Cryptography.Primitives.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Security.Cryptography.X509Certificates.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Security.Cryptography.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Security.Principal.Windows.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Security.Principal.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Security.SecureString.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Security.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.ServiceModel.Web.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.ServiceProcess.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Text.Encoding.CodePages.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Text.Encoding.Extensions.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Text.Encoding.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Text.Encodings.Web.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Text.Json.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Text.RegularExpressions.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Threading.Channels.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Threading.Overlapped.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Threading.Tasks.Dataflow.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Threading.Tasks.Extensions.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Threading.Tasks.Parallel.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Threading.Tasks.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Threading.Thread.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Threading.ThreadPool.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Threading.Timer.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Threading.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Transactions.Local.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Transactions.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.ValueTuple.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Web.HttpUtility.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Web.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Windows.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Xml.Linq.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Xml.ReaderWriter.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Xml.Serialization.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Xml.XDocument.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Xml.XPath.XDocument.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Xml.XPath.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Xml.XmlDocument.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Xml.XmlSerializer.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.Xml.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/System.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/WindowsBase.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/corebindings.c +0 -104
- package/src/interop/bin/Release/net8.0/browser-wasm/dotnet-legacy.d.ts +0 -295
- package/src/interop/bin/Release/net8.0/browser-wasm/dotnet.d.ts +0 -472
- package/src/interop/bin/Release/net8.0/browser-wasm/dotnet.es6.extpost.js +0 -2
- package/src/interop/bin/Release/net8.0/browser-wasm/dotnet.es6.lib.js +0 -163
- package/src/interop/bin/Release/net8.0/browser-wasm/dotnet.es6.pre.js +0 -5
- package/src/interop/bin/Release/net8.0/browser-wasm/dotnet.js +0 -4
- package/src/interop/bin/Release/net8.0/browser-wasm/dotnet.js.map +0 -1
- package/src/interop/bin/Release/net8.0/browser-wasm/dotnet.native.js +0 -17
- package/src/interop/bin/Release/net8.0/browser-wasm/dotnet.native.js.symbols +0 -8582
- package/src/interop/bin/Release/net8.0/browser-wasm/dotnet.native.wasm +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/dotnet.runtime.js +0 -4
- package/src/interop/bin/Release/net8.0/browser-wasm/dotnet.runtime.js.map +0 -1
- package/src/interop/bin/Release/net8.0/browser-wasm/driver.c +0 -1391
- package/src/interop/bin/Release/net8.0/browser-wasm/emcc-default.rsp +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/emcc-link.rsp +0 -16
- package/src/interop/bin/Release/net8.0/browser-wasm/emcc-props.json +0 -14
- package/src/interop/bin/Release/net8.0/browser-wasm/gc-common.h +0 -73
- package/src/interop/bin/Release/net8.0/browser-wasm/icudt.dat +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/icudt_CJK.dat +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/icudt_EFIGS.dat +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/icudt_hybrid.dat +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/icudt_no_CJK.dat +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/libSystem.Globalization.Native.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/libSystem.IO.Compression.Native.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/libSystem.Native.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/libicudata.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/libicui18n.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/libicuuc.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/libmono-component-debugger-static.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/libmono-component-debugger-stub-static.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/libmono-component-diagnostics_tracing-static.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/libmono-component-diagnostics_tracing-stub-static.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/libmono-component-hot_reload-static.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/libmono-component-hot_reload-stub-static.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/libmono-component-marshal-ilgen-static.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/libmono-component-marshal-ilgen-stub-static.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/libmono-ee-interp.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/libmono-icall-table.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/libmono-profiler-aot.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/libmono-profiler-browser.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/libmono-wasm-eh-js.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/libmono-wasm-eh-wasm.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/libmono-wasm-nosimd.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/libmono-wasm-simd.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/libmonosgen-2.0.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/mscorlib.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/netstandard.dll +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/package.json +0 -44
- package/src/interop/bin/Release/net8.0/browser-wasm/pal_random.lib.js +0 -45
- package/src/interop/bin/Release/net8.0/browser-wasm/pinvoke.c +0 -62
- package/src/interop/bin/Release/net8.0/browser-wasm/pinvoke.h +0 -50
- package/src/interop/bin/Release/net8.0/browser-wasm/runtimeconfig.bin +0 -1
- package/src/interop/bin/Release/net8.0/browser-wasm/wasm-bundled-timezones.a +0 -0
- package/src/interop/bin/Release/net8.0/browser-wasm/wasm-config.h +0 -13
- package/src/interop/modelParser.js +0 -11
- package/src/interop/obj/DTDLParserJSInterop.csproj.nuget.dgspec.json +0 -83
- package/src/interop/obj/DTDLParserJSInterop.csproj.nuget.g.props +0 -21
- package/src/interop/obj/DTDLParserJSInterop.csproj.nuget.g.targets +0 -6
- package/src/interop/obj/Release/net8.0/browser-wasm/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +0 -4
- package/src/interop/obj/Release/net8.0/browser-wasm/DTDLPars.F465EEA8.Up2Date +0 -0
- package/src/interop/obj/Release/net8.0/browser-wasm/DTDLParserJSInterop.AssemblyInfo.cs +0 -22
- package/src/interop/obj/Release/net8.0/browser-wasm/DTDLParserJSInterop.AssemblyInfoInputs.cache +0 -1
- package/src/interop/obj/Release/net8.0/browser-wasm/DTDLParserJSInterop.GeneratedMSBuildEditorConfig.editorconfig +0 -17
- package/src/interop/obj/Release/net8.0/browser-wasm/DTDLParserJSInterop.assets.cache +0 -0
- package/src/interop/obj/Release/net8.0/browser-wasm/DTDLParserJSInterop.csproj.AssemblyReference.cache +0 -0
- package/src/interop/obj/Release/net8.0/browser-wasm/DTDLParserJSInterop.csproj.CoreCompileInputs.cache +0 -1
- package/src/interop/obj/Release/net8.0/browser-wasm/DTDLParserJSInterop.csproj.FileListAbsolute.txt +0 -237
- package/src/interop/obj/Release/net8.0/browser-wasm/DTDLParserJSInterop.dll +0 -0
- package/src/interop/obj/Release/net8.0/browser-wasm/DTDLParserJSInterop.genruntimeconfig.cache +0 -1
- package/src/interop/obj/Release/net8.0/browser-wasm/DTDLParserJSInterop.pdb +0 -0
- package/src/interop/obj/Release/net8.0/browser-wasm/DTDLParserJSInterop.sourcelink.json +0 -1
- package/src/interop/obj/Release/net8.0/browser-wasm/ref/DTDLParserJSInterop.dll +0 -0
- package/src/interop/obj/Release/net8.0/browser-wasm/refint/DTDLParserJSInterop.dll +0 -0
- package/src/interop/obj/Release/net8.0/browser-wasm/wasm/for-build/corebindings.o +0 -0
- package/src/interop/obj/Release/net8.0/browser-wasm/wasm/for-build/dotnet.native.js +0 -17
- package/src/interop/obj/Release/net8.0/browser-wasm/wasm/for-build/dotnet.native.wasm +0 -0
- package/src/interop/obj/Release/net8.0/browser-wasm/wasm/for-build/driver.o +0 -0
- package/src/interop/obj/Release/net8.0/browser-wasm/wasm/for-build/emcc-compile.rsp +0 -12
- package/src/interop/obj/Release/net8.0/browser-wasm/wasm/for-build/emcc-link.rsp +0 -38
- package/src/interop/obj/Release/net8.0/browser-wasm/wasm/for-build/icall-table.h +0 -1653
- package/src/interop/obj/Release/net8.0/browser-wasm/wasm/for-build/m2n_cache.txt +0 -3
- package/src/interop/obj/Release/net8.0/browser-wasm/wasm/for-build/pinvoke-table.h +0 -329
- package/src/interop/obj/Release/net8.0/browser-wasm/wasm/for-build/pinvoke.o +0 -0
- package/src/interop/obj/Release/net8.0/browser-wasm/wasm/for-build/runtime-icall-table.h +0 -449
- package/src/interop/obj/Release/net8.0/browser-wasm/wasm/for-build/wasm_m2n_invoke.g.h +0 -522
- package/src/interop/obj/project.assets.json +0 -384
- package/src/interop/obj/project.nuget.cache +0 -13
- package/src/interop/runtimeconfig.template.json +0 -11
- package/src/interop.ts +0 -9
- package/test/mocharc.json +0 -6
- package/tsconfig.json +0 -31
- package/types/DtdlErr.d.ts +0 -26
- package/types/DtdlOm.d.ts +0 -372
|
@@ -1,1391 +0,0 @@
|
|
|
1
|
-
// Licensed to the .NET Foundation under one or more agreements.
|
|
2
|
-
// The .NET Foundation licenses this file to you under the MIT license.
|
|
3
|
-
#include <emscripten.h>
|
|
4
|
-
#include <emscripten/stack.h>
|
|
5
|
-
#include <stdio.h>
|
|
6
|
-
#include <stddef.h>
|
|
7
|
-
#include <stdlib.h>
|
|
8
|
-
#include <string.h>
|
|
9
|
-
#include <stdint.h>
|
|
10
|
-
#include <assert.h>
|
|
11
|
-
#include <math.h>
|
|
12
|
-
#include <dlfcn.h>
|
|
13
|
-
#include <sys/stat.h>
|
|
14
|
-
|
|
15
|
-
#include <mono/metadata/appdomain.h>
|
|
16
|
-
#include <mono/metadata/assembly.h>
|
|
17
|
-
#include <mono/metadata/class.h>
|
|
18
|
-
#include <mono/metadata/tokentype.h>
|
|
19
|
-
#include <mono/metadata/threads.h>
|
|
20
|
-
#include <mono/metadata/image.h>
|
|
21
|
-
#include <mono/metadata/loader.h>
|
|
22
|
-
#include <mono/metadata/mono-gc.h>
|
|
23
|
-
#include <mono/metadata/object.h>
|
|
24
|
-
#include <mono/metadata/debug-helpers.h>
|
|
25
|
-
// FIXME: unavailable in emscripten
|
|
26
|
-
// #include <mono/metadata/gc-internals.h>
|
|
27
|
-
|
|
28
|
-
#include <mono/metadata/mono-private-unstable.h>
|
|
29
|
-
|
|
30
|
-
#include <mono/utils/mono-logger.h>
|
|
31
|
-
#include <mono/utils/mono-dl-fallback.h>
|
|
32
|
-
#include <mono/jit/jit.h>
|
|
33
|
-
#include <mono/jit/mono-private-unstable.h>
|
|
34
|
-
|
|
35
|
-
#include "wasm-config.h"
|
|
36
|
-
#include "pinvoke.h"
|
|
37
|
-
|
|
38
|
-
#ifdef GEN_PINVOKE
|
|
39
|
-
#include "wasm_m2n_invoke.g.h"
|
|
40
|
-
#endif
|
|
41
|
-
#include "gc-common.h"
|
|
42
|
-
|
|
43
|
-
void bindings_initialize_internals ();
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
void mono_wasm_enable_debugging (int);
|
|
47
|
-
void mono_ee_interp_init (const char *opts);
|
|
48
|
-
void mono_marshal_ilgen_init (void);
|
|
49
|
-
void mono_method_builder_ilgen_init (void);
|
|
50
|
-
void mono_sgen_mono_ilgen_init (void);
|
|
51
|
-
void mono_icall_table_init (void);
|
|
52
|
-
char *monoeg_g_getenv(const char *variable);
|
|
53
|
-
int monoeg_g_setenv(const char *variable, const char *value, int overwrite);
|
|
54
|
-
int32_t mini_parse_debug_option (const char *option);
|
|
55
|
-
char *mono_method_get_full_name (MonoMethod *method);
|
|
56
|
-
|
|
57
|
-
#ifndef INVARIANT_TIMEZONE
|
|
58
|
-
extern void mono_register_timezones_bundle (void);
|
|
59
|
-
#endif /* INVARIANT_TIMEZONE */
|
|
60
|
-
extern void mono_wasm_set_entrypoint_breakpoint (const char* assembly_name, int method_token);
|
|
61
|
-
static void mono_wasm_init_finalizer_thread (void);
|
|
62
|
-
|
|
63
|
-
extern void mono_bundled_resources_add_assembly_resource (const char *id, const char *name, const uint8_t *data, uint32_t size, void (*free_func)(void *, void*), void *free_data);
|
|
64
|
-
extern void mono_bundled_resources_add_assembly_symbol_resource (const char *id, const uint8_t *data, uint32_t size, void (*free_func)(void *, void *), void *free_data);
|
|
65
|
-
extern void mono_bundled_resources_add_satellite_assembly_resource (const char *id, const char *name, const char *culture, const uint8_t *data, uint32_t size, void (*free_func)(void *, void*), void *free_data);
|
|
66
|
-
|
|
67
|
-
#ifndef DISABLE_LEGACY_JS_INTEROP
|
|
68
|
-
|
|
69
|
-
#define MARSHAL_TYPE_NULL 0
|
|
70
|
-
#define MARSHAL_TYPE_INT 1
|
|
71
|
-
#define MARSHAL_TYPE_FP64 2
|
|
72
|
-
#define MARSHAL_TYPE_STRING 3
|
|
73
|
-
#define MARSHAL_TYPE_VT 4
|
|
74
|
-
#define MARSHAL_TYPE_DELEGATE 5
|
|
75
|
-
#define MARSHAL_TYPE_TASK 6
|
|
76
|
-
#define MARSHAL_TYPE_OBJECT 7
|
|
77
|
-
#define MARSHAL_TYPE_BOOL 8
|
|
78
|
-
#define MARSHAL_TYPE_ENUM 9
|
|
79
|
-
#define MARSHAL_TYPE_DATE 20
|
|
80
|
-
#define MARSHAL_TYPE_DATEOFFSET 21
|
|
81
|
-
#define MARSHAL_TYPE_URI 22
|
|
82
|
-
#define MARSHAL_TYPE_SAFEHANDLE 23
|
|
83
|
-
|
|
84
|
-
// typed array marshaling
|
|
85
|
-
#define MARSHAL_ARRAY_BYTE 10
|
|
86
|
-
#define MARSHAL_ARRAY_UBYTE 11
|
|
87
|
-
#define MARSHAL_ARRAY_UBYTE_C 12
|
|
88
|
-
#define MARSHAL_ARRAY_SHORT 13
|
|
89
|
-
#define MARSHAL_ARRAY_USHORT 14
|
|
90
|
-
#define MARSHAL_ARRAY_INT 15
|
|
91
|
-
#define MARSHAL_ARRAY_UINT 16
|
|
92
|
-
#define MARSHAL_ARRAY_FLOAT 17
|
|
93
|
-
#define MARSHAL_ARRAY_DOUBLE 18
|
|
94
|
-
|
|
95
|
-
#define MARSHAL_TYPE_FP32 24
|
|
96
|
-
#define MARSHAL_TYPE_UINT32 25
|
|
97
|
-
#define MARSHAL_TYPE_INT64 26
|
|
98
|
-
#define MARSHAL_TYPE_UINT64 27
|
|
99
|
-
#define MARSHAL_TYPE_CHAR 28
|
|
100
|
-
#define MARSHAL_TYPE_STRING_INTERNED 29
|
|
101
|
-
#define MARSHAL_TYPE_VOID 30
|
|
102
|
-
#define MARSHAL_TYPE_POINTER 32
|
|
103
|
-
|
|
104
|
-
// errors
|
|
105
|
-
#define MARSHAL_ERROR_BUFFER_TOO_SMALL 512
|
|
106
|
-
#define MARSHAL_ERROR_NULL_CLASS_POINTER 513
|
|
107
|
-
#define MARSHAL_ERROR_NULL_TYPE_POINTER 514
|
|
108
|
-
|
|
109
|
-
static MonoClass* datetime_class;
|
|
110
|
-
static MonoClass* datetimeoffset_class;
|
|
111
|
-
static MonoClass* uri_class;
|
|
112
|
-
static MonoClass* task_class;
|
|
113
|
-
static MonoClass* safehandle_class;
|
|
114
|
-
static MonoClass* voidtaskresult_class;
|
|
115
|
-
|
|
116
|
-
static int resolved_datetime_class = 0,
|
|
117
|
-
resolved_datetimeoffset_class = 0,
|
|
118
|
-
resolved_uri_class = 0,
|
|
119
|
-
resolved_task_class = 0,
|
|
120
|
-
resolved_safehandle_class = 0,
|
|
121
|
-
resolved_voidtaskresult_class = 0;
|
|
122
|
-
|
|
123
|
-
#endif /* DISABLE_LEGACY_JS_INTEROP */
|
|
124
|
-
|
|
125
|
-
int mono_wasm_enable_gc = 1;
|
|
126
|
-
|
|
127
|
-
/* Not part of public headers */
|
|
128
|
-
#define MONO_ICALL_TABLE_CALLBACKS_VERSION 3
|
|
129
|
-
|
|
130
|
-
typedef struct {
|
|
131
|
-
int version;
|
|
132
|
-
void* (*lookup) (MonoMethod *method, char *classname, char *methodname, char *sigstart, int32_t *flags);
|
|
133
|
-
const char* (*lookup_icall_symbol) (void* func);
|
|
134
|
-
} MonoIcallTableCallbacks;
|
|
135
|
-
|
|
136
|
-
int
|
|
137
|
-
mono_string_instance_is_interned (MonoString *str_raw);
|
|
138
|
-
|
|
139
|
-
void
|
|
140
|
-
mono_install_icall_table_callbacks (const MonoIcallTableCallbacks *cb);
|
|
141
|
-
|
|
142
|
-
int mono_regression_test_step (int verbose_level, char *image, char *method_name);
|
|
143
|
-
void mono_trace_init (void);
|
|
144
|
-
|
|
145
|
-
#define g_new(type, size) ((type *) malloc (sizeof (type) * (size)))
|
|
146
|
-
#define g_new0(type, size) ((type *) calloc (sizeof (type), (size)))
|
|
147
|
-
|
|
148
|
-
static MonoDomain *root_domain;
|
|
149
|
-
|
|
150
|
-
#define RUNTIMECONFIG_BIN_FILE "runtimeconfig.bin"
|
|
151
|
-
|
|
152
|
-
extern void mono_wasm_trace_logger (const char *log_domain, const char *log_level, const char *message, mono_bool fatal, void *user_data);
|
|
153
|
-
|
|
154
|
-
static void
|
|
155
|
-
wasm_trace_logger (const char *log_domain, const char *log_level, const char *message, mono_bool fatal, void *user_data)
|
|
156
|
-
{
|
|
157
|
-
mono_wasm_trace_logger(log_domain, log_level, message, fatal, user_data);
|
|
158
|
-
if (fatal)
|
|
159
|
-
exit (1);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
typedef uint32_t target_mword;
|
|
163
|
-
typedef target_mword SgenDescriptor;
|
|
164
|
-
typedef SgenDescriptor MonoGCDescriptor;
|
|
165
|
-
MONO_API int mono_gc_register_root (char *start, size_t size, MonoGCDescriptor descr, MonoGCRootSource source, void *key, const char *msg);
|
|
166
|
-
void mono_gc_deregister_root (char* addr);
|
|
167
|
-
|
|
168
|
-
EMSCRIPTEN_KEEPALIVE int
|
|
169
|
-
mono_wasm_register_root (char *start, size_t size, const char *name)
|
|
170
|
-
{
|
|
171
|
-
int result;
|
|
172
|
-
MONO_ENTER_GC_UNSAFE;
|
|
173
|
-
result = mono_gc_register_root (start, size, (MonoGCDescriptor)NULL, MONO_ROOT_SOURCE_EXTERNAL, NULL, name ? name : "mono_wasm_register_root");
|
|
174
|
-
MONO_EXIT_GC_UNSAFE;
|
|
175
|
-
return result;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
EMSCRIPTEN_KEEPALIVE void
|
|
179
|
-
mono_wasm_deregister_root (char *addr)
|
|
180
|
-
{
|
|
181
|
-
MONO_ENTER_GC_UNSAFE;
|
|
182
|
-
mono_gc_deregister_root (addr);
|
|
183
|
-
MONO_EXIT_GC_UNSAFE;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
#ifdef DRIVER_GEN
|
|
187
|
-
#include "driver-gen.c"
|
|
188
|
-
#endif
|
|
189
|
-
|
|
190
|
-
static void
|
|
191
|
-
bundled_resources_free_func (void *resource, void *free_data)
|
|
192
|
-
{
|
|
193
|
-
free (free_data);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
EMSCRIPTEN_KEEPALIVE int
|
|
197
|
-
mono_wasm_add_assembly (const char *name, const unsigned char *data, unsigned int size)
|
|
198
|
-
{
|
|
199
|
-
int len = strlen (name);
|
|
200
|
-
if (!strcasecmp (".pdb", &name [len - 4])) {
|
|
201
|
-
char *new_name = strdup (name);
|
|
202
|
-
//FIXME handle debugging assemblies with .exe extension
|
|
203
|
-
strcpy (&new_name [len - 3], "dll");
|
|
204
|
-
mono_bundled_resources_add_assembly_symbol_resource (new_name, data, size, bundled_resources_free_func, new_name);
|
|
205
|
-
return 1;
|
|
206
|
-
}
|
|
207
|
-
char *assembly_name = strdup (name);
|
|
208
|
-
assert (assembly_name);
|
|
209
|
-
mono_bundled_resources_add_assembly_resource (assembly_name, assembly_name, data, size, bundled_resources_free_func, assembly_name);
|
|
210
|
-
return mono_has_pdb_checksum ((char*)data, size);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
static void
|
|
214
|
-
bundled_resources_free_slots_func (void *resource, void *free_data)
|
|
215
|
-
{
|
|
216
|
-
if (free_data) {
|
|
217
|
-
void **slots = (void **)free_data;
|
|
218
|
-
for (int i = 0; slots [i]; i++)
|
|
219
|
-
free (slots [i]);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
EMSCRIPTEN_KEEPALIVE void
|
|
224
|
-
mono_wasm_add_satellite_assembly (const char *name, const char *culture, const unsigned char *data, unsigned int size)
|
|
225
|
-
{
|
|
226
|
-
int id_len = strlen (culture) + 1 + strlen (name); // +1 is for the "/"
|
|
227
|
-
char *id = (char *)malloc (sizeof (char) * (id_len + 1)); // +1 is for the terminating null character
|
|
228
|
-
assert (id);
|
|
229
|
-
|
|
230
|
-
int num_char = snprintf (id, (id_len + 1), "%s/%s", culture, name);
|
|
231
|
-
assert (num_char > 0 && num_char == id_len);
|
|
232
|
-
|
|
233
|
-
char *satellite_assembly_name = strdup (name);
|
|
234
|
-
assert (satellite_assembly_name);
|
|
235
|
-
|
|
236
|
-
char *satellite_assembly_culture = strdup (culture);
|
|
237
|
-
assert (satellite_assembly_culture);
|
|
238
|
-
|
|
239
|
-
void **slots = malloc (sizeof (void *) * 4);
|
|
240
|
-
assert (slots);
|
|
241
|
-
slots [0] = id;
|
|
242
|
-
slots [1] = satellite_assembly_name;
|
|
243
|
-
slots [2] = satellite_assembly_culture;
|
|
244
|
-
slots [3] = NULL;
|
|
245
|
-
|
|
246
|
-
mono_bundled_resources_add_satellite_assembly_resource (id, satellite_assembly_name, satellite_assembly_culture, data, size, bundled_resources_free_slots_func, slots);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
EMSCRIPTEN_KEEPALIVE void
|
|
250
|
-
mono_wasm_setenv (const char *name, const char *value)
|
|
251
|
-
{
|
|
252
|
-
assert (name);
|
|
253
|
-
assert (value);
|
|
254
|
-
monoeg_g_setenv (strdup (name), strdup (value), 1);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
EMSCRIPTEN_KEEPALIVE char *
|
|
258
|
-
mono_wasm_getenv (const char *name)
|
|
259
|
-
{
|
|
260
|
-
return monoeg_g_getenv (name); // JS must free
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
static void *sysglobal_native_handle;
|
|
264
|
-
|
|
265
|
-
static void*
|
|
266
|
-
wasm_dl_load (const char *name, int flags, char **err, void *user_data)
|
|
267
|
-
{
|
|
268
|
-
void* handle = wasm_dl_lookup_pinvoke_table (name);
|
|
269
|
-
if (handle)
|
|
270
|
-
return handle;
|
|
271
|
-
|
|
272
|
-
if (!strcmp (name, "System.Globalization.Native"))
|
|
273
|
-
return sysglobal_native_handle;
|
|
274
|
-
|
|
275
|
-
#if WASM_SUPPORTS_DLOPEN
|
|
276
|
-
return dlopen(name, flags);
|
|
277
|
-
#endif
|
|
278
|
-
|
|
279
|
-
return NULL;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
static void*
|
|
283
|
-
wasm_dl_symbol (void *handle, const char *name, char **err, void *user_data)
|
|
284
|
-
{
|
|
285
|
-
if (handle == sysglobal_native_handle)
|
|
286
|
-
assert (0);
|
|
287
|
-
|
|
288
|
-
#if WASM_SUPPORTS_DLOPEN
|
|
289
|
-
if (!wasm_dl_is_pinvoke_tables (handle)) {
|
|
290
|
-
return dlsym (handle, name);
|
|
291
|
-
}
|
|
292
|
-
#endif
|
|
293
|
-
|
|
294
|
-
PinvokeImport *table = (PinvokeImport*)handle;
|
|
295
|
-
for (int i = 0; table [i].name; ++i) {
|
|
296
|
-
if (!strcmp (table [i].name, name))
|
|
297
|
-
return table [i].func;
|
|
298
|
-
}
|
|
299
|
-
return NULL;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
#if !defined(ENABLE_AOT) || defined(EE_MODE_LLVMONLY_INTERP)
|
|
303
|
-
#define NEED_INTERP 1
|
|
304
|
-
#ifndef LINK_ICALLS
|
|
305
|
-
// FIXME: llvm+interp mode needs this to call icalls
|
|
306
|
-
#define NEED_NORMAL_ICALL_TABLES 1
|
|
307
|
-
#endif
|
|
308
|
-
#endif
|
|
309
|
-
|
|
310
|
-
#ifdef LINK_ICALLS
|
|
311
|
-
|
|
312
|
-
#include "icall-table.h"
|
|
313
|
-
|
|
314
|
-
static int
|
|
315
|
-
compare_int (const void *k1, const void *k2)
|
|
316
|
-
{
|
|
317
|
-
return *(int*)k1 - *(int*)k2;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
static void*
|
|
321
|
-
icall_table_lookup (MonoMethod *method, char *classname, char *methodname, char *sigstart, int32_t *out_flags)
|
|
322
|
-
{
|
|
323
|
-
uint32_t token = mono_method_get_token (method);
|
|
324
|
-
assert (token);
|
|
325
|
-
assert ((token & MONO_TOKEN_METHOD_DEF) == MONO_TOKEN_METHOD_DEF);
|
|
326
|
-
uint32_t token_idx = token - MONO_TOKEN_METHOD_DEF;
|
|
327
|
-
|
|
328
|
-
int *indexes = NULL;
|
|
329
|
-
int indexes_size = 0;
|
|
330
|
-
uint8_t *flags = NULL;
|
|
331
|
-
void **funcs = NULL;
|
|
332
|
-
|
|
333
|
-
*out_flags = 0;
|
|
334
|
-
|
|
335
|
-
const char *image_name = mono_image_get_name (mono_class_get_image (mono_method_get_class (method)));
|
|
336
|
-
|
|
337
|
-
#if defined(ICALL_TABLE_corlib)
|
|
338
|
-
if (!strcmp (image_name, "System.Private.CoreLib")) {
|
|
339
|
-
indexes = corlib_icall_indexes;
|
|
340
|
-
indexes_size = sizeof (corlib_icall_indexes) / 4;
|
|
341
|
-
flags = corlib_icall_flags;
|
|
342
|
-
funcs = corlib_icall_funcs;
|
|
343
|
-
assert (sizeof (corlib_icall_indexes [0]) == 4);
|
|
344
|
-
}
|
|
345
|
-
#endif
|
|
346
|
-
#ifdef ICALL_TABLE_System
|
|
347
|
-
if (!strcmp (image_name, "System")) {
|
|
348
|
-
indexes = System_icall_indexes;
|
|
349
|
-
indexes_size = sizeof (System_icall_indexes) / 4;
|
|
350
|
-
flags = System_icall_flags;
|
|
351
|
-
funcs = System_icall_funcs;
|
|
352
|
-
}
|
|
353
|
-
#endif
|
|
354
|
-
assert (indexes);
|
|
355
|
-
|
|
356
|
-
void *p = bsearch (&token_idx, indexes, indexes_size, 4, compare_int);
|
|
357
|
-
if (!p) {
|
|
358
|
-
return NULL;
|
|
359
|
-
printf ("wasm: Unable to lookup icall: %s\n", mono_method_get_name (method));
|
|
360
|
-
exit (1);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
uint32_t idx = (int*)p - indexes;
|
|
364
|
-
*out_flags = flags [idx];
|
|
365
|
-
|
|
366
|
-
//printf ("ICALL: %s %x %d %d\n", methodname, token, idx, (int)(funcs [idx]));
|
|
367
|
-
|
|
368
|
-
return funcs [idx];
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
static const char*
|
|
372
|
-
icall_table_lookup_symbol (void *func)
|
|
373
|
-
{
|
|
374
|
-
assert (0);
|
|
375
|
-
return NULL;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
#endif
|
|
379
|
-
|
|
380
|
-
/*
|
|
381
|
-
* get_native_to_interp:
|
|
382
|
-
*
|
|
383
|
-
* Return a pointer to a wasm function which can be used to enter the interpreter to
|
|
384
|
-
* execute METHOD from native code.
|
|
385
|
-
* EXTRA_ARG is the argument passed to the interp entry functions in the runtime.
|
|
386
|
-
*/
|
|
387
|
-
void*
|
|
388
|
-
get_native_to_interp (MonoMethod *method, void *extra_arg)
|
|
389
|
-
{
|
|
390
|
-
void *addr;
|
|
391
|
-
|
|
392
|
-
MONO_ENTER_GC_UNSAFE;
|
|
393
|
-
MonoClass *klass = mono_method_get_class (method);
|
|
394
|
-
MonoImage *image = mono_class_get_image (klass);
|
|
395
|
-
MonoAssembly *assembly = mono_image_get_assembly (image);
|
|
396
|
-
MonoAssemblyName *aname = mono_assembly_get_name (assembly);
|
|
397
|
-
const char *name = mono_assembly_name_get_name (aname);
|
|
398
|
-
const char *class_name = mono_class_get_name (klass);
|
|
399
|
-
const char *method_name = mono_method_get_name (method);
|
|
400
|
-
char key [128];
|
|
401
|
-
int len;
|
|
402
|
-
|
|
403
|
-
assert (strlen (name) < 100);
|
|
404
|
-
snprintf (key, sizeof(key), "%s_%s_%s", name, class_name, method_name);
|
|
405
|
-
len = strlen (key);
|
|
406
|
-
for (int i = 0; i < len; ++i) {
|
|
407
|
-
if (key [i] == '.')
|
|
408
|
-
key [i] = '_';
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
addr = wasm_dl_get_native_to_interp (key, extra_arg);
|
|
412
|
-
MONO_EXIT_GC_UNSAFE;
|
|
413
|
-
return addr;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
void mono_wasm_link_icu_shim (void);
|
|
417
|
-
|
|
418
|
-
void
|
|
419
|
-
cleanup_runtime_config (MonovmRuntimeConfigArguments *args, void *user_data)
|
|
420
|
-
{
|
|
421
|
-
free (args);
|
|
422
|
-
free (user_data);
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
EMSCRIPTEN_KEEPALIVE void
|
|
426
|
-
mono_wasm_load_runtime (const char *unused, int debug_level)
|
|
427
|
-
{
|
|
428
|
-
const char *interp_opts = "";
|
|
429
|
-
|
|
430
|
-
#ifndef INVARIANT_GLOBALIZATION
|
|
431
|
-
mono_wasm_link_icu_shim ();
|
|
432
|
-
#endif
|
|
433
|
-
|
|
434
|
-
// We should enable this as part of the wasm build later
|
|
435
|
-
#ifndef DISABLE_THREADS
|
|
436
|
-
monoeg_g_setenv ("MONO_THREADS_SUSPEND", "coop", 0);
|
|
437
|
-
monoeg_g_setenv ("MONO_SLEEP_ABORT_LIMIT", "5000", 0);
|
|
438
|
-
#endif
|
|
439
|
-
|
|
440
|
-
// monoeg_g_setenv ("DOTNET_DebugWriteToStdErr", "1", 0);
|
|
441
|
-
|
|
442
|
-
#ifdef DEBUG
|
|
443
|
-
// monoeg_g_setenv ("MONO_LOG_LEVEL", "debug", 0);
|
|
444
|
-
// monoeg_g_setenv ("MONO_LOG_MASK", "gc", 0);
|
|
445
|
-
// Setting this env var allows Diagnostic.Debug to write to stderr. In a browser environment this
|
|
446
|
-
// output will be sent to the console. Right now this is the only way to emit debug logging from
|
|
447
|
-
// corlib assemblies.
|
|
448
|
-
#endif
|
|
449
|
-
// When the list of app context properties changes, please update RuntimeConfigReservedProperties for
|
|
450
|
-
// target _WasmGenerateRuntimeConfig in WasmApp.targets file
|
|
451
|
-
const char *appctx_keys[2];
|
|
452
|
-
appctx_keys [0] = "APP_CONTEXT_BASE_DIRECTORY";
|
|
453
|
-
appctx_keys [1] = "RUNTIME_IDENTIFIER";
|
|
454
|
-
|
|
455
|
-
const char *appctx_values[2];
|
|
456
|
-
appctx_values [0] = "/";
|
|
457
|
-
appctx_values [1] = "browser-wasm";
|
|
458
|
-
|
|
459
|
-
char *file_name = RUNTIMECONFIG_BIN_FILE;
|
|
460
|
-
int str_len = strlen (file_name) + 1; // +1 is for the "/"
|
|
461
|
-
char *file_path = (char *)malloc (sizeof (char) * (str_len +1)); // +1 is for the terminating null character
|
|
462
|
-
int num_char = snprintf (file_path, (str_len + 1), "/%s", file_name);
|
|
463
|
-
struct stat buffer;
|
|
464
|
-
|
|
465
|
-
assert (num_char > 0 && num_char == str_len);
|
|
466
|
-
|
|
467
|
-
if (stat (file_path, &buffer) == 0) {
|
|
468
|
-
MonovmRuntimeConfigArguments *arg = (MonovmRuntimeConfigArguments *)malloc (sizeof (MonovmRuntimeConfigArguments));
|
|
469
|
-
arg->kind = 0;
|
|
470
|
-
arg->runtimeconfig.name.path = file_path;
|
|
471
|
-
monovm_runtimeconfig_initialize (arg, cleanup_runtime_config, file_path);
|
|
472
|
-
} else {
|
|
473
|
-
free (file_path);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
monovm_initialize (2, appctx_keys, appctx_values);
|
|
477
|
-
|
|
478
|
-
mini_parse_debug_option ("top-runtime-invoke-unhandled");
|
|
479
|
-
|
|
480
|
-
#ifndef INVARIANT_TIMEZONE
|
|
481
|
-
mono_register_timezones_bundle ();
|
|
482
|
-
#endif /* INVARIANT_TIMEZONE */
|
|
483
|
-
mono_dl_fallback_register (wasm_dl_load, wasm_dl_symbol, NULL, NULL);
|
|
484
|
-
mono_wasm_install_get_native_to_interp_tramp (get_native_to_interp);
|
|
485
|
-
|
|
486
|
-
#ifdef GEN_PINVOKE
|
|
487
|
-
mono_wasm_install_interp_to_native_callback (mono_wasm_interp_to_native_callback);
|
|
488
|
-
#endif
|
|
489
|
-
|
|
490
|
-
#ifdef ENABLE_AOT
|
|
491
|
-
monoeg_g_setenv ("MONO_AOT_MODE", "aot", 1);
|
|
492
|
-
|
|
493
|
-
// Defined in driver-gen.c
|
|
494
|
-
register_aot_modules ();
|
|
495
|
-
#ifdef EE_MODE_LLVMONLY_INTERP
|
|
496
|
-
mono_jit_set_aot_mode (MONO_AOT_MODE_LLVMONLY_INTERP);
|
|
497
|
-
#else
|
|
498
|
-
mono_jit_set_aot_mode (MONO_AOT_MODE_LLVMONLY);
|
|
499
|
-
#endif
|
|
500
|
-
#else
|
|
501
|
-
mono_jit_set_aot_mode (MONO_AOT_MODE_INTERP_ONLY);
|
|
502
|
-
|
|
503
|
-
/*
|
|
504
|
-
* debug_level > 0 enables debugging and sets the debug log level to debug_level
|
|
505
|
-
* debug_level == 0 disables debugging and enables interpreter optimizations
|
|
506
|
-
* debug_level < 0 enabled debugging and disables debug logging.
|
|
507
|
-
*
|
|
508
|
-
* Note: when debugging is enabled interpreter optimizations are disabled.
|
|
509
|
-
*/
|
|
510
|
-
if (debug_level) {
|
|
511
|
-
// Disable optimizations which interfere with debugging
|
|
512
|
-
interp_opts = "-all";
|
|
513
|
-
mono_wasm_enable_debugging (debug_level);
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
#endif
|
|
517
|
-
|
|
518
|
-
#ifdef LINK_ICALLS
|
|
519
|
-
/* Link in our own linked icall table */
|
|
520
|
-
static const MonoIcallTableCallbacks mono_icall_table_callbacks =
|
|
521
|
-
{
|
|
522
|
-
MONO_ICALL_TABLE_CALLBACKS_VERSION,
|
|
523
|
-
icall_table_lookup,
|
|
524
|
-
icall_table_lookup_symbol
|
|
525
|
-
};
|
|
526
|
-
mono_install_icall_table_callbacks (&mono_icall_table_callbacks);
|
|
527
|
-
#endif
|
|
528
|
-
|
|
529
|
-
#ifdef NEED_NORMAL_ICALL_TABLES
|
|
530
|
-
mono_icall_table_init ();
|
|
531
|
-
#endif
|
|
532
|
-
#ifdef NEED_INTERP
|
|
533
|
-
mono_ee_interp_init (interp_opts);
|
|
534
|
-
mono_marshal_ilgen_init();
|
|
535
|
-
mono_method_builder_ilgen_init ();
|
|
536
|
-
mono_sgen_mono_ilgen_init ();
|
|
537
|
-
#endif
|
|
538
|
-
|
|
539
|
-
mono_trace_init ();
|
|
540
|
-
mono_trace_set_log_handler (wasm_trace_logger, NULL);
|
|
541
|
-
root_domain = mono_jit_init_version ("mono", NULL);
|
|
542
|
-
|
|
543
|
-
bindings_initialize_internals();
|
|
544
|
-
|
|
545
|
-
mono_thread_set_main (mono_thread_current ());
|
|
546
|
-
|
|
547
|
-
// TODO: we can probably delay starting the finalizer thread even longer - maybe from JS
|
|
548
|
-
// once we're done with loading and are about to begin running some managed code.
|
|
549
|
-
mono_wasm_init_finalizer_thread ();
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
EMSCRIPTEN_KEEPALIVE MonoAssembly*
|
|
553
|
-
mono_wasm_assembly_load (const char *name)
|
|
554
|
-
{
|
|
555
|
-
assert (name);
|
|
556
|
-
MonoImageOpenStatus status;
|
|
557
|
-
MonoAssemblyName* aname = mono_assembly_name_new (name);
|
|
558
|
-
|
|
559
|
-
MonoAssembly *res = mono_assembly_load (aname, NULL, &status);
|
|
560
|
-
mono_assembly_name_free (aname);
|
|
561
|
-
|
|
562
|
-
return res;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
EMSCRIPTEN_KEEPALIVE MonoAssembly*
|
|
566
|
-
mono_wasm_get_corlib (void)
|
|
567
|
-
{
|
|
568
|
-
MonoAssembly* result;
|
|
569
|
-
MONO_ENTER_GC_UNSAFE;
|
|
570
|
-
result = mono_image_get_assembly (mono_get_corlib());
|
|
571
|
-
MONO_EXIT_GC_UNSAFE;
|
|
572
|
-
return result;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
EMSCRIPTEN_KEEPALIVE MonoClass*
|
|
576
|
-
mono_wasm_assembly_find_class (MonoAssembly *assembly, const char *namespace, const char *name)
|
|
577
|
-
{
|
|
578
|
-
assert (assembly);
|
|
579
|
-
MonoClass *result;
|
|
580
|
-
MONO_ENTER_GC_UNSAFE;
|
|
581
|
-
result = mono_class_from_name (mono_assembly_get_image (assembly), namespace, name);
|
|
582
|
-
MONO_EXIT_GC_UNSAFE;
|
|
583
|
-
return result;
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
extern int mono_runtime_run_module_cctor (MonoImage *image, MonoError *error);
|
|
587
|
-
|
|
588
|
-
EMSCRIPTEN_KEEPALIVE void
|
|
589
|
-
mono_wasm_runtime_run_module_cctor (MonoAssembly *assembly)
|
|
590
|
-
{
|
|
591
|
-
assert (assembly);
|
|
592
|
-
MonoError error;
|
|
593
|
-
MONO_ENTER_GC_UNSAFE;
|
|
594
|
-
MonoImage *image = mono_assembly_get_image (assembly);
|
|
595
|
-
if (!mono_runtime_run_module_cctor(image, &error)) {
|
|
596
|
-
//g_print ("Failed to run module constructor due to %s\n", mono_error_get_message (error));
|
|
597
|
-
}
|
|
598
|
-
MONO_EXIT_GC_UNSAFE;
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
EMSCRIPTEN_KEEPALIVE MonoMethod*
|
|
603
|
-
mono_wasm_assembly_find_method (MonoClass *klass, const char *name, int arguments)
|
|
604
|
-
{
|
|
605
|
-
assert (klass);
|
|
606
|
-
MonoMethod* result;
|
|
607
|
-
MONO_ENTER_GC_UNSAFE;
|
|
608
|
-
result = mono_class_get_method_from_name (klass, name, arguments);
|
|
609
|
-
MONO_EXIT_GC_UNSAFE;
|
|
610
|
-
return result;
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
EMSCRIPTEN_KEEPALIVE void
|
|
614
|
-
mono_wasm_invoke_method_ref (MonoMethod *method, MonoObject **this_arg_in, void *params[], MonoObject **_out_exc, MonoObject **out_result)
|
|
615
|
-
{
|
|
616
|
-
PPVOLATILE(MonoObject) out_exc = _out_exc;
|
|
617
|
-
PVOLATILE(MonoObject) temp_exc = NULL;
|
|
618
|
-
if (out_exc)
|
|
619
|
-
*out_exc = NULL;
|
|
620
|
-
else
|
|
621
|
-
out_exc = &temp_exc;
|
|
622
|
-
|
|
623
|
-
MONO_ENTER_GC_UNSAFE;
|
|
624
|
-
if (out_result) {
|
|
625
|
-
*out_result = NULL;
|
|
626
|
-
PVOLATILE(MonoObject) invoke_result = mono_runtime_invoke (method, this_arg_in ? *this_arg_in : NULL, params, (MonoObject **)out_exc);
|
|
627
|
-
store_volatile(out_result, invoke_result);
|
|
628
|
-
} else {
|
|
629
|
-
mono_runtime_invoke (method, this_arg_in ? *this_arg_in : NULL, params, (MonoObject **)out_exc);
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
if (*out_exc && out_result) {
|
|
633
|
-
PVOLATILE(MonoObject) exc2 = NULL;
|
|
634
|
-
store_volatile(out_result, (MonoObject*)mono_object_to_string (*out_exc, (MonoObject **)&exc2));
|
|
635
|
-
if (exc2)
|
|
636
|
-
store_volatile(out_result, (MonoObject*)mono_string_new (root_domain, "Exception Double Fault"));
|
|
637
|
-
}
|
|
638
|
-
MONO_EXIT_GC_UNSAFE;
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
EMSCRIPTEN_KEEPALIVE int
|
|
642
|
-
mono_wasm_invoke_method_bound (MonoMethod *method, void* args /*JSMarshalerArguments*/, MonoString **out_exc)
|
|
643
|
-
{
|
|
644
|
-
PVOLATILE(MonoObject) temp_exc = NULL;
|
|
645
|
-
|
|
646
|
-
void *invoke_args[1] = { args };
|
|
647
|
-
int is_err = 0;
|
|
648
|
-
|
|
649
|
-
MONO_ENTER_GC_UNSAFE;
|
|
650
|
-
mono_runtime_invoke (method, NULL, invoke_args, (MonoObject **)&temp_exc);
|
|
651
|
-
|
|
652
|
-
// this failure is unlikely because it would be runtime error, not application exception.
|
|
653
|
-
// the application exception is passed inside JSMarshalerArguments `args`
|
|
654
|
-
if (temp_exc) {
|
|
655
|
-
PVOLATILE(MonoObject) exc2 = NULL;
|
|
656
|
-
store_volatile((MonoObject**)out_exc, (MonoObject*)mono_object_to_string ((MonoObject*)temp_exc, (MonoObject **)&exc2));
|
|
657
|
-
if (exc2)
|
|
658
|
-
store_volatile((MonoObject**)out_exc, (MonoObject*)mono_string_new (root_domain, "Exception Double Fault"));
|
|
659
|
-
is_err = 1;
|
|
660
|
-
}
|
|
661
|
-
MONO_EXIT_GC_UNSAFE;
|
|
662
|
-
return is_err;
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
EMSCRIPTEN_KEEPALIVE MonoMethod*
|
|
666
|
-
mono_wasm_assembly_get_entry_point (MonoAssembly *assembly, int auto_insert_breakpoint)
|
|
667
|
-
{
|
|
668
|
-
MonoImage *image;
|
|
669
|
-
MonoMethod *method;
|
|
670
|
-
|
|
671
|
-
MONO_ENTER_GC_UNSAFE;
|
|
672
|
-
image = mono_assembly_get_image (assembly);
|
|
673
|
-
uint32_t entry = mono_image_get_entry_point (image);
|
|
674
|
-
if (!entry)
|
|
675
|
-
goto end;
|
|
676
|
-
|
|
677
|
-
mono_domain_ensure_entry_assembly (root_domain, assembly);
|
|
678
|
-
method = mono_get_method (image, entry, NULL);
|
|
679
|
-
|
|
680
|
-
/*
|
|
681
|
-
* If the entry point looks like a compiler generated wrapper around
|
|
682
|
-
* an async method in the form "<Name>" then try to look up the async methods
|
|
683
|
-
* "<Name>$" and "Name" it could be wrapping. We do this because the generated
|
|
684
|
-
* sync wrapper will call task.GetAwaiter().GetResult() when we actually want
|
|
685
|
-
* to yield to the host runtime.
|
|
686
|
-
*/
|
|
687
|
-
if (mono_method_get_flags (method, NULL) & 0x0800 /* METHOD_ATTRIBUTE_SPECIAL_NAME */) {
|
|
688
|
-
const char *name = mono_method_get_name (method);
|
|
689
|
-
int name_length = strlen (name);
|
|
690
|
-
|
|
691
|
-
if ((*name != '<') || (name [name_length - 1] != '>'))
|
|
692
|
-
goto end;
|
|
693
|
-
|
|
694
|
-
MonoClass *klass = mono_method_get_class (method);
|
|
695
|
-
assert(klass);
|
|
696
|
-
char *async_name = malloc (name_length + 2);
|
|
697
|
-
snprintf (async_name, name_length + 2, "%s$", name);
|
|
698
|
-
|
|
699
|
-
// look for "<Name>$"
|
|
700
|
-
MonoMethodSignature *sig = mono_method_get_signature (method, image, mono_method_get_token (method));
|
|
701
|
-
MonoMethod *async_method = mono_class_get_method_from_name (klass, async_name, mono_signature_get_param_count (sig));
|
|
702
|
-
if (async_method != NULL) {
|
|
703
|
-
free (async_name);
|
|
704
|
-
method = async_method;
|
|
705
|
-
goto end;
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
// look for "Name" by trimming the first and last character of "<Name>"
|
|
709
|
-
async_name [name_length - 1] = '\0';
|
|
710
|
-
async_method = mono_class_get_method_from_name (klass, async_name + 1, mono_signature_get_param_count (sig));
|
|
711
|
-
|
|
712
|
-
free (async_name);
|
|
713
|
-
if (async_method != NULL)
|
|
714
|
-
method = async_method;
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
end:
|
|
718
|
-
MONO_EXIT_GC_UNSAFE;
|
|
719
|
-
if (auto_insert_breakpoint)
|
|
720
|
-
{
|
|
721
|
-
MonoAssemblyName *aname = mono_assembly_get_name (assembly);
|
|
722
|
-
const char *name = mono_assembly_name_get_name (aname);
|
|
723
|
-
if (name != NULL)
|
|
724
|
-
mono_wasm_set_entrypoint_breakpoint(name, mono_method_get_token (method));
|
|
725
|
-
}
|
|
726
|
-
return method;
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
EMSCRIPTEN_KEEPALIVE void
|
|
730
|
-
mono_wasm_string_from_utf16_ref (const mono_unichar2 * chars, int length, MonoString **result)
|
|
731
|
-
{
|
|
732
|
-
assert (length >= 0);
|
|
733
|
-
|
|
734
|
-
MONO_ENTER_GC_UNSAFE;
|
|
735
|
-
if (chars) {
|
|
736
|
-
mono_gc_wbarrier_generic_store_atomic(result, (MonoObject *)mono_string_new_utf16 (root_domain, chars, length));
|
|
737
|
-
} else {
|
|
738
|
-
mono_gc_wbarrier_generic_store_atomic(result, NULL);
|
|
739
|
-
}
|
|
740
|
-
MONO_EXIT_GC_UNSAFE;
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
#ifndef DISABLE_LEGACY_JS_INTEROP
|
|
744
|
-
|
|
745
|
-
static int
|
|
746
|
-
class_is_task (MonoClass *klass)
|
|
747
|
-
{
|
|
748
|
-
if (!klass)
|
|
749
|
-
return 0;
|
|
750
|
-
|
|
751
|
-
int result;
|
|
752
|
-
MONO_ENTER_GC_UNSAFE;
|
|
753
|
-
if (!task_class && !resolved_task_class) {
|
|
754
|
-
task_class = mono_class_from_name (mono_get_corlib(), "System.Threading.Tasks", "Task");
|
|
755
|
-
resolved_task_class = 1;
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
result = task_class && (klass == task_class || mono_class_is_subclass_of(klass, task_class, 0));
|
|
759
|
-
MONO_EXIT_GC_UNSAFE;
|
|
760
|
-
return result;
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
static MonoClass*
|
|
764
|
-
_get_uri_class(MonoException** exc)
|
|
765
|
-
{
|
|
766
|
-
MonoAssembly* assembly = mono_wasm_assembly_load ("System");
|
|
767
|
-
if (!assembly)
|
|
768
|
-
return NULL;
|
|
769
|
-
MonoClass* klass = mono_wasm_assembly_find_class(assembly, "System", "Uri");
|
|
770
|
-
return klass;
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
static void
|
|
774
|
-
_ensure_classes_resolved (void)
|
|
775
|
-
{
|
|
776
|
-
MONO_ENTER_GC_UNSAFE;
|
|
777
|
-
if (!datetime_class && !resolved_datetime_class) {
|
|
778
|
-
datetime_class = mono_class_from_name (mono_get_corlib(), "System", "DateTime");
|
|
779
|
-
resolved_datetime_class = 1;
|
|
780
|
-
}
|
|
781
|
-
if (!datetimeoffset_class && !resolved_datetimeoffset_class) {
|
|
782
|
-
datetimeoffset_class = mono_class_from_name (mono_get_corlib(), "System", "DateTimeOffset");
|
|
783
|
-
resolved_datetimeoffset_class = 1;
|
|
784
|
-
}
|
|
785
|
-
if (!uri_class && !resolved_uri_class) {
|
|
786
|
-
PVOLATILE(MonoException) exc = NULL;
|
|
787
|
-
uri_class = _get_uri_class((MonoException **)&exc);
|
|
788
|
-
resolved_uri_class = 1;
|
|
789
|
-
}
|
|
790
|
-
if (!safehandle_class && !resolved_safehandle_class) {
|
|
791
|
-
safehandle_class = mono_class_from_name (mono_get_corlib(), "System.Runtime.InteropServices", "SafeHandle");
|
|
792
|
-
resolved_safehandle_class = 1;
|
|
793
|
-
}
|
|
794
|
-
if (!voidtaskresult_class && !resolved_voidtaskresult_class) {
|
|
795
|
-
voidtaskresult_class = mono_class_from_name (mono_get_corlib(), "System.Threading.Tasks", "VoidTaskResult");
|
|
796
|
-
resolved_voidtaskresult_class = 1;
|
|
797
|
-
}
|
|
798
|
-
MONO_EXIT_GC_UNSAFE;
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
// This must be run inside a GC unsafe region
|
|
802
|
-
static int
|
|
803
|
-
_marshal_type_from_mono_type (int mono_type, MonoClass *klass, MonoType *type)
|
|
804
|
-
{
|
|
805
|
-
switch (mono_type) {
|
|
806
|
-
// case MONO_TYPE_CHAR: prob should be done not as a number?
|
|
807
|
-
case MONO_TYPE_VOID:
|
|
808
|
-
return MARSHAL_TYPE_VOID;
|
|
809
|
-
case MONO_TYPE_BOOLEAN:
|
|
810
|
-
return MARSHAL_TYPE_BOOL;
|
|
811
|
-
case MONO_TYPE_I: // IntPtr
|
|
812
|
-
case MONO_TYPE_U: // UIntPtr
|
|
813
|
-
case MONO_TYPE_PTR:
|
|
814
|
-
return MARSHAL_TYPE_POINTER;
|
|
815
|
-
case MONO_TYPE_I1:
|
|
816
|
-
case MONO_TYPE_I2:
|
|
817
|
-
case MONO_TYPE_I4:
|
|
818
|
-
return MARSHAL_TYPE_INT;
|
|
819
|
-
case MONO_TYPE_CHAR:
|
|
820
|
-
return MARSHAL_TYPE_CHAR;
|
|
821
|
-
case MONO_TYPE_U1:
|
|
822
|
-
case MONO_TYPE_U2:
|
|
823
|
-
case MONO_TYPE_U4: // The distinction between this and signed int is
|
|
824
|
-
// important due to how numbers work in JavaScript
|
|
825
|
-
return MARSHAL_TYPE_UINT32;
|
|
826
|
-
case MONO_TYPE_I8:
|
|
827
|
-
return MARSHAL_TYPE_INT64;
|
|
828
|
-
case MONO_TYPE_U8:
|
|
829
|
-
return MARSHAL_TYPE_UINT64;
|
|
830
|
-
case MONO_TYPE_R4:
|
|
831
|
-
return MARSHAL_TYPE_FP32;
|
|
832
|
-
case MONO_TYPE_R8:
|
|
833
|
-
return MARSHAL_TYPE_FP64;
|
|
834
|
-
case MONO_TYPE_STRING:
|
|
835
|
-
return MARSHAL_TYPE_STRING;
|
|
836
|
-
case MONO_TYPE_SZARRAY: { // simple zero based one-dim-array
|
|
837
|
-
if (klass) {
|
|
838
|
-
MonoClass *eklass = mono_class_get_element_class (klass);
|
|
839
|
-
MonoType *etype = mono_class_get_type (eklass);
|
|
840
|
-
|
|
841
|
-
switch (mono_type_get_type (etype)) {
|
|
842
|
-
case MONO_TYPE_U1:
|
|
843
|
-
return MARSHAL_ARRAY_UBYTE;
|
|
844
|
-
case MONO_TYPE_I1:
|
|
845
|
-
return MARSHAL_ARRAY_BYTE;
|
|
846
|
-
case MONO_TYPE_U2:
|
|
847
|
-
return MARSHAL_ARRAY_USHORT;
|
|
848
|
-
case MONO_TYPE_I2:
|
|
849
|
-
return MARSHAL_ARRAY_SHORT;
|
|
850
|
-
case MONO_TYPE_U4:
|
|
851
|
-
return MARSHAL_ARRAY_UINT;
|
|
852
|
-
case MONO_TYPE_I4:
|
|
853
|
-
return MARSHAL_ARRAY_INT;
|
|
854
|
-
case MONO_TYPE_R4:
|
|
855
|
-
return MARSHAL_ARRAY_FLOAT;
|
|
856
|
-
case MONO_TYPE_R8:
|
|
857
|
-
return MARSHAL_ARRAY_DOUBLE;
|
|
858
|
-
default:
|
|
859
|
-
return MARSHAL_TYPE_OBJECT;
|
|
860
|
-
}
|
|
861
|
-
} else {
|
|
862
|
-
return MARSHAL_TYPE_OBJECT;
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
default:
|
|
866
|
-
_ensure_classes_resolved ();
|
|
867
|
-
|
|
868
|
-
if (klass) {
|
|
869
|
-
if (klass == datetime_class)
|
|
870
|
-
return MARSHAL_TYPE_DATE;
|
|
871
|
-
if (klass == datetimeoffset_class)
|
|
872
|
-
return MARSHAL_TYPE_DATEOFFSET;
|
|
873
|
-
if (uri_class && mono_class_is_assignable_from(uri_class, klass))
|
|
874
|
-
return MARSHAL_TYPE_URI;
|
|
875
|
-
if (klass == voidtaskresult_class)
|
|
876
|
-
return MARSHAL_TYPE_VOID;
|
|
877
|
-
if (mono_class_is_enum (klass))
|
|
878
|
-
return MARSHAL_TYPE_ENUM;
|
|
879
|
-
if (type && !mono_type_is_reference (type)) //vt
|
|
880
|
-
return MARSHAL_TYPE_VT;
|
|
881
|
-
if (mono_class_is_delegate (klass))
|
|
882
|
-
return MARSHAL_TYPE_DELEGATE;
|
|
883
|
-
if (class_is_task(klass))
|
|
884
|
-
return MARSHAL_TYPE_TASK;
|
|
885
|
-
if (safehandle_class && (klass == safehandle_class || mono_class_is_subclass_of(klass, safehandle_class, 0)))
|
|
886
|
-
return MARSHAL_TYPE_SAFEHANDLE;
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
return MARSHAL_TYPE_OBJECT;
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
EMSCRIPTEN_KEEPALIVE void
|
|
894
|
-
mono_wasm_typed_array_new_ref (char *arr, int length, int size, int type, PPVOLATILE(MonoArray) result)
|
|
895
|
-
{
|
|
896
|
-
MONO_ENTER_GC_UNSAFE;
|
|
897
|
-
MonoClass * typeClass = mono_get_byte_class(); // default is Byte
|
|
898
|
-
switch (type) {
|
|
899
|
-
case MARSHAL_ARRAY_BYTE:
|
|
900
|
-
typeClass = mono_get_sbyte_class();
|
|
901
|
-
break;
|
|
902
|
-
case MARSHAL_ARRAY_SHORT:
|
|
903
|
-
typeClass = mono_get_int16_class();
|
|
904
|
-
break;
|
|
905
|
-
case MARSHAL_ARRAY_USHORT:
|
|
906
|
-
typeClass = mono_get_uint16_class();
|
|
907
|
-
break;
|
|
908
|
-
case MARSHAL_ARRAY_INT:
|
|
909
|
-
typeClass = mono_get_int32_class();
|
|
910
|
-
break;
|
|
911
|
-
case MARSHAL_ARRAY_UINT:
|
|
912
|
-
typeClass = mono_get_uint32_class();
|
|
913
|
-
break;
|
|
914
|
-
case MARSHAL_ARRAY_FLOAT:
|
|
915
|
-
typeClass = mono_get_single_class();
|
|
916
|
-
break;
|
|
917
|
-
case MARSHAL_ARRAY_DOUBLE:
|
|
918
|
-
typeClass = mono_get_double_class();
|
|
919
|
-
break;
|
|
920
|
-
case MARSHAL_ARRAY_UBYTE:
|
|
921
|
-
case MARSHAL_ARRAY_UBYTE_C:
|
|
922
|
-
typeClass = mono_get_byte_class();
|
|
923
|
-
break;
|
|
924
|
-
default:
|
|
925
|
-
printf ("Invalid marshal type %d in mono_wasm_typed_array_new", type);
|
|
926
|
-
abort();
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
PVOLATILE(MonoArray) buffer;
|
|
930
|
-
|
|
931
|
-
buffer = mono_array_new (mono_get_root_domain(), typeClass, length);
|
|
932
|
-
memcpy(mono_array_addr_with_size(buffer, sizeof(char), 0), arr, length * size);
|
|
933
|
-
|
|
934
|
-
store_volatile((PPVOLATILE(MonoObject))result, (MonoObject *)buffer);
|
|
935
|
-
MONO_EXIT_GC_UNSAFE;
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
EMSCRIPTEN_KEEPALIVE MonoMethod*
|
|
939
|
-
mono_wasm_get_delegate_invoke_ref (MonoObject **delegate)
|
|
940
|
-
{
|
|
941
|
-
MonoMethod * result;
|
|
942
|
-
MONO_ENTER_GC_UNSAFE;
|
|
943
|
-
result = mono_get_delegate_invoke(mono_object_get_class (*delegate));
|
|
944
|
-
MONO_EXIT_GC_UNSAFE;
|
|
945
|
-
return result;
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
EMSCRIPTEN_KEEPALIVE void
|
|
949
|
-
mono_wasm_box_primitive_ref (MonoClass *klass, void *value, int value_size, PPVOLATILE(MonoObject) result)
|
|
950
|
-
{
|
|
951
|
-
assert (klass);
|
|
952
|
-
|
|
953
|
-
MONO_ENTER_GC_UNSAFE;
|
|
954
|
-
MonoType *type = mono_class_get_type (klass);
|
|
955
|
-
int alignment;
|
|
956
|
-
|
|
957
|
-
if (mono_type_size (type, &alignment) <= value_size)
|
|
958
|
-
// TODO: use mono_value_box_checked and propagate error out
|
|
959
|
-
store_volatile(result, mono_value_box (root_domain, klass, value));
|
|
960
|
-
|
|
961
|
-
MONO_EXIT_GC_UNSAFE;
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
EMSCRIPTEN_KEEPALIVE char *
|
|
965
|
-
mono_wasm_get_type_name (MonoType * typePtr) {
|
|
966
|
-
return mono_type_get_name_full (typePtr, MONO_TYPE_NAME_FORMAT_REFLECTION);
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
EMSCRIPTEN_KEEPALIVE char *
|
|
970
|
-
mono_wasm_get_type_aqn (MonoType * typePtr) {
|
|
971
|
-
return mono_type_get_name_full (typePtr, MONO_TYPE_NAME_FORMAT_ASSEMBLY_QUALIFIED);
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
// This code runs inside a gc unsafe region
|
|
975
|
-
static int
|
|
976
|
-
_mono_wasm_try_unbox_primitive_and_get_type_ref_impl (PVOLATILE(MonoObject) obj, void *result, int result_capacity) {
|
|
977
|
-
void **resultP = result;
|
|
978
|
-
int *resultI = result;
|
|
979
|
-
uint32_t *resultU = result;
|
|
980
|
-
int64_t *resultL = result;
|
|
981
|
-
float *resultF = result;
|
|
982
|
-
double *resultD = result;
|
|
983
|
-
|
|
984
|
-
/* Process obj before calling into the runtime, class_from_name () can invoke managed code */
|
|
985
|
-
MonoClass *klass = mono_object_get_class (obj);
|
|
986
|
-
if (!klass)
|
|
987
|
-
return MARSHAL_ERROR_NULL_CLASS_POINTER;
|
|
988
|
-
|
|
989
|
-
MonoType *type = mono_class_get_type (klass), *original_type = type;
|
|
990
|
-
if (!type)
|
|
991
|
-
return MARSHAL_ERROR_NULL_TYPE_POINTER;
|
|
992
|
-
|
|
993
|
-
if ((klass == mono_get_string_class ()) &&
|
|
994
|
-
mono_string_instance_is_interned ((MonoString *)obj)) {
|
|
995
|
-
*resultL = 0;
|
|
996
|
-
*resultP = type;
|
|
997
|
-
return MARSHAL_TYPE_STRING_INTERNED;
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
if (mono_class_is_enum (klass))
|
|
1001
|
-
type = mono_type_get_underlying_type (type);
|
|
1002
|
-
|
|
1003
|
-
if (!type)
|
|
1004
|
-
return MARSHAL_ERROR_NULL_TYPE_POINTER;
|
|
1005
|
-
|
|
1006
|
-
int mono_type = mono_type_get_type (type);
|
|
1007
|
-
|
|
1008
|
-
if (mono_type == MONO_TYPE_GENERICINST) {
|
|
1009
|
-
// HACK: While the 'any other type' fallback is valid for classes, it will do the
|
|
1010
|
-
// wrong thing for structs, so we need to make sure the valuetype handler is used
|
|
1011
|
-
if (mono_type_generic_inst_is_valuetype (type))
|
|
1012
|
-
mono_type = MONO_TYPE_VALUETYPE;
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
// FIXME: We would prefer to unbox once here but it will fail if the value isn't unboxable
|
|
1016
|
-
|
|
1017
|
-
switch (mono_type) {
|
|
1018
|
-
case MONO_TYPE_I1:
|
|
1019
|
-
case MONO_TYPE_BOOLEAN:
|
|
1020
|
-
*resultI = *(signed char*)mono_object_unbox (obj);
|
|
1021
|
-
break;
|
|
1022
|
-
case MONO_TYPE_U1:
|
|
1023
|
-
*resultU = *(unsigned char*)mono_object_unbox (obj);
|
|
1024
|
-
break;
|
|
1025
|
-
case MONO_TYPE_I2:
|
|
1026
|
-
case MONO_TYPE_CHAR:
|
|
1027
|
-
*resultI = *(short*)mono_object_unbox (obj);
|
|
1028
|
-
break;
|
|
1029
|
-
case MONO_TYPE_U2:
|
|
1030
|
-
*resultU = *(unsigned short*)mono_object_unbox (obj);
|
|
1031
|
-
break;
|
|
1032
|
-
case MONO_TYPE_I4:
|
|
1033
|
-
case MONO_TYPE_I:
|
|
1034
|
-
*resultI = *(int*)mono_object_unbox (obj);
|
|
1035
|
-
break;
|
|
1036
|
-
case MONO_TYPE_U4:
|
|
1037
|
-
*resultU = *(uint32_t*)mono_object_unbox (obj);
|
|
1038
|
-
break;
|
|
1039
|
-
case MONO_TYPE_R4:
|
|
1040
|
-
*resultF = *(float*)mono_object_unbox (obj);
|
|
1041
|
-
break;
|
|
1042
|
-
case MONO_TYPE_R8:
|
|
1043
|
-
*resultD = *(double*)mono_object_unbox (obj);
|
|
1044
|
-
break;
|
|
1045
|
-
case MONO_TYPE_PTR:
|
|
1046
|
-
*resultU = (uint32_t)(*(void**)mono_object_unbox (obj));
|
|
1047
|
-
break;
|
|
1048
|
-
case MONO_TYPE_I8:
|
|
1049
|
-
case MONO_TYPE_U8:
|
|
1050
|
-
// FIXME: At present the javascript side of things can't handle this,
|
|
1051
|
-
// but there's no reason not to future-proof this API
|
|
1052
|
-
*resultL = *(int64_t*)mono_object_unbox (obj);
|
|
1053
|
-
break;
|
|
1054
|
-
case MONO_TYPE_VALUETYPE:
|
|
1055
|
-
{
|
|
1056
|
-
int obj_size = mono_object_get_size (obj),
|
|
1057
|
-
required_size = (sizeof (int)) + (sizeof (MonoType *)) + obj_size;
|
|
1058
|
-
|
|
1059
|
-
// Check whether this struct has special-case marshaling
|
|
1060
|
-
// FIXME: Do we need to null out obj before this?
|
|
1061
|
-
int marshal_type = _marshal_type_from_mono_type (mono_type, klass, original_type);
|
|
1062
|
-
if (marshal_type != MARSHAL_TYPE_VT)
|
|
1063
|
-
return marshal_type;
|
|
1064
|
-
|
|
1065
|
-
// Check whether the result buffer is big enough for the struct and padding
|
|
1066
|
-
if (result_capacity < required_size)
|
|
1067
|
-
return MARSHAL_ERROR_BUFFER_TOO_SMALL;
|
|
1068
|
-
|
|
1069
|
-
// Store a header before the struct data with the size of the data and its MonoType
|
|
1070
|
-
*resultP = type;
|
|
1071
|
-
int * resultSize = (int *)(resultP + 1);
|
|
1072
|
-
*resultSize = obj_size;
|
|
1073
|
-
void * resultVoid = (resultP + 2);
|
|
1074
|
-
void * unboxed = mono_object_unbox (obj);
|
|
1075
|
-
memcpy (resultVoid, unboxed, obj_size);
|
|
1076
|
-
return MARSHAL_TYPE_VT;
|
|
1077
|
-
}
|
|
1078
|
-
break;
|
|
1079
|
-
default:
|
|
1080
|
-
// If we failed to do a fast unboxing, return the original type information so
|
|
1081
|
-
// that the caller can do a proper, slow unboxing later
|
|
1082
|
-
// HACK: Store the class pointer into the result buffer so our caller doesn't
|
|
1083
|
-
// have to call back into the native runtime later to get it
|
|
1084
|
-
*resultP = type;
|
|
1085
|
-
int fallbackResultType = _marshal_type_from_mono_type (mono_type, klass, original_type);
|
|
1086
|
-
assert (fallbackResultType != MARSHAL_TYPE_VT);
|
|
1087
|
-
return fallbackResultType;
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
// We successfully performed a fast unboxing here so use the type information
|
|
1091
|
-
// matching what we unboxed (i.e. an enum's underlying type instead of its type)
|
|
1092
|
-
int resultType = _marshal_type_from_mono_type (mono_type, klass, type);
|
|
1093
|
-
assert (resultType != MARSHAL_TYPE_VT);
|
|
1094
|
-
return resultType;
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
EMSCRIPTEN_KEEPALIVE int
|
|
1098
|
-
mono_wasm_try_unbox_primitive_and_get_type_ref (MonoObject **objRef, void *result, int result_capacity)
|
|
1099
|
-
{
|
|
1100
|
-
if (!result)
|
|
1101
|
-
return MARSHAL_ERROR_BUFFER_TOO_SMALL;
|
|
1102
|
-
|
|
1103
|
-
int retval;
|
|
1104
|
-
int *resultI = result;
|
|
1105
|
-
int64_t *resultL = result;
|
|
1106
|
-
|
|
1107
|
-
if (result_capacity >= sizeof (int64_t))
|
|
1108
|
-
*resultL = 0;
|
|
1109
|
-
else if (result_capacity >= sizeof (int))
|
|
1110
|
-
*resultI = 0;
|
|
1111
|
-
|
|
1112
|
-
if (result_capacity < 16)
|
|
1113
|
-
return MARSHAL_ERROR_BUFFER_TOO_SMALL;
|
|
1114
|
-
|
|
1115
|
-
if (!objRef || !(*objRef))
|
|
1116
|
-
return MARSHAL_TYPE_NULL;
|
|
1117
|
-
|
|
1118
|
-
MONO_ENTER_GC_UNSAFE;
|
|
1119
|
-
retval = _mono_wasm_try_unbox_primitive_and_get_type_ref_impl (*objRef, result, result_capacity);
|
|
1120
|
-
MONO_EXIT_GC_UNSAFE;
|
|
1121
|
-
return retval;
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
EMSCRIPTEN_KEEPALIVE int
|
|
1125
|
-
mono_wasm_array_length_ref (MonoArray **array)
|
|
1126
|
-
{
|
|
1127
|
-
return mono_array_length (*array);
|
|
1128
|
-
}
|
|
1129
|
-
|
|
1130
|
-
EMSCRIPTEN_KEEPALIVE void
|
|
1131
|
-
mono_wasm_array_get_ref (PPVOLATILE(MonoArray) array, int idx, PPVOLATILE(MonoObject) result)
|
|
1132
|
-
{
|
|
1133
|
-
MONO_ENTER_GC_UNSAFE;
|
|
1134
|
-
mono_gc_wbarrier_generic_store_atomic((void*)result, mono_array_get ((MonoArray*)*array, MonoObject*, idx));
|
|
1135
|
-
MONO_EXIT_GC_UNSAFE;
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
EMSCRIPTEN_KEEPALIVE void
|
|
1139
|
-
mono_wasm_obj_array_new_ref (int size, MonoArray **result)
|
|
1140
|
-
{
|
|
1141
|
-
MONO_ENTER_GC_UNSAFE;
|
|
1142
|
-
mono_gc_wbarrier_generic_store_atomic(result, (MonoObject *)mono_array_new (root_domain, mono_get_object_class (), size));
|
|
1143
|
-
MONO_EXIT_GC_UNSAFE;
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
// Deprecated
|
|
1147
|
-
EMSCRIPTEN_KEEPALIVE MonoArray*
|
|
1148
|
-
mono_wasm_obj_array_new (int size)
|
|
1149
|
-
{
|
|
1150
|
-
PVOLATILE(MonoArray) result = NULL;
|
|
1151
|
-
mono_wasm_obj_array_new_ref(size, (MonoArray **)&result);
|
|
1152
|
-
return result;
|
|
1153
|
-
}
|
|
1154
|
-
|
|
1155
|
-
EMSCRIPTEN_KEEPALIVE void
|
|
1156
|
-
mono_wasm_obj_array_set (MonoArray *array, int idx, MonoObject *obj)
|
|
1157
|
-
{
|
|
1158
|
-
mono_array_setref (array, idx, obj);
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
EMSCRIPTEN_KEEPALIVE void
|
|
1162
|
-
mono_wasm_obj_array_set_ref (MonoArray **array, int idx, MonoObject **obj)
|
|
1163
|
-
{
|
|
1164
|
-
MONO_ENTER_GC_UNSAFE;
|
|
1165
|
-
mono_array_setref (*array, idx, *obj);
|
|
1166
|
-
MONO_EXIT_GC_UNSAFE;
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
EMSCRIPTEN_KEEPALIVE void
|
|
1170
|
-
mono_wasm_string_array_new_ref (int size, MonoArray **result)
|
|
1171
|
-
{
|
|
1172
|
-
MONO_ENTER_GC_UNSAFE;
|
|
1173
|
-
mono_gc_wbarrier_generic_store_atomic(result, (MonoObject *)mono_array_new (root_domain, mono_get_string_class (), size));
|
|
1174
|
-
MONO_EXIT_GC_UNSAFE;
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
#endif /* DISABLE_LEGACY_JS_INTEROP */
|
|
1178
|
-
|
|
1179
|
-
EMSCRIPTEN_KEEPALIVE int
|
|
1180
|
-
mono_wasm_exec_regression (int verbose_level, char *image)
|
|
1181
|
-
{
|
|
1182
|
-
return mono_regression_test_step (verbose_level, image, NULL) ? 0 : 1;
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
EMSCRIPTEN_KEEPALIVE int
|
|
1186
|
-
mono_wasm_exit (int exit_code)
|
|
1187
|
-
{
|
|
1188
|
-
mono_jit_cleanup (root_domain);
|
|
1189
|
-
exit (exit_code);
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
EMSCRIPTEN_KEEPALIVE int
|
|
1193
|
-
mono_wasm_abort ()
|
|
1194
|
-
{
|
|
1195
|
-
abort ();
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
|
-
EMSCRIPTEN_KEEPALIVE void
|
|
1199
|
-
mono_wasm_set_main_args (int argc, char* argv[])
|
|
1200
|
-
{
|
|
1201
|
-
mono_runtime_set_main_args (argc, argv);
|
|
1202
|
-
}
|
|
1203
|
-
|
|
1204
|
-
EMSCRIPTEN_KEEPALIVE int
|
|
1205
|
-
mono_wasm_strdup (const char *s)
|
|
1206
|
-
{
|
|
1207
|
-
return (int)strdup (s);
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
EMSCRIPTEN_KEEPALIVE void
|
|
1211
|
-
mono_wasm_parse_runtime_options (int argc, char* argv[])
|
|
1212
|
-
{
|
|
1213
|
-
mono_jit_parse_options (argc, argv);
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
EMSCRIPTEN_KEEPALIVE void
|
|
1217
|
-
mono_wasm_enable_on_demand_gc (int enable)
|
|
1218
|
-
{
|
|
1219
|
-
mono_wasm_enable_gc = enable ? 1 : 0;
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1222
|
-
EMSCRIPTEN_KEEPALIVE void
|
|
1223
|
-
mono_wasm_intern_string_ref (MonoString **string)
|
|
1224
|
-
{
|
|
1225
|
-
MONO_ENTER_GC_UNSAFE;
|
|
1226
|
-
mono_gc_wbarrier_generic_store_atomic(string, (MonoObject *)mono_string_intern (*string));
|
|
1227
|
-
MONO_EXIT_GC_UNSAFE;
|
|
1228
|
-
}
|
|
1229
|
-
|
|
1230
|
-
EMSCRIPTEN_KEEPALIVE void
|
|
1231
|
-
mono_wasm_string_get_data_ref (
|
|
1232
|
-
MonoString **string, mono_unichar2 **outChars, int *outLengthBytes, int *outIsInterned
|
|
1233
|
-
) {
|
|
1234
|
-
MONO_ENTER_GC_UNSAFE;
|
|
1235
|
-
if (!string || !(*string)) {
|
|
1236
|
-
if (outChars)
|
|
1237
|
-
*outChars = 0;
|
|
1238
|
-
if (outLengthBytes)
|
|
1239
|
-
*outLengthBytes = 0;
|
|
1240
|
-
if (outIsInterned)
|
|
1241
|
-
*outIsInterned = 1;
|
|
1242
|
-
} else {
|
|
1243
|
-
if (outChars)
|
|
1244
|
-
*outChars = mono_string_chars (*string);
|
|
1245
|
-
if (outLengthBytes)
|
|
1246
|
-
*outLengthBytes = mono_string_length (*string) * 2;
|
|
1247
|
-
if (outIsInterned)
|
|
1248
|
-
*outIsInterned = mono_string_instance_is_interned (*string);
|
|
1249
|
-
}
|
|
1250
|
-
MONO_EXIT_GC_UNSAFE;
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1253
|
-
EMSCRIPTEN_KEEPALIVE MonoType *
|
|
1254
|
-
mono_wasm_class_get_type (MonoClass *klass)
|
|
1255
|
-
{
|
|
1256
|
-
if (!klass)
|
|
1257
|
-
return NULL;
|
|
1258
|
-
MonoType *result;
|
|
1259
|
-
MONO_ENTER_GC_UNSAFE;
|
|
1260
|
-
result = mono_class_get_type (klass);
|
|
1261
|
-
MONO_EXIT_GC_UNSAFE;
|
|
1262
|
-
return result;
|
|
1263
|
-
}
|
|
1264
|
-
|
|
1265
|
-
EMSCRIPTEN_KEEPALIVE void
|
|
1266
|
-
mono_wasm_write_managed_pointer_unsafe (PPVOLATILE(MonoObject) destination, PVOLATILE(MonoObject) source) {
|
|
1267
|
-
store_volatile(destination, source);
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
|
-
EMSCRIPTEN_KEEPALIVE void
|
|
1271
|
-
mono_wasm_copy_managed_pointer (PPVOLATILE(MonoObject) destination, PPVOLATILE(MonoObject) source) {
|
|
1272
|
-
copy_volatile(destination, source);
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
#ifdef ENABLE_AOT_PROFILER
|
|
1276
|
-
|
|
1277
|
-
void mono_profiler_init_aot (const char *desc);
|
|
1278
|
-
|
|
1279
|
-
EMSCRIPTEN_KEEPALIVE void
|
|
1280
|
-
mono_wasm_profiler_init_aot (const char *desc)
|
|
1281
|
-
{
|
|
1282
|
-
mono_profiler_init_aot (desc);
|
|
1283
|
-
}
|
|
1284
|
-
|
|
1285
|
-
#endif
|
|
1286
|
-
|
|
1287
|
-
#ifdef ENABLE_BROWSER_PROFILER
|
|
1288
|
-
|
|
1289
|
-
void mono_profiler_init_browser (const char *desc);
|
|
1290
|
-
|
|
1291
|
-
EMSCRIPTEN_KEEPALIVE void
|
|
1292
|
-
mono_wasm_profiler_init_browser (const char *desc)
|
|
1293
|
-
{
|
|
1294
|
-
mono_profiler_init_browser (desc);
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
#endif
|
|
1298
|
-
|
|
1299
|
-
static void
|
|
1300
|
-
mono_wasm_init_finalizer_thread (void)
|
|
1301
|
-
{
|
|
1302
|
-
// At this time we don't use a dedicated thread for finalization even if threading is enabled.
|
|
1303
|
-
// Finalizers periodically run on the main thread
|
|
1304
|
-
#if 0
|
|
1305
|
-
mono_gc_init_finalizer_thread ();
|
|
1306
|
-
#endif
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
#define I52_ERROR_NONE 0
|
|
1310
|
-
#define I52_ERROR_NON_INTEGRAL 1
|
|
1311
|
-
#define I52_ERROR_OUT_OF_RANGE 2
|
|
1312
|
-
|
|
1313
|
-
#define U52_MAX_VALUE ((1ULL << 53) - 1)
|
|
1314
|
-
#define I52_MAX_VALUE ((1LL << 53) - 1)
|
|
1315
|
-
#define I52_MIN_VALUE -I52_MAX_VALUE
|
|
1316
|
-
|
|
1317
|
-
EMSCRIPTEN_KEEPALIVE double mono_wasm_i52_to_f64 (int64_t *source, int *error) {
|
|
1318
|
-
int64_t value = *source;
|
|
1319
|
-
|
|
1320
|
-
if ((value < I52_MIN_VALUE) || (value > I52_MAX_VALUE)) {
|
|
1321
|
-
*error = I52_ERROR_OUT_OF_RANGE;
|
|
1322
|
-
return NAN;
|
|
1323
|
-
}
|
|
1324
|
-
|
|
1325
|
-
*error = I52_ERROR_NONE;
|
|
1326
|
-
return (double)value;
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
EMSCRIPTEN_KEEPALIVE double mono_wasm_u52_to_f64 (uint64_t *source, int *error) {
|
|
1330
|
-
uint64_t value = *source;
|
|
1331
|
-
|
|
1332
|
-
if (value > U52_MAX_VALUE) {
|
|
1333
|
-
*error = I52_ERROR_OUT_OF_RANGE;
|
|
1334
|
-
return NAN;
|
|
1335
|
-
}
|
|
1336
|
-
|
|
1337
|
-
*error = I52_ERROR_NONE;
|
|
1338
|
-
return (double)value;
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1341
|
-
EMSCRIPTEN_KEEPALIVE int mono_wasm_f64_to_u52 (uint64_t *destination, double value) {
|
|
1342
|
-
if ((value < 0) || (value > U52_MAX_VALUE))
|
|
1343
|
-
return I52_ERROR_OUT_OF_RANGE;
|
|
1344
|
-
if (floor(value) != value)
|
|
1345
|
-
return I52_ERROR_NON_INTEGRAL;
|
|
1346
|
-
|
|
1347
|
-
*destination = (uint64_t)value;
|
|
1348
|
-
return I52_ERROR_NONE;
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
EMSCRIPTEN_KEEPALIVE int mono_wasm_f64_to_i52 (int64_t *destination, double value) {
|
|
1352
|
-
if ((value < I52_MIN_VALUE) || (value > I52_MAX_VALUE))
|
|
1353
|
-
return I52_ERROR_OUT_OF_RANGE;
|
|
1354
|
-
if (floor(value) != value)
|
|
1355
|
-
return I52_ERROR_NON_INTEGRAL;
|
|
1356
|
-
|
|
1357
|
-
*destination = (int64_t)value;
|
|
1358
|
-
return I52_ERROR_NONE;
|
|
1359
|
-
}
|
|
1360
|
-
|
|
1361
|
-
// JS is responsible for freeing this
|
|
1362
|
-
EMSCRIPTEN_KEEPALIVE const char * mono_wasm_method_get_full_name (MonoMethod *method) {
|
|
1363
|
-
return mono_method_get_full_name(method);
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
EMSCRIPTEN_KEEPALIVE const char * mono_wasm_method_get_name (MonoMethod *method) {
|
|
1367
|
-
return mono_method_get_name(method);
|
|
1368
|
-
}
|
|
1369
|
-
|
|
1370
|
-
EMSCRIPTEN_KEEPALIVE float mono_wasm_get_f32_unaligned (const float *src) {
|
|
1371
|
-
return *src;
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
EMSCRIPTEN_KEEPALIVE double mono_wasm_get_f64_unaligned (const double *src) {
|
|
1375
|
-
return *src;
|
|
1376
|
-
}
|
|
1377
|
-
|
|
1378
|
-
EMSCRIPTEN_KEEPALIVE int32_t mono_wasm_get_i32_unaligned (const int32_t *src) {
|
|
1379
|
-
return *src;
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
|
-
EMSCRIPTEN_KEEPALIVE int mono_wasm_is_zero_page_reserved () {
|
|
1383
|
-
// If the stack is above the first 512 bytes of memory this indicates that it is safe
|
|
1384
|
-
// to optimize out null checks for operations that also do a bounds check, like string
|
|
1385
|
-
// and array element loads. (We already know that Emscripten malloc will never allocate
|
|
1386
|
-
// data at 0.) This is the default behavior for Emscripten release builds and is
|
|
1387
|
-
// controlled by the emscripten GLOBAL_BASE option (default value 1024).
|
|
1388
|
-
// clang/llvm may perform this optimization if --low-memory-unused is set.
|
|
1389
|
-
// https://github.com/emscripten-core/emscripten/issues/19389
|
|
1390
|
-
return (emscripten_stack_get_base() > 512) && (emscripten_stack_get_end() > 512);
|
|
1391
|
-
}
|