| OLD | NEW |
| 1 .. _tutorial: | 1 .. _tutorial: |
| 2 | 2 |
| 3 ###################################### | 3 ###################################### |
| 4 C++ Tutorial: Getting Started (Part 1) | 4 C++ Tutorial: Getting Started (Part 1) |
| 5 ###################################### | 5 ###################################### |
| 6 | 6 |
| 7 .. contents:: | 7 .. contents:: |
| 8 :local: | 8 :local: |
| 9 :backlinks: none | 9 :backlinks: none |
| 10 :depth: 2 | 10 :depth: 2 |
| 11 | 11 |
| 12 Overview | 12 Overview |
| 13 ======== | 13 ======== |
| 14 | 14 |
| 15 This tutorial shows how to build and run a web application using Portable Native | 15 This tutorial shows how to build and run a web application using Portable Native |
| 16 Client (PNaCl). This is a client-side application that uses HTML, JavaScript and | 16 Client (PNaCl). This is a client-side application that uses HTML, JavaScript and |
| 17 a Native Client module written in C++. The PNaCl toolchain is used to enable | 17 a Native Client module written in C++. The PNaCl toolchain is used to enable |
| 18 running the Native Client module directly from a web page. | 18 running the Native Client module directly from a web page. |
| 19 | 19 |
| 20 It's recommended to read the :doc:`Native Client Technical Overview | 20 It's recommended that you read the :doc:`Native Client Technical Overview |
| 21 </overview>` prior to going through this tutorial. | 21 </overview>` prior to going through this tutorial. |
| 22 | 22 |
| 23 What the application in this tutorial does | 23 What the application in this tutorial does |
| 24 ------------------------------------------ | 24 ------------------------------------------ |
| 25 | 25 |
| 26 The application in this tutorial shows how to load a Native Client module in a | 26 The application in this tutorial shows how to load a Native Client module in a |
| 27 web page, and how to send messages between JavaScript and the C++ code in the | 27 web page, and how to send messages between JavaScript and the Native Client |
| 28 Native Client module. In this simple application, the JavaScript code in the web | 28 module. In this simple application, the JavaScript sends a ``'hello'`` message |
| 29 page sends a ``'hello'`` message to the Native Client module. When the Native | 29 to the Native Client module. When the Native Client module receives a message, |
| 30 Client module receives a message, it checks whether the message is equal to the | 30 it checks whether the message is equal to the string ``'hello'``. If it is, the |
| 31 string ``'hello'``. If it is, the Native Client module returns a message saying | 31 Native Client module returns a message saying ``'hello from NaCl'``. A |
| 32 ``'hello from NaCl'``. A JavaScript alert panel displays the message received | 32 JavaScript alert panel displays the message received from the Native Client |
| 33 from the Native Client module. | 33 module. |
| 34 | 34 |
| 35 Communication between JavaScript and Native Client modules | 35 Communication between JavaScript and Native Client modules |
| 36 ---------------------------------------------------------- | 36 ---------------------------------------------------------- |
| 37 | 37 |
| 38 The Native Client programming model supports bidirectional communication between | 38 The Native Client programming model supports bidirectional communication between |
| 39 JavaScript and the Native Client module (C/C++ code). Both sides can initiate | 39 JavaScript and the Native Client module. Both sides can initiate |
| 40 and respond to messages. In all cases, the communication is asynchronous: The | 40 and respond to messages. In all cases, the communication is asynchronous: The |
| 41 caller (JavaScript or the Native Client module) sends a message, but the caller | 41 caller (JavaScript or the Native Client module) sends a message, but the caller |
| 42 does not wait for, or may not even expect, a response. This behavior is | 42 does not wait for, or may not even expect, a response. This behavior is |
| 43 analogous to client/server communication on the web, where the client posts a | 43 analogous to client/server communication on the web, where the client posts a |
| 44 message to the server and returns immediately. The Native Client messaging | 44 message to the server and returns immediately. The Native Client messaging |
| 45 system is part of the Pepper API, and is described in detail in | 45 system is part of the Pepper API, and is described in detail in |
| 46 :doc:`Developer's Guide: Messaging System </devguide/coding/message-system>`. | 46 :doc:`Developer's Guide: Messaging System </devguide/coding/message-system>`. |
| 47 It is also similar to the way `web workers | 47 It is also similar to the way `web workers |
| 48 <http://en.wikipedia.org/wiki/Web_worker>`_ interact with the main document in | 48 <http://en.wikipedia.org/wiki/Web_worker>`_ interact with the main document in |
| 49 JavaScript. | 49 JavaScript. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 69 $ cd pepper_$(VERSION)/getting_started | 69 $ cd pepper_$(VERSION)/getting_started |
| 70 $ make serve | 70 $ make serve |
| 71 | 71 |
| 72 .. Note:: | 72 .. Note:: |
| 73 :class: note | 73 :class: note |
| 74 | 74 |
| 75 The SDK may consist of several "bundles", one per Chrome/Pepper version (see | 75 The SDK may consist of several "bundles", one per Chrome/Pepper version (see |
| 76 :doc:`versioning information </version>`). In the sample invocation above | 76 :doc:`versioning information </version>`). In the sample invocation above |
| 77 ``pepper_$(VERSION)`` refers to the specific version you want to use. For | 77 ``pepper_$(VERSION)`` refers to the specific version you want to use. For |
| 78 example, ``pepper_31``. If you don't know which version you need, use the | 78 example, ``pepper_31``. If you don't know which version you need, use the |
| 79 one labeled ``(stable)`` by ``naclsdk list``. See :doc:`Download the Native | 79 one labeled ``(stable)`` by the ``naclsdk list`` command. See |
| 80 Client SDK </sdk/download>` for more details. | 80 :doc:`Download the Native Client SDK </sdk/download>` for more details. |
| 81 | 81 |
| 82 If no port number is specified, the server defaults to port 5103, and can be | 82 If no port number is specified, the server defaults to port 5103, and can be |
| 83 accessed at ``http://localhost:5103``. | 83 accessed at ``http://localhost:5103``. |
| 84 | 84 |
| 85 Any server can be used for the purpose of development. The one provided with the | 85 Any server can be used for the purpose of development. The one provided with the |
| 86 SDK is just a convenience, not a requirement. | 86 SDK is just a convenience, not a requirement. |
| 87 | 87 |
| 88 .. _tutorial_step_3: | 88 .. _tutorial_step_3: |
| 89 | 89 |
| 90 Step 3: Set up the Chrome browser | 90 Step 3: Set up the Chrome browser |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 There's more information about troubleshooting in the documentation: | 273 There's more information about troubleshooting in the documentation: |
| 274 | 274 |
| 275 * :ref:`FAQ Troubleshooting <faq_troubleshooting>`. | 275 * :ref:`FAQ Troubleshooting <faq_troubleshooting>`. |
| 276 * The :doc:`Progress Events </devguide/coding/progress-events>` document | 276 * The :doc:`Progress Events </devguide/coding/progress-events>` document |
| 277 contains some useful information about handling error events. | 277 contains some useful information about handling error events. |
| 278 | 278 |
| 279 Next steps | 279 Next steps |
| 280 ========== | 280 ========== |
| 281 | 281 |
| 282 * See the :doc:`Application Structure </devguide/coding/application-structure>` | 282 * See the :doc:`Application Structure </devguide/coding/application-structure>` |
| 283 chapter in the Developer's Guide for information about how to structure a | 283 section in the Developer's Guide for information about how to structure a |
| 284 Native Client module. | 284 Native Client module. |
| 285 * Check the `C++ Reference </native-client/pepper_stable/cpp>`_ for details | 285 * Check the `C++ Reference </native-client/pepper_stable/cpp>`_ for details |
| 286 about how to use the Pepper APIs. | 286 about how to use the Pepper APIs. |
| 287 * Browse through the source code of the SDK examples (in the ``examples`` | 287 * Browse through the source code of the SDK examples (in the ``examples`` |
| 288 directory) to learn additional techniques for writing Native Client | 288 directory) to learn additional techniques for writing Native Client |
| 289 applications and using the Pepper APIs. | 289 applications and using the Pepper APIs. |
| 290 * See the :doc:`Building </devguide/devcycle/building>`, :doc:`Running | 290 * See the :doc:`Building </devguide/devcycle/building>`, :doc:`Running |
| 291 </devguide/devcycle/running>`, and :doc:`Debugging pages | 291 </devguide/devcycle/running>`, and :doc:`Debugging pages |
| 292 </devguide/devcycle/debugging>` for information about how to build, run, and | 292 </devguide/devcycle/debugging>` for information about how to build, run, and |
| 293 debug Native Client applications. | 293 debug Native Client applications. |
| 294 * Check the `naclports <http://code.google.com/p/naclports/>`_ project to see | 294 * Check the `naclports <http://code.google.com/p/naclports/>`_ project to see |
| 295 what libraries have been ported for use with Native Client. If you port an | 295 what libraries have been ported for use with Native Client. If you port an |
| 296 open-source library for your own use, we recommend adding it to naclports | 296 open-source library for your own use, we recommend adding it to naclports |
| 297 (see `How to check code into naclports | 297 (see `How to check code into naclports |
| 298 <http://code.google.com/p/naclports/wiki/HowTo_Checkin>`_). | 298 <http://code.google.com/p/naclports/wiki/HowTo_Checkin>`_). |
| OLD | NEW |