aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/javascript/reference/global_objects/webassembly/instance
diff options
context:
space:
mode:
authorFlorian Merz <me@fiji-flo.de>2021-02-11 12:36:08 +0100
committerFlorian Merz <me@fiji-flo.de>2021-02-11 12:36:08 +0100
commit39f2114f9797eb51994966c6bb8ff1814c9a4da8 (patch)
tree66dbd9c921f56e440f8816ed29ac23682a1ac4ef /files/fr/web/javascript/reference/global_objects/webassembly/instance
parent8260a606c143e6b55a467edf017a56bdcd6cba7e (diff)
downloadtranslated-content-39f2114f9797eb51994966c6bb8ff1814c9a4da8.tar.gz
translated-content-39f2114f9797eb51994966c6bb8ff1814c9a4da8.tar.bz2
translated-content-39f2114f9797eb51994966c6bb8ff1814c9a4da8.zip
unslug fr: move
Diffstat (limited to 'files/fr/web/javascript/reference/global_objects/webassembly/instance')
-rw-r--r--files/fr/web/javascript/reference/global_objects/webassembly/instance/exports/index.html71
-rw-r--r--files/fr/web/javascript/reference/global_objects/webassembly/instance/index.html81
2 files changed, 152 insertions, 0 deletions
diff --git a/files/fr/web/javascript/reference/global_objects/webassembly/instance/exports/index.html b/files/fr/web/javascript/reference/global_objects/webassembly/instance/exports/index.html
new file mode 100644
index 0000000000..cec4fddea3
--- /dev/null
+++ b/files/fr/web/javascript/reference/global_objects/webassembly/instance/exports/index.html
@@ -0,0 +1,71 @@
+---
+title: WebAssembly.Instance.prototype.exports
+slug: Web/JavaScript/Reference/Objets_globaux/WebAssembly/Instance/exports
+tags:
+ - API
+ - Experimental
+ - JavaScript
+ - Propriété
+ - Reference
+ - WebAssembly
+ - instance
+translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/exports
+---
+<div>{{JSRef}}</div>
+
+<p>La propriété <strong><code>exports</code></strong> du prototype de {{jsxref("WebAssembly.Instance")}} est une propriété en lecture seul qui renvoie un objet dont les propriétés sont les différentes fonctions exportées depuis l'instance du module WebAssembly. Cela permet d'y accéder et de les manipuler en JavaScript.</p>
+
+<pre class="syntaxbox">instance.exports</pre>
+
+<h2 id="Exemples">Exemples</h2>
+
+<p>Après avoir récupéré le <em>bytecode</em> WebAssembly grâce à la méthode <code>fetch()</code>, on le compile et on instancie le module grâce à la fonction {{jsxref("WebAssembly.instantiateStreaming()")}}. Lorsqu'on utilise cette fonction, on importe une fonction dans le module. Ensuite, on appelle <a href="/fr/docs/WebAssembly/Exported_functions">une fonction WebAssembly exportée</a> qui est exposée via l'instance.</p>
+
+<pre class="brush: js">var importObject = {
+ imports: {
+ imported_func: function(arg) {
+ console.log(arg);
+ }
+ }
+};
+WebAssembly.instantiateStreaming(fetch('simple.wasm'), importObject)
+.then(obj =&gt; obj.instance.exports.exported_func());</pre>
+
+<div class="note">
+<p><strong>Note :</strong> Voir le fichier <a href="https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/index.html">index.html</a> sur GitHub (ainsi que <a href="https://mdn.github.io/webassembly-examples/js-api-examples/">la démonstration</a>) pour un exemple.</p>
+</div>
+
+<h2 id="Spécifications">Spécifications</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Spécification</th>
+ <th scope="col">État</th>
+ <th scope="col">Commentaires</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('WebAssembly JS', '#webassemblyinstance-objects', 'WebAssembly.Instance objects')}}</td>
+ <td>{{Spec2('WebAssembly JS')}}</td>
+ <td>Brouillon de définition initiale pour WebAssembly.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>
+
+<div>
+<div class="hidden">Ce tableau de compatibilité a été généré à partir de données structurées. Si vous souhaitez contribuer à ces données, n'hésitez pas à envoyer une <em>pull request</em> sur <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a>.</div>
+
+<p>{{Compat("javascript.builtins.WebAssembly.Instance.exports")}}</p>
+</div>
+
+<h2 id="Voir_aussi">Voir aussi</h2>
+
+<ul>
+ <li><a href="/fr/docs/WebAssembly">Le portail WebAssembly</a></li>
+ <li><a href="/fr/docs/WebAssembly/Concepts">Les concepts relatifs à WebAssembly</a></li>
+ <li><a href="/fr/docs/WebAssembly/Using_the_JavaScript_API">Utiliser l'API JavaScript WebAssembly</a></li>
+</ul>
diff --git a/files/fr/web/javascript/reference/global_objects/webassembly/instance/index.html b/files/fr/web/javascript/reference/global_objects/webassembly/instance/index.html
new file mode 100644
index 0000000000..93c6a9b324
--- /dev/null
+++ b/files/fr/web/javascript/reference/global_objects/webassembly/instance/index.html
@@ -0,0 +1,81 @@
+---
+title: WebAssembly.Instance()
+slug: Web/JavaScript/Reference/Objets_globaux/WebAssembly/Instance
+tags:
+ - API
+ - Constructeur
+ - JavaScript
+ - Reference
+ - WebAssembly
+ - instance
+translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance
+---
+<div>{{JSRef}}</div>
+
+<p>Un objet <strong><code>WebAssembly.Instance</code></strong> représente un objet exécutable, avec un état, qui est une instance d'un <a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/WebAssembly/Module">module WebAssembly</a>. Un objet <code>Instance</code> contient l'ensemble <a href="/fr/docs/WebAssembly/Exported_functions">des fonctions WebAssembly exportées</a> qui permettent d'invoquer du code WebAssembly depuis du code JavaScript.</p>
+
+<p>Le constructeur <code>WebAssembly.Instance()</code> peut être appelé afin de créer, de façon synchrone, une instance d'un {{jsxref("WebAssembly.Module")}} donné. Toutefois, pour obtenir une instance, on utilisera généralement la fonction asynchrone {{jsxref("WebAssembly.instantiateStreaming()")}}.</p>
+
+<h2 id="Syntaxe">Syntaxe</h2>
+
+<div class="warning">
+<p><strong>Important </strong>: L'instanciation de modules volumineux peut être coûteuse en temps/ressource. <code>Instance()</code> ne doit être utilisée que lorsqu'une instanciation synchrone est nécessaire. Pour tous les autres cas, c'est la méthode {{jsxref("WebAssembly.instantiateStreaming()")}} qui devrait être utilisée.</p>
+</div>
+
+<pre class="syntaxbox">var monInstance = new WebAssembly.Instance(<em>module</em>, <em>importObject</em>);</pre>
+
+<h3 id="Paramètres">Paramètres</h3>
+
+<dl>
+ <dt><code>module</code></dt>
+ <dd>L'objet <a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/WebAssembly/Module" title="The Module() constructor of the WebAssembly global object creates a new Module object instance."><code>WebAssembly.Module</code></a> qu'on souhaite instancier.</dd>
+ <dt><code>importObject</code> {{optional_inline}}</dt>
+ <dd>Un objet qui contient des valeurs à importer dans l'instance. Ce peuvent être des fonctions ou des objets <a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/WebAssembly/Memory" title="The Memory() constructor of the WebAssembly global object creates a new Memory object instance, which represents a WebAssembly memory. These can be thought of as resizeable array buffers, wrappers around WebAssembly memories."><code>WebAssembly.Memory</code></a>. Il doit exister une propriété correspondante pour chaque import, si ce n'est pas le cas, un exception <code><a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/WebAssembly/LinkError">WebAssembly.LinkError</a></code> sera levée.</dd>
+</dl>
+
+<h2 id="Instances_d'Instance">Instances d'<code>Instance</code></h2>
+
+<p>Toutes les instances du type <code>Instance</code> héritent du prototype du constructeur <code>Instance()</code>. Celui-ci peut être modifié afin de modifier l'ensemble des instances de <code>Instance</code>.</p>
+
+<h3 id="Propriétés">Propriétés</h3>
+
+<p>{{page('/fr/docs/Web/JavaScript/Reference/Objets_globaux/WebAssembly/Instance/prototype', 'Propriétés')}}</p>
+
+<h3 id="Méthodes">Méthodes</h3>
+
+<p>{{page('/fr/docs/Web/JavaScript/Reference/Objets_globaux/WebAssembly/Instance/prototype', 'Méthodes')}}</p>
+
+<h2 id="Spécifications">Spécifications</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Spécification</th>
+ <th scope="col">État</th>
+ <th scope="col">Commentaires</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('WebAssembly JS', '#webassemblyinstance-objects', 'Instance')}}</td>
+ <td>{{Spec2('WebAssembly JS')}}</td>
+ <td>Définition initiale dans un brouillon de spécification.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>
+
+<div>
+<div class="hidden">Ce tableau de compatibilité a été généré à partir de données structurées. Si vous souhaitez contribuer à ces données, n'hésitez pas à envoyer une <em>pull request</em> sur <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a>.</div>
+
+<p>{{Compat("javascript.builtins.WebAssembly.Instance")}}</p>
+</div>
+
+<h2 id="Voir_aussi">Voir aussi</h2>
+
+<ul>
+ <li><a href="/fr/docs/WebAssembly">Le portail WebAssembly</a></li>
+ <li><a href="/fr/docs/WebAssembly/Concepts">Les concepts relatifs à WebAssembly</a></li>
+ <li><a href="/fr/docs/WebAssembly/Using_the_JavaScript_API">Utiliser l'API JavaScript WebAssembly</a></li>
+</ul>