blob: 28a6cf6364f2976b9cc9753e1285c0ebd5186dc4 [file] [log] [blame]
[email protected]0325ee32011-11-10 18:35:101// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]1758e882010-11-01 16:16:502// 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]0325ee32011-11-10 18:35:108/// @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]1758e882010-11-01 16:16:5012#include "ppapi/cpp/module.h"
13
[email protected]6b7550a2010-12-20 19:03:0714namespace pp {
15
[email protected]1758e882010-11-01 16:16:5016namespace {
17
[email protected]6b7550a2010-12-20 19:03:0718// Specialize this function to return the interface string corresponding to the
19// PP?_XXX structure.
Daniel Bratell07811502018-11-13 16:05:2020template <typename T>
21const char* interface_name();
[email protected]1758e882010-11-01 16:16:5022
[email protected]6b7550a2010-12-20 19:03:0723template <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]1758e882010-11-01 16:16:5028
[email protected]6b7550a2010-12-20 19:03:0729template <typename T> inline bool has_interface() {
30 return get_interface<T>() != NULL;
31}
[email protected]1758e882010-11-01 16:16:5032
33} // namespace
34
[email protected]6b7550a2010-12-20 19:03:0735} // namespace pp
36
[email protected]1758e882010-11-01 16:16:5037#endif // PPAPI_CPP_MODULE_IMPL_H_
38