Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: examples/srpc/duality/scriptable.cc

Issue 2856050: Adding srpc example to naclports. (Closed) Base URL: http://naclports.googlecode.com/svn/trunk/src/
Patch Set: '' Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « examples/srpc/duality/scriptable.h ('k') | examples/srpc/duality/scripting_bridge.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2010 The Native Client SDK Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can
3 // be found in the LICENSE file.
4
5
6 #include <string.h>
7
8 #include <nacl/nacl_npapi.h>
9 #include <examples/srpc/duality/scriptable.h>
10
11 #include <map>
12
13
14 Scriptable::Scriptable() : method_table_(NULL), property_table_(NULL) {
15 printf("Duality: Scriptable() was called!\n");
16 fflush(stdout);
17 }
18
19 Scriptable::~Scriptable() {
20 printf("Duality: ~Scriptable() was called!\n");
21 fflush(stdout);
22 if (method_table_ != NULL) {
23 delete method_table_;
24 }
25 if (property_table_ != NULL) {
26 delete property_table_;
27 }
28 }
29
30 void Scriptable::Init() {
31 printf("Duality: Scriptable::Init() was called!\n");
32 fflush(stdout);
33 if (method_table_ == NULL) {
34 method_table_ = new IdentifierToMethodMap();
35 }
36 if (property_table_ == NULL) {
37 property_table_ = new IdentifierToPropertyMap();
38 }
39
40 InitializeMethodTable();
41 InitializePropertyTable();
42 }
43
44 bool Scriptable::GetProperty(NPIdentifier name, NPVariant *result) {
45 printf("Duality: Scriptable::GetProperty was called!\n");
46 fflush(stdout);
47 VOID_TO_NPVARIANT(*result);
48
49 Scriptable::IdentifierToPropertyMap::const_iterator i;
50 i = property_table_->find(name);
51 if (i != property_table_->end()) {
52 return ((i->second))(this, result);
53 }
54 return false;
55 }
56
57 bool Scriptable::HasMethod(NPIdentifier name) const {
58 printf("Duality: Scriptable::HasMethod was called!\n");
59 fflush(stdout);
60 bool have_method = false;
61 Scriptable::IdentifierToMethodMap::const_iterator i;
62 i = method_table_->find(name);
63 if (i != method_table_->end()) {
64 have_method = true;
65 }
66 printf("Duality: Scriptable::HasMethod returning %d!\n", have_method);
67 fflush(stdout);
68 return have_method;
69 }
70
71 bool Scriptable::HasProperty(NPIdentifier name) const {
72 printf("Duality: Scriptable::HasProperty was called!\n");
73 fflush(stdout);
74 bool have_property = false;
75 Scriptable::IdentifierToPropertyMap::const_iterator i;
76 i = property_table_->find(name);
77 if (i != property_table_->end()) {
78 have_property = true;
79 }
80 printf("Duality: Scriptable::HasProperty returning %d!\n",
81 have_property);
82 fflush(stdout);
83 return have_property;
84 }
85
86 bool Scriptable::Invoke(NPIdentifier method_name,
87 const NPVariant* args,
88 uint32_t arg_count,
89 NPVariant* result) {
90 printf("Duality: Scriptable::Invoke was called!\n");
91 fflush(stdout);
92 bool rval = false;
93 Scriptable::IdentifierToMethodMap::const_iterator i;
94 i = method_table_->find(method_name);
95 if (i != method_table_->end()) {
96 rval = (i->second)(this, args, arg_count, result);
97 }
98 return rval;
99 }
100
101 bool Scriptable::InvokeDefault(const NPVariant* args,
102 uint32_t arg_count,
103 NPVariant* result) {
104 printf("Duality: Scriptable::InvokeDefault was called!\n");
105 fflush(stdout);
106 return false; // Not implemented.
107 }
108
109 bool Scriptable::RemoveProperty(NPIdentifier name) {
110 printf("Duality: Scriptable::RemoveProperty was called!\n");
111 fflush(stdout);
112 return false; // Not implemented.
113 }
114
115 bool Scriptable::SetProperty(NPIdentifier name, const NPVariant* value) {
116 printf("Duality: Scriptable::SetProperty was called!\n");
117 fflush(stdout);
118 return false; // Not implemented.
119 }
OLDNEW
« no previous file with comments | « examples/srpc/duality/scriptable.h ('k') | examples/srpc/duality/scripting_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698