diff options
author | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-26 01:09:48 +0000 |
---|---|---|
committer | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-26 01:09:48 +0000 |
commit | 5b3a670dc03ac0233f8bdeb1e575c18fe3980082 (patch) | |
tree | 7f663344ee5d1520b75473b1f682fa90bf92c593 /o3d/plugin | |
parent | 9f8634d2e7060f157ef9f1050edd8239e68d6bbd (diff) | |
download | chromium_src-5b3a670dc03ac0233f8bdeb1e575c18fe3980082.zip chromium_src-5b3a670dc03ac0233f8bdeb1e575c18fe3980082.tar.gz chromium_src-5b3a670dc03ac0233f8bdeb1e575c18fe3980082.tar.bz2 |
Fixed Mac gyp build. Switched to using Chrome hash_tables.h, changed
how hash functions are specified for certain key types, and deleted
our std_hash.h. Fixed forward reference bug in cmd_buffer_format.h.
Built and tested on Windows and Mac.
Remaining workarounds: enabled C++ exceptions due to use of Objective
C try/catch in plugin_mac.mm; disabled warnings as errors due to
signed / unsigned issues in command buffer code, which will probably
need to be fixed by changing typedefs and argument types.
Review URL: http://codereview.chromium.org/249013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27311 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/plugin')
-rw-r--r-- | o3d/plugin/cross/np_v8_bridge.h | 35 | ||||
-rw-r--r-- | o3d/plugin/cross/o3d_glue.h | 43 |
2 files changed, 65 insertions, 13 deletions
diff --git a/o3d/plugin/cross/np_v8_bridge.h b/o3d/plugin/cross/np_v8_bridge.h index 150a3c2..a43d1d6 100644 --- a/o3d/plugin/cross/np_v8_bridge.h +++ b/o3d/plugin/cross/np_v8_bridge.h @@ -39,7 +39,7 @@ #include <npruntime.h> #include <map> -#include "base/cross/std_hash.h" +#include "base/hash_tables.h" #include "core/cross/error_status.h" #include "core/cross/service_dependency.h" #include "core/cross/types.h" @@ -179,15 +179,33 @@ class NPObjectPtr { T* object_; }; +} // namespace o3d + // Hashes an NPObject so it can be used in a hash_map. -template <typename T> -class NPObjectPtrHash { - public: - size_t operator() (const NPObjectPtr<T>& ptr) const { - return o3d::base::hash<size_t>()(reinterpret_cast<size_t>(ptr.Get())); +#if defined(COMPILER_GCC) +namespace __gnu_cxx { + +template<class T> +struct hash<o3d::NPObjectPtr<T> > { + std::size_t operator()(const o3d::NPObjectPtr<T>& ptr) const { + return hash<size_t>()(reinterpret_cast<size_t>(ptr.Get())); } }; +} // namespace __gnu_cxx +#elif defined(COMPILER_MSVC) +namespace stdext { + +template<class T> +inline size_t hash_value(const o3d::NPObjectPtr<T>& ptr) { + return hash_value(reinterpret_cast<size_t>(ptr.Get())); +} + +} // namespace stdext +#endif // COMPILER + +namespace o3d { + // A V8 handle that automatically disposes itself when it is destroyed. There // must be only one of these for each persistent handle, otherwise they might // be disposed more than once. @@ -369,9 +387,8 @@ class NPV8Bridge { NPObjectPtr<NPObject> GetNPConstructFunction(int arity); - typedef o3d::base::hash_map<NPObjectPtr<NPObject>, - AutoV8Persistent<v8::Object>, - NPObjectPtrHash<NPObject> > NPV8ObjectMap; + typedef ::base::hash_map<NPObjectPtr<NPObject>, + AutoV8Persistent<v8::Object> > NPV8ObjectMap; typedef std::map<int, NPObjectPtr<NPObject> > NPConstructFunctionMap; diff --git a/o3d/plugin/cross/o3d_glue.h b/o3d/plugin/cross/o3d_glue.h index 12fb572..bd02228 100644 --- a/o3d/plugin/cross/o3d_glue.h +++ b/o3d/plugin/cross/o3d_glue.h @@ -52,7 +52,7 @@ #include <string> #include <vector> #include "base/scoped_ptr.h" -#include "base/cross/std_hash.h" +#include "base/hash_tables.h" #include "core/cross/display_mode.h" #include "core/cross/display_window.h" #include "core/cross/object_base.h" @@ -75,6 +75,41 @@ class Client; class Renderer; } +// Hashes the NPClass and ObjectBase types so they can be used in a hash_map. +#if defined(COMPILER_GCC) +namespace __gnu_cxx { + +template<> +struct hash<NPClass*> { + std::size_t operator()(NPClass* const& ptr) const { + return hash<size_t>()(reinterpret_cast<size_t>(ptr)); + } +}; + +template<> +struct hash<const o3d::ObjectBase::Class*> { + std::size_t operator()(const o3d::ObjectBase::Class* const& ptr) const { + return hash<size_t>()(reinterpret_cast<size_t>(ptr)); + } +}; + +} // namespace __gnu_cxx +#elif defined(COMPILER_MSVC) +namespace stdext { + +template<> +inline size_t hash_value(NPClass* const& ptr) { + return hash_value(reinterpret_cast<size_t>(ptr)); +} + +template<> +inline size_t hash_value(const o3d::ObjectBase::Class* const& ptr) { + return hash_value(reinterpret_cast<size_t>(ptr)); +} + +} // namespace stdext +#endif // COMPILER + namespace glue { class StreamManager; @@ -119,10 +154,10 @@ void InitializeGlue(NPP npp); typedef glue::namespace_o3d::class_Client::NPAPIObject ClientNPObject; class PluginObject: public NPObject { - typedef o3d::base::hash_map<Id, NPAPIObject *> ClientObjectMap; - typedef o3d::base::hash_map<const ObjectBase::Class *, NPClass *> + typedef ::base::hash_map<Id, NPAPIObject *> ClientObjectMap; + typedef ::base::hash_map<const ObjectBase::Class *, NPClass *> ClientToNPClassMap; - typedef o3d::base::hash_map<NPClass *, const ObjectBase::Class *> + typedef ::base::hash_map<NPClass *, const ObjectBase::Class *> NPToClientClassMap; NPP npp_; |