コード例 #1
0
ファイル: Host.cs プロジェクト: riclxu/wasmtime
        /// <summary>
        /// Defines a WASI implementation in the host.
        /// </summary>
        /// <param name="name">The name of the WASI module to define.</param>
        /// <param name="config">The <see cref="WasiConfiguration"/> to configure the WASI implementation with.</param>
        public void DefineWasi(string name, WasiConfiguration config = null)
        {
            CheckDisposed();

            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Name cannot be null or empty.", nameof(name));
            }

            if (config is null)
            {
                config = new WasiConfiguration();
            }

            using var wasi = config.CreateWasi(Store, name);

            if (!Interop.wasmtime_linker_define_wasi(Linker, wasi))
            {
                throw new WasmtimeException($"Failed to define WASI module '{name}'.");
            }
        }
コード例 #2
0
ファイル: Host.cs プロジェクト: yvt/wasmtime-dotnet
        /// <summary>
        /// Defines a WASI implementation in the host.
        /// </summary>
        /// <param name="name">The name of the WASI module to define.</param>
        /// <param name="config">The <see cref="WasiConfiguration"/> to configure the WASI implementation with.</param>
        public void DefineWasi(string name, WasiConfiguration config = null)
        {
            CheckDisposed();

            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Name cannot be null or empty.", nameof(name));
            }

            if (config is null)
            {
                config = new WasiConfiguration();
            }

            using var wasi = config.CreateWasi(Store, name);

            var error = Interop.wasmtime_linker_define_wasi(Linker, wasi);

            if (error != IntPtr.Zero)
            {
                throw WasmtimeException.FromOwnedError(error);
            }
        }