diff options
Diffstat (limited to 'files/ja/web/javascript/reference/global_objects/webassembly/module/index.html')
-rw-r--r-- | files/ja/web/javascript/reference/global_objects/webassembly/module/index.html | 95 |
1 files changed, 0 insertions, 95 deletions
diff --git a/files/ja/web/javascript/reference/global_objects/webassembly/module/index.html b/files/ja/web/javascript/reference/global_objects/webassembly/module/index.html deleted file mode 100644 index 36fabff4a2..0000000000 --- a/files/ja/web/javascript/reference/global_objects/webassembly/module/index.html +++ /dev/null @@ -1,95 +0,0 @@ ---- -title: WebAssembly.Module -slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/Module -tags: - - API - - Constructor - - Experimental - - JavaScript - - Module - - Reference - - WebAssembly -translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Module ---- -<div>{{JSRef}}</div> - -<p><strong><code>WebAssembly.Module</code></strong> オブジェクトには、ブラウザーでコンパイルされたステートレスな WebAssembly コードが含まれています。これを効率的に<a href="/ja/docs/Web/API/Worker/postMessage">ワーカー間で共有</a>したり、複数回インスタンス化したりすることができます。</p> - -<h2 id="Constructor" name="Constructor">コンストラクター</h2> - -<dl> - <dt>{{jsxref("Global_Objects/WebAssembly/Module/Module", "WebAssembly.Module()")}}</dt> - <dd>新しい <code>Module</code> オブジェクトを生成します。</dd> -</dl> - -<h2 id="Static_properties" name="Static_properties">静的プロパティ</h2> - -<dl> - <dt>{{jsxref("Global_Objects/WebAssembly/Module/customSections", "WebAssembly.Module.customSections()")}}</dt> - <dd><code>Module</code> と文字列を指定すると、モジュール内の与えられた文字列を名前に持つ全てのカスタムセクションの内容を返します。</dd> - <dt>{{jsxref("Global_Objects/WebAssembly/Module/exports", "WebAssembly.Module.exports()")}}</dt> - <dd><code>Module</code> を指定すると、エクスポート宣言の情報を配列として返します。</dd> - <dt>{{jsxref("Global_Objects/WebAssembly/Module/imports", "WebAssembly.Module.imports()")}}</dt> - <dd><code>Module</code> を指定すると、インポート宣言の情報を配列として返します。</dd> -</dl> - -<h2 id="Examples" name="Examples">例</h2> - -<h3 id="Sending_a_compiled_module_to_a_worker" name="Sending_a_compiled_module_to_a_worker">コンパイル済みのモジュールをワーカーに送信</h3> - -<p>以下の例では (GitHub 上の <a href="https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/index-compile.html">index-compile.html</a> および<a href="https://mdn.github.io/webassembly-examples/js-api-examples/index-compile.html">ライブ表示</a>も参照してください)、読み込まれた <code>simple.wasm</code> のバイトコードを {{jsxref("WebAssembly.compileStreaming()")}} メソッドでコンパイルし、結果の <code>Module</code> インスタンスを<a href="/ja/docs/Web/API/Web_Workers_API">ワーカー</a>へ、 {{domxref("Worker/postMessage", "postMessage()")}} を使用して送信します。</p> - -<pre class="brush: js notranslate">var worker = new Worker("wasm_worker.js"); - -WebAssembly.compileStreaming(fetch('simple.wasm')) -.then(mod => - worker.postMessage(mod) -);</pre> - -<p>ワーカー内では (<code><a href="https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/wasm_worker.js">wasm_worker.js</a></code> を参照)、モジュールを使用するための import オブジェクトを定義し、メインスレッドからモジュールを受け取るためのイベントハンドラーをセットアップします。モジュールを受け取ったら、 {{jsxref("WebAssembly.instantiate()")}} メソッドを使ってインスタンスを作成し、その中からエクスポートされた関数を呼び出します。</p> - -<pre class="brush: js notranslate">var importObject = { - imports: { - imported_func: function(arg) { - console.log(arg); - } - } -}; - -onmessage = function(e) { - console.log('module received from main thread'); - var mod = e.data; - - WebAssembly.instantiate(mod, importObject).then(function(instance) { - instance.exports.exported_func(); - }); -};</pre> - -<h2 id="Specifications" name="Specifications">仕様書</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">仕様書</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('WebAssembly JS', '#modules', 'WebAssembly.Module()')}}</td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> - -<div> -<p>{{Compat("javascript.builtins.WebAssembly.Module")}}</p> -</div> - -<h2 id="See_also" name="See_also">関連情報</h2> - -<ul> - <li><a href="/ja/docs/WebAssembly">WebAssembly</a> 概要ページ</li> - <li><a href="/ja/docs/WebAssembly/Concepts">WebAssembly の概念</a></li> - <li><a href="/ja/docs/WebAssembly/Using_the_JavaScript_API">WebAssembly JavaScript API の使用</a></li> -</ul> |