summaryrefslogtreecommitdiffstats
path: root/gpu/np_utils/np_class.h
diff options
context:
space:
mode:
authorapatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-25 00:01:32 +0000
committerapatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-25 00:01:32 +0000
commit96449d2cf2f37ffcab09ad8e15d9d6f3534271cb (patch)
tree7d603b2bc43bea75362248d27e54c5ce51017fdf /gpu/np_utils/np_class.h
parentfd50fb2b7e19a6589270a02a28fb4dea5b6f38d3 (diff)
downloadchromium_src-96449d2cf2f37ffcab09ad8e15d9d6f3534271cb.zip
chromium_src-96449d2cf2f37ffcab09ad8e15d9d6f3534271cb.tar.gz
chromium_src-96449d2cf2f37ffcab09ad8e15d9d6f3534271cb.tar.bz2
Landing the GPU process and command buffer code again, this time with a DEPS file with the necessary include rules.
TEST=none BUG=none git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33006 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/np_utils/np_class.h')
-rw-r--r--gpu/np_utils/np_class.h125
1 files changed, 125 insertions, 0 deletions
diff --git a/gpu/np_utils/np_class.h b/gpu/np_utils/np_class.h
new file mode 100644
index 0000000..21d1d4b
--- /dev/null
+++ b/gpu/np_utils/np_class.h
@@ -0,0 +1,125 @@
+// Copyright (c) 2006-2008 The Chromium 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 GPU_NP_UTILS_NP_CLASS_H_
+#define GPU_NP_UTILS_NP_CLASS_H_
+
+#include "gpu/np_utils/np_object_pointer.h"
+#include "gpu/np_utils/np_headers.h"
+
+// This file implements NPGetClass<T>. This function returns an NPClass
+// that can be used to instantiate an NPObject subclass T. The NPClass
+// function pointers will invoke the most derived corresponding member
+// functions in T.
+
+namespace np_utils {
+
+namespace np_class_impl {
+ // This template version of the NPClass allocate function creates a subclass
+ // of BaseNPObject.
+ template <typename NPObjectType>
+ static NPObject* Allocate(NPP npp, NPClass*) {
+ return new NPObjectType(npp);
+ }
+
+ // These implementations of the NPClass functions forward to the virtual
+ // functions in DefaultNPObject.
+ template <typename NPObjectType>
+ static void Deallocate(NPObject* object) {
+ delete static_cast<NPObjectType*>(object);
+ }
+
+ template <typename NPObjectType>
+ static void Invalidate(NPObject* object) {
+ return static_cast<NPObjectType*>(object)->Invalidate();
+ }
+
+ template <typename NPObjectType>
+ static bool HasMethod(NPObject* object, NPIdentifier name) {
+ return static_cast<NPObjectType*>(object)->HasMethod(name);
+ }
+
+ template <typename NPObjectType>
+ static bool Invoke(NPObject* object,
+ NPIdentifier name,
+ const NPVariant* args,
+ uint32_t num_args,
+ NPVariant* result) {
+ return static_cast<NPObjectType*>(object)->Invoke(
+ name, args, num_args, result);
+ }
+
+ template <typename NPObjectType>
+ static bool InvokeDefault(NPObject* object,
+ const NPVariant* args,
+ uint32_t num_args,
+ NPVariant* result) {
+ return static_cast<NPObjectType*>(object)->InvokeDefault(
+ args, num_args, result);
+ }
+
+ template <typename NPObjectType>
+ static bool HasProperty(NPObject* object, NPIdentifier name) {
+ return static_cast<NPObjectType*>(object)->HasProperty(name);
+ }
+
+ template <typename NPObjectType>
+ static bool GetProperty(NPObject* object,
+ NPIdentifier name,
+ NPVariant* result) {
+ return static_cast<NPObjectType*>(object)->GetProperty(name, result);
+ }
+
+ template <typename NPObjectType>
+ static bool SetProperty(NPObject* object,
+ NPIdentifier name,
+ const NPVariant* value) {
+ return static_cast<NPObjectType*>(object)->SetProperty(name, value);
+ }
+
+ template <typename NPObjectType>
+ static bool RemoveProperty(NPObject* object, NPIdentifier name) {
+ return static_cast<NPObjectType*>(object)->RemoveProperty(name);
+ }
+
+ template <typename NPObjectType>
+ static bool Enumerate(NPObject* object,
+ NPIdentifier** names,
+ uint32_t* count) {
+ return static_cast<NPObjectType*>(object)->Enumerate(names, count);
+ };
+
+ template <typename NPObjectType>
+ static bool Construct(NPObject* object,
+ const NPVariant* args,
+ uint32_t num_args,
+ NPVariant* result) {
+ return static_cast<NPObjectType*>(object)->Construct(
+ args, num_args, result);
+ }
+} // namespace np_class_impl;
+
+template <typename NPObjectType>
+const NPClass* NPGetClass() {
+ static const NPClass np_class = {
+ NP_CLASS_STRUCT_VERSION,
+ np_class_impl::Allocate<NPObjectType>,
+ np_class_impl::Deallocate<NPObjectType>,
+ np_class_impl::Invalidate<NPObjectType>,
+ np_class_impl::HasMethod<NPObjectType>,
+ np_class_impl::Invoke<NPObjectType>,
+ np_class_impl::InvokeDefault<NPObjectType>,
+ np_class_impl::HasProperty<NPObjectType>,
+ np_class_impl::GetProperty<NPObjectType>,
+ np_class_impl::SetProperty<NPObjectType>,
+ np_class_impl::RemoveProperty<NPObjectType>,
+ np_class_impl::Enumerate<NPObjectType>,
+ np_class_impl::Construct<NPObjectType>,
+ };
+ return &np_class;
+};
+
+} // namespace np_utils
+
+#endif // GPU_NP_UTILS_NP_CLASS_H_