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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « examples/srpc/duality/npp_gate.cc ('k') | examples/srpc/duality/scriptable.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: examples/srpc/duality/scriptable.h
===================================================================
--- examples/srpc/duality/scriptable.h (revision 0)
+++ examples/srpc/duality/scriptable.h (revision 0)
@@ -0,0 +1,66 @@
+// Copyright 2010 The Native Client SDK Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can
+// be found in the LICENSE file.
+
+#ifndef EXAMPLES_SRPC_DUALITY_SCRIPTABLE_H_
+#define EXAMPLES_SRPC_DUALITY_SCRIPTABLE_H_
+
+
+#include <string.h>
+
+#include <nacl/nacl_npapi.h>
+
+#include <map>
+
+// Extend this class and add object-specific functions and properties to the
+// method table and property table.
+class Scriptable {
+ public:
+ Scriptable();
+ virtual ~Scriptable();
+
+ // Ensures that members are initialized.
+ virtual void Init();
+
+ bool GetProperty(NPIdentifier name, NPVariant *result);
+
+ bool HasMethod(NPIdentifier name) const;
+
+ bool HasProperty(NPIdentifier name) const;
+
+ bool Invoke(NPIdentifier method_name,
+ const NPVariant* args,
+ uint32_t arg_count,
+ NPVariant* result);
+
+ bool InvokeDefault(const NPVariant* args,
+ uint32_t arg_count,
+ NPVariant* result);
+
+ bool RemoveProperty(NPIdentifier name);
+
+ bool SetProperty(NPIdentifier name, const NPVariant* value);
+
+ protected:
+ // These can't be scriptable::functions because that would make this
+ // uninheritable.
+ typedef bool (*Method)(Scriptable* instance,
+ const NPVariant* args,
+ uint32_t arg_count,
+ NPVariant* result);
+ typedef bool (*Property)(Scriptable* instance,
+ NPVariant* result);
+
+ typedef std::map<NPIdentifier, Method> IdentifierToMethodMap;
+ typedef std::map<NPIdentifier, Property> IdentifierToPropertyMap;
+
+ // Implemented by the final class.
+ virtual void InitializeMethodTable() = 0;
+ // Implemented by the final class.
+ virtual void InitializePropertyTable() = 0;
+
+ IdentifierToMethodMap * method_table_;
+ IdentifierToPropertyMap * property_table_;
+};
+
+#endif // EXAMPLES_SRPC_DUALITY_SCRIPTABLE_H_
« 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