| OLD | NEW |
| 1 {{+bindTo:partials.standard_nacl_article}} | 1 {{+bindTo:partials.standard_nacl_article}} |
| 2 | 2 |
| 3 <section id="native-client-modules"> | 3 <section id="native-client-modules"> |
| 4 <span id="devcycle-native-client-modules"></span><h1 id="native-client-modules">
<span id="devcycle-native-client-modules"></span>Native Client Modules</h1> | 4 <span id="devcycle-native-client-modules"></span><h1 id="native-client-modules">
<span id="devcycle-native-client-modules"></span>Native Client Modules</h1> |
| 5 <p>This document describes the classes and functions that you need to implement
in | 5 <p>This document describes the classes and functions that you need to implement
in |
| 6 a Native Client module in order for Chrome to load, initialize, and run it. The | 6 a Native Client module in order for Chrome to load, initialize, and run it. The |
| 7 requirements are the same regardless of whether or not the module uses PNaCl, | 7 requirements are the same regardless of whether or not the module uses PNaCl, |
| 8 but depend on whether the module is written in C or C++.</p> | 8 but depend on whether the module is written in C or C++.</p> |
| 9 <div class="contents local" id="contents" style="display: none"> | 9 <div class="contents local" id="contents" style="display: none"> |
| 10 <ul class="small-gap"> | 10 <ul class="small-gap"> |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 <li>Code that defines your own Module class (derived from the <code>pp::Module</
code> | 116 <li>Code that defines your own Module class (derived from the <code>pp::Module</
code> |
| 117 class)</li> | 117 class)</li> |
| 118 <li>Code that defines your own Instance class (derived from the <code>pp:Instanc
e</code> | 118 <li>Code that defines your own Instance class (derived from the <code>pp:Instanc
e</code> |
| 119 class)</li> | 119 class)</li> |
| 120 </ul> | 120 </ul> |
| 121 <p>In the “Hello tutorial” example (in the <code>getting_started/par
t1</code> directory of | 121 <p>In the “Hello tutorial” example (in the <code>getting_started/par
t1</code> directory of |
| 122 the NaCl SDK), these three components are specified in the file | 122 the NaCl SDK), these three components are specified in the file |
| 123 <code>hello_tutorial.cc</code>. Here is the factory function:</p> | 123 <code>hello_tutorial.cc</code>. Here is the factory function:</p> |
| 124 <pre class="prettyprint"> | 124 <pre class="prettyprint"> |
| 125 namespace pp { | 125 namespace pp { |
| 126 Module* CreateModule() { | 126 Module* CreateModule() { |
| 127 return new HelloTutorialModule(); | 127 return new HelloTutorialModule(); |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 </pre> | 130 </pre> |
| 131 <p>The <code>CreateModule()</code> factory function is the main binding point be
tween a | 131 <p>The <code>CreateModule()</code> factory function is the main binding point be
tween a |
| 132 module and the browser, and serves as the entry point into the module. The | 132 module and the browser, and serves as the entry point into the module. The |
| 133 browser calls <code>CreateModule()</code> when a module is first loaded; this fu
nction | 133 browser calls <code>CreateModule()</code> when a module is first loaded; this fu
nction |
| 134 returns a Module object derived from the <code>pp::Module</code> class. The brow
ser keeps | 134 returns a Module object derived from the <code>pp::Module</code> class. The brow
ser keeps |
| 135 a singleton of the Module object.</p> | 135 a singleton of the Module object.</p> |
| 136 <p>Below is the Module class from the “Hello tutorial” example:</p> | 136 <p>Below is the Module class from the “Hello tutorial” example:</p> |
| 137 <pre class="prettyprint"> | 137 <pre class="prettyprint"> |
| 138 class HelloTutorialModule : public pp::Module { | 138 class HelloTutorialModule : public pp::Module { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 166 <a class="reference internal" href="/native-client/devguide/coding/message-syste
m.html"><em>Native Client messaging system</em></a> for more information about | 166 <a class="reference internal" href="/native-client/devguide/coding/message-syste
m.html"><em>Native Client messaging system</em></a> for more information about |
| 167 how to send messages between JavaScript code and Native Client modules.</p> | 167 how to send messages between JavaScript code and Native Client modules.</p> |
| 168 <p>While the <code>CreateModule()</code> factory function, the <code>Module</cod
e> class, and the | 168 <p>While the <code>CreateModule()</code> factory function, the <code>Module</cod
e> class, and the |
| 169 <code>Instance</code> class are required for a Native Client application, the co
de | 169 <code>Instance</code> class are required for a Native Client application, the co
de |
| 170 samples shown above don’t actually do anything. Subsequent documents in th
e | 170 samples shown above don’t actually do anything. Subsequent documents in th
e |
| 171 Developer’s Guide build on these code samples and add more interesting | 171 Developer’s Guide build on these code samples and add more interesting |
| 172 functionality.</p> | 172 functionality.</p> |
| 173 </section> | 173 </section> |
| 174 | 174 |
| 175 {{/partials.standard_nacl_article}} | 175 {{/partials.standard_nacl_article}} |
| OLD | NEW |