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

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

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/npp_gate.cc ('k') | examples/srpc/duality/scriptable.cc » ('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 #ifndef EXAMPLES_SRPC_DUALITY_SCRIPTABLE_H_
6 #define EXAMPLES_SRPC_DUALITY_SCRIPTABLE_H_
7
8
9 #include <string.h>
10
11 #include <nacl/nacl_npapi.h>
12
13 #include <map>
14
15 // Extend this class and add object-specific functions and properties to the
16 // method table and property table.
17 class Scriptable {
18 public:
19 Scriptable();
20 virtual ~Scriptable();
21
22 // Ensures that members are initialized.
23 virtual void Init();
24
25 bool GetProperty(NPIdentifier name, NPVariant *result);
26
27 bool HasMethod(NPIdentifier name) const;
28
29 bool HasProperty(NPIdentifier name) const;
30
31 bool Invoke(NPIdentifier method_name,
32 const NPVariant* args,
33 uint32_t arg_count,
34 NPVariant* result);
35
36 bool InvokeDefault(const NPVariant* args,
37 uint32_t arg_count,
38 NPVariant* result);
39
40 bool RemoveProperty(NPIdentifier name);
41
42 bool SetProperty(NPIdentifier name, const NPVariant* value);
43
44 protected:
45 // These can't be scriptable::functions because that would make this
46 // uninheritable.
47 typedef bool (*Method)(Scriptable* instance,
48 const NPVariant* args,
49 uint32_t arg_count,
50 NPVariant* result);
51 typedef bool (*Property)(Scriptable* instance,
52 NPVariant* result);
53
54 typedef std::map<NPIdentifier, Method> IdentifierToMethodMap;
55 typedef std::map<NPIdentifier, Property> IdentifierToPropertyMap;
56
57 // Implemented by the final class.
58 virtual void InitializeMethodTable() = 0;
59 // Implemented by the final class.
60 virtual void InitializePropertyTable() = 0;
61
62 IdentifierToMethodMap * method_table_;
63 IdentifierToPropertyMap * property_table_;
64 };
65
66 #endif // EXAMPLES_SRPC_DUALITY_SCRIPTABLE_H_
OLDNEW
« no previous file with comments | « examples/srpc/duality/npp_gate.cc ('k') | examples/srpc/duality/scriptable.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698