Chromium Code Reviews| Index: mojo/public/cpp/bindings/interface_traits.h |
| diff --git a/mojo/public/cpp/bindings/interface_traits.h b/mojo/public/cpp/bindings/interface_traits.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e8e8bf39e4ed12d4cf80e3b89cde84bf9d16a5fa |
| --- /dev/null |
| +++ b/mojo/public/cpp/bindings/interface_traits.h |
| @@ -0,0 +1,43 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_TRAITS_H_ |
| +#define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_TRAITS_H_ |
| + |
| +#include <stdint.h> |
| + |
| +#include <string> |
| + |
| +namespace mojo { |
| + |
| +// Metadata information for each method in an interface. |
| +struct MethodMetadata { |
| + uint32_t min_version; |
|
yzshen1
2016/12/22 18:53:28
At the moment, it seems that min_version is what i
|
| + uint32_t ordinal; |
| + const char* name; |
| +}; |
| + |
| +// Exposes metadata about a method. MethodIndex should be one of the |
| +// kMethodNameMethodIndex constants in Interface::kMethodIndices. |
| +template <typename Interface, uint32_t MethodIndex> |
| +struct MethodTraits { |
| + static uint32_t MinVersion() { |
| + return Interface::kMethodMetadata[MethodIndex].min_version; |
| + } |
| + |
| + static const char* Name() { |
| + return Interface::kMethodMetadata[MethodIndex].name; |
| + } |
| + |
| + static uint32_t Ordinal() { |
| + return Interface::kMethodMetadata[MethodIndex].ordinal; |
| + } |
| + |
| + static_assert(MethodIndex < Interface::kMethodMetadataSize, |
| + "Invalid method index"); |
| +}; |
| + |
| +} // namespace mojo |
| + |
| +#endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_TRAITS_H_ |