summaryrefslogtreecommitdiffstats
path: root/o3d/gpu/np_utils/np_dispatcher_specializations.h
diff options
context:
space:
mode:
Diffstat (limited to 'o3d/gpu/np_utils/np_dispatcher_specializations.h')
-rw-r--r--o3d/gpu/np_utils/np_dispatcher_specializations.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/o3d/gpu/np_utils/np_dispatcher_specializations.h b/o3d/gpu/np_utils/np_dispatcher_specializations.h
new file mode 100644
index 0000000..62fb8c4
--- /dev/null
+++ b/o3d/gpu/np_utils/np_dispatcher_specializations.h
@@ -0,0 +1,85 @@
+// 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.
+
+// There is deliberately no header guard here. This file is included multiple
+// times, once for each dispatcher specialiation arity. Do not include this
+// file directly. Include np_dispatcher.h instead.
+
+template <typename NPObjectType PARAM_TYPENAMES>
+class NPDispatcher<NPObjectType, void(PARAM_TYPES)>
+ : public BaseNPDispatcher {
+ typedef void (NPObjectType::*FunctionType)(PARAM_TYPES);
+ public:
+ NPDispatcher(BaseNPDispatcher* next,
+ const NPUTF8* name,
+ FunctionType function)
+ : BaseNPDispatcher(next, name),
+ function_(function) {
+ }
+
+ virtual bool Invoke(NPObject* object,
+ const NPVariant* args,
+ uint32_t num_args,
+ NPVariant* result) {
+ VOID_TO_NPVARIANT(*result);
+
+ if (num_args != NUM_PARAMS)
+ return false;
+
+ PARAM_TO_NVPARIANT_CONVERSIONS
+
+ (static_cast<NPObjectType*>(object)->*function_)(PARAM_NAMES);
+ return true;
+ }
+
+ virtual int num_args() const {
+ return NUM_PARAMS;
+ }
+
+ private:
+ FunctionType function_;
+};
+
+template <typename NPObjectType, typename R PARAM_TYPENAMES>
+class NPDispatcher<NPObjectType, R(PARAM_TYPES)>
+ : public BaseNPDispatcher {
+ typedef R (NPObjectType::*FunctionType)(PARAM_TYPES);
+ public:
+ NPDispatcher(BaseNPDispatcher* next,
+ const NPUTF8* name,
+ FunctionType function)
+ : BaseNPDispatcher(next, name),
+ function_(function) {
+ }
+
+ virtual bool Invoke(NPObject* object,
+ const NPVariant* args,
+ uint32_t num_args,
+ NPVariant* result) {
+ VOID_TO_NPVARIANT(*result);
+
+ if (num_args != NUM_PARAMS)
+ return false;
+
+ PARAM_TO_NVPARIANT_CONVERSIONS
+
+ ValueToNPVariant(
+ (static_cast<NPObjectType*>(object)->*function_)(PARAM_NAMES), result);
+ return true;
+ }
+
+ virtual int num_args() const {
+ return NUM_PARAMS;
+ }
+
+ private:
+ FunctionType function_;
+};
+
+#undef NUM_PARAMS
+#undef PARAM_TYPENAMES
+#undef PARAM_TYPES
+#undef PARAM_NAMES
+#undef PARAM_DECLS
+#undef PARAM_TO_NVPARIANT_CONVERSIONS