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

Side by Side Diff: gpu/np_utils/np_class.h

Issue 481007: Deleted np_utils library. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years 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 | « gpu/np_utils/np_browser_stub.cc ('k') | gpu/np_utils/np_class_unittest.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 (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef GPU_NP_UTILS_NP_CLASS_H_
6 #define GPU_NP_UTILS_NP_CLASS_H_
7
8 #include "gpu/np_utils/np_object_pointer.h"
9 #include "gpu/np_utils/np_headers.h"
10
11 // This file implements NPGetClass<T>. This function returns an NPClass
12 // that can be used to instantiate an NPObject subclass T. The NPClass
13 // function pointers will invoke the most derived corresponding member
14 // functions in T.
15
16 namespace np_utils {
17
18 namespace np_class_impl {
19 // This template version of the NPClass allocate function creates a subclass
20 // of BaseNPObject.
21 template <typename NPObjectType>
22 static NPObject* Allocate(NPP npp, NPClass*) {
23 return new NPObjectType(npp);
24 }
25
26 // These implementations of the NPClass functions forward to the virtual
27 // functions in DefaultNPObject.
28 template <typename NPObjectType>
29 static void Deallocate(NPObject* object) {
30 delete static_cast<NPObjectType*>(object);
31 }
32
33 template <typename NPObjectType>
34 static void Invalidate(NPObject* object) {
35 return static_cast<NPObjectType*>(object)->Invalidate();
36 }
37
38 template <typename NPObjectType>
39 static bool HasMethod(NPObject* object, NPIdentifier name) {
40 return static_cast<NPObjectType*>(object)->HasMethod(name);
41 }
42
43 template <typename NPObjectType>
44 static bool Invoke(NPObject* object,
45 NPIdentifier name,
46 const NPVariant* args,
47 uint32_t num_args,
48 NPVariant* result) {
49 return static_cast<NPObjectType*>(object)->Invoke(
50 name, args, num_args, result);
51 }
52
53 template <typename NPObjectType>
54 static bool InvokeDefault(NPObject* object,
55 const NPVariant* args,
56 uint32_t num_args,
57 NPVariant* result) {
58 return static_cast<NPObjectType*>(object)->InvokeDefault(
59 args, num_args, result);
60 }
61
62 template <typename NPObjectType>
63 static bool HasProperty(NPObject* object, NPIdentifier name) {
64 return static_cast<NPObjectType*>(object)->HasProperty(name);
65 }
66
67 template <typename NPObjectType>
68 static bool GetProperty(NPObject* object,
69 NPIdentifier name,
70 NPVariant* result) {
71 return static_cast<NPObjectType*>(object)->GetProperty(name, result);
72 }
73
74 template <typename NPObjectType>
75 static bool SetProperty(NPObject* object,
76 NPIdentifier name,
77 const NPVariant* value) {
78 return static_cast<NPObjectType*>(object)->SetProperty(name, value);
79 }
80
81 template <typename NPObjectType>
82 static bool RemoveProperty(NPObject* object, NPIdentifier name) {
83 return static_cast<NPObjectType*>(object)->RemoveProperty(name);
84 }
85
86 template <typename NPObjectType>
87 static bool Enumerate(NPObject* object,
88 NPIdentifier** names,
89 uint32_t* count) {
90 return static_cast<NPObjectType*>(object)->Enumerate(names, count);
91 };
92
93 template <typename NPObjectType>
94 static bool Construct(NPObject* object,
95 const NPVariant* args,
96 uint32_t num_args,
97 NPVariant* result) {
98 return static_cast<NPObjectType*>(object)->Construct(
99 args, num_args, result);
100 }
101 } // namespace np_class_impl;
102
103 template <typename NPObjectType>
104 const NPClass* NPGetClass() {
105 static const NPClass np_class = {
106 NP_CLASS_STRUCT_VERSION,
107 np_class_impl::Allocate<NPObjectType>,
108 np_class_impl::Deallocate<NPObjectType>,
109 np_class_impl::Invalidate<NPObjectType>,
110 np_class_impl::HasMethod<NPObjectType>,
111 np_class_impl::Invoke<NPObjectType>,
112 np_class_impl::InvokeDefault<NPObjectType>,
113 np_class_impl::HasProperty<NPObjectType>,
114 np_class_impl::GetProperty<NPObjectType>,
115 np_class_impl::SetProperty<NPObjectType>,
116 np_class_impl::RemoveProperty<NPObjectType>,
117 np_class_impl::Enumerate<NPObjectType>,
118 np_class_impl::Construct<NPObjectType>,
119 };
120 return &np_class;
121 };
122
123 } // namespace np_utils
124
125 #endif // GPU_NP_UTILS_NP_CLASS_H_
OLDNEW
« no previous file with comments | « gpu/np_utils/np_browser_stub.cc ('k') | gpu/np_utils/np_class_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698