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

Side by Side Diff: o3d/gpu_plugin/np_utils/np_dispatcher.cc

Issue 196032: Replaced BaseNPObject with DefaultNPObject because...... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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
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 #include "o3d/gpu_plugin/np_utils/np_dispatcher.h"
6
7 namespace o3d {
8 namespace gpu_plugin {
9
10 bool DispatcherHasMethodHelper(BaseNPDispatcher* chain,
11 NPObject* object,
12 NPIdentifier name) {
13 for (BaseNPDispatcher* dispatcher = chain;
14 dispatcher;
15 dispatcher = dispatcher->next()) {
16 if (dispatcher->name() == name) {
17 return true;
18 }
19 }
20
21 return false;
22 }
23
24 bool DispatcherInvokeHelper(BaseNPDispatcher* chain,
25 NPObject* object,
26 NPIdentifier name,
27 const NPVariant* args,
28 uint32_t num_args,
29 NPVariant* result) {
30 VOID_TO_NPVARIANT(*result);
31
32 for (BaseNPDispatcher* dispatcher = chain;
33 dispatcher;
34 dispatcher = dispatcher->next()) {
35 if (dispatcher->name() == name && dispatcher->num_args() == num_args) {
36 if (dispatcher->Invoke(object, args, num_args, result))
37 return true;
38 }
39 }
40
41 return false;
42 }
43
44 bool DispatcherEnumerateHelper(BaseNPDispatcher* chain,
45 NPObject* object,
46 NPIdentifier** names,
47 uint32_t* num_names) {
48 // Count the number of names.
49 *num_names = 0;
50 for (BaseNPDispatcher* dispatcher = chain;
51 dispatcher;
52 dispatcher = dispatcher->next()) {
53 ++(*num_names);
54 }
55
56 // Copy names into the array.
57 *names = static_cast<NPIdentifier*>(
58 NPBrowser::get()->MemAlloc((*num_names) * sizeof(**names)));
59 int i = 0;
60 for (BaseNPDispatcher* dispatcher = chain;
61 dispatcher;
62 dispatcher = dispatcher->next()) {
63 (*names)[i] = dispatcher->name();
64 ++i;
65 }
66
67 return true;
68 }
69
70 BaseNPDispatcher::BaseNPDispatcher(BaseNPDispatcher* next, const NPUTF8* name)
71 : next_(next) {
72 // Convert first character to lower case if it is the ASCII range.
73 // TODO(apatrick): do this correctly for non-ASCII characters.
74 std::string java_script_style_name(name);
75 if (isupper(java_script_style_name[0])) {
76 java_script_style_name[0] = tolower(java_script_style_name[0]);
77 }
78
79 name_ = NPBrowser::get()->GetStringIdentifier(
80 java_script_style_name.c_str());
81 }
82
83 BaseNPDispatcher::~BaseNPDispatcher() {
84 }
85
86 } // namespace gpu_plugin
87 } // namespace o3d
OLDNEW
« no previous file with comments | « o3d/gpu_plugin/np_utils/np_dispatcher.h ('k') | o3d/gpu_plugin/np_utils/np_dispatcher_specializations.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698