tmp
Friday, October 11, 2013
Native Client Tutorial 2
[前回の続き](http://fiahfy.blogspot.jp/2013/10/native-client-tutorial-example.html) [Step 4: Create a set of stub files for your application.](https://developers.google.com/native-client/devguide/tutorial#templates) * [hello_tutorial.zip](https://developers.google.com/native-client/devguide/hello_tutorial.zip) をDLして解凍 * hello_tutorial をexampleの中へ ```bash $ mv hello_tutorial nacl_sdk/pepper_30/examples/ ``` * make ```bash $ cd nacl_sdk/pepper_30/examples/hello_tutorial $ make ``` *
を表示 LOADING.. -> SUCCESSが表示されればおk (nacl_sdk/pepper_30/tools/httpd.py は起動しておく) * hello_tutorial.html に以下を追加 ```javascript // Indicate load success. function moduleDidLoad() { HelloTutorialModule = document.getElementById('hello_tutorial'); updateStatus('SUCCESS'); // 追加 HelloTutorialModule.postMessage('hello'); } ``` * hello_tutorial.cc に以下追加 ```cs #include
#include
#include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/var.h" // 追加 namespace { const char* const kHelloString = "hello"; const char* const kReplyString = "hello from NaCl"; } // namespace ``` ```cs virtual void HandleMessage(const pp::Var& var_message) { // 追加 if (!var_message.is_string()) return; std::string message = var_message.AsString(); pp::Var var_reply; if (message == kHelloString) { var_reply = pp::Var(kReplyString); PostMessage(var_reply); } } ``` * make ```bash $ make ``` *
を表示 alertで `hello from NaCl` と表示される 表示されない場合は httpd.py, chrome を再起動とかしてみる
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment