[email protected] | 0325ee3 | 2011-11-10 18:35:10 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 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 PPAPI_CPP_MODULE_IMPL_H_ | ||||
6 | #define PPAPI_CPP_MODULE_IMPL_H_ | ||||
7 | |||||
[email protected] | 0325ee3 | 2011-11-10 18:35:10 | [diff] [blame] | 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 | |||||
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 12 | #include "ppapi/cpp/module.h" |
13 | |||||
[email protected] | 6b7550a | 2010-12-20 19:03:07 | [diff] [blame] | 14 | namespace pp { |
15 | |||||
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 16 | namespace { |
17 | |||||
[email protected] | 6b7550a | 2010-12-20 19:03:07 | [diff] [blame] | 18 | // Specialize this function to return the interface string corresponding to the |
19 | // PP?_XXX structure. | ||||
Daniel Bratell | 0781150 | 2018-11-13 16:05:20 | [diff] [blame] | 20 | template <typename T> |
21 | const char* interface_name(); | ||||
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 22 | |
[email protected] | 6b7550a | 2010-12-20 19:03:07 | [diff] [blame] | 23 | template <typename T> inline T const* get_interface() { |
24 | static T const* funcs = reinterpret_cast<T const*>( | ||||
25 | pp::Module::Get()->GetBrowserInterface(interface_name<T>())); | ||||
26 | return funcs; | ||||
27 | } | ||||
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 28 | |
[email protected] | 6b7550a | 2010-12-20 19:03:07 | [diff] [blame] | 29 | template <typename T> inline bool has_interface() { |
30 | return get_interface<T>() != NULL; | ||||
31 | } | ||||
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 32 | |
33 | } // namespace | ||||
34 | |||||
[email protected] | 6b7550a | 2010-12-20 19:03:07 | [diff] [blame] | 35 | } // namespace pp |
36 | |||||
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 37 | #endif // PPAPI_CPP_MODULE_IMPL_H_ |
38 |