| Index: ppapi/examples/scripting/post_message.cc
|
| diff --git a/ppapi/examples/scripting/post_message.cc b/ppapi/examples/scripting/post_message.cc
|
| index 24f79271bc3ac30e34c0e8947473d8907a0071db..1faa0c1df646cda502013280eb106461ec0f8420 100644
|
| --- a/ppapi/examples/scripting/post_message.cc
|
| +++ b/ppapi/examples/scripting/post_message.cc
|
| @@ -4,6 +4,10 @@
|
|
|
| #include <algorithm>
|
|
|
| +#include <stdio.h>
|
| +#include <string.h>
|
| +
|
| +#include "ppapi/cpp/dev/var_array_buffer_dev.h"
|
| #include "ppapi/cpp/instance.h"
|
| #include "ppapi/cpp/module.h"
|
| #include "ppapi/cpp/var.h"
|
| @@ -26,10 +30,17 @@ class MyInstance : public pp::Instance {
|
| void MyInstance::HandleMessage(const pp::Var& message_data) {
|
| if (message_data.is_string()) {
|
| std::string string_copy(message_data.AsString());
|
| - std::reverse(string_copy.begin(), string_copy.end());
|
| - bool is_palindrome(message_data.AsString() == string_copy);
|
| + pp::VarArrayBuffer_Dev buff(string_copy.size());
|
| + char* str = static_cast<char*>(buff.Map());
|
| + memcpy(str, string_copy.c_str(), buff.ByteLength());
|
|
|
| - PostMessage(pp::Var(is_palindrome));
|
| + PostMessage(buff);
|
| + } else if (message_data.is_array_buffer()) {
|
| + pp::VarArrayBuffer_Dev buff_var(message_data);
|
| + char* buff = static_cast<char*>(buff_var.Map());
|
| + for (size_t i=0; i < buff_var.ByteLength(); ++i)
|
| + printf("%d ", int(buff[i]));
|
| + printf("\n");
|
| }
|
| }
|
|
|
|
|