| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PPAPI_CPP_MODULE_IMPL_H_ | 5 #ifndef PPAPI_CPP_MODULE_IMPL_H_ |
| 6 #define PPAPI_CPP_MODULE_IMPL_H_ | 6 #define PPAPI_CPP_MODULE_IMPL_H_ |
| 7 | 7 |
| 8 /// @file |
| 9 /// This file defines some simple function templates that help the C++ wrappers |
| 10 /// (and are not for external developers to use). |
| 11 |
| 8 #include "ppapi/cpp/module.h" | 12 #include "ppapi/cpp/module.h" |
| 9 | 13 |
| 10 namespace pp { | 14 namespace pp { |
| 11 | 15 |
| 12 namespace { | 16 namespace { |
| 13 | 17 |
| 14 // Specialize this function to return the interface string corresponding to the | 18 // Specialize this function to return the interface string corresponding to the |
| 15 // PP?_XXX structure. | 19 // PP?_XXX structure. |
| 16 template <typename T> const char* interface_name() { | 20 template <typename T> const char* interface_name() { |
| 17 return NULL; | 21 return NULL; |
| 18 } | 22 } |
| 19 | 23 |
| 20 template <typename T> inline T const* get_interface() { | 24 template <typename T> inline T const* get_interface() { |
| 21 static T const* funcs = reinterpret_cast<T const*>( | 25 static T const* funcs = reinterpret_cast<T const*>( |
| 22 pp::Module::Get()->GetBrowserInterface(interface_name<T>())); | 26 pp::Module::Get()->GetBrowserInterface(interface_name<T>())); |
| 23 return funcs; | 27 return funcs; |
| 24 } | 28 } |
| 25 | 29 |
| 26 template <typename T> inline bool has_interface() { | 30 template <typename T> inline bool has_interface() { |
| 27 return get_interface<T>() != NULL; | 31 return get_interface<T>() != NULL; |
| 28 } | 32 } |
| 29 | 33 |
| 30 } // namespace | 34 } // namespace |
| 31 | 35 |
| 32 } // namespace pp | 36 } // namespace pp |
| 33 | 37 |
| 34 #endif // PPAPI_CPP_MODULE_IMPL_H_ | 38 #endif // PPAPI_CPP_MODULE_IMPL_H_ |
| 35 | 39 |
| OLD | NEW |