Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(731)

Side by Side Diff: mojo/public/tools/bindings/generators/cpp_templates/enum_serialization_declaration.tmpl

Issue 2225673002: Support exporting Mojo bindings for the component build. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix win_clang Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 {%- set mojom_type = enum|get_qualified_name_for_kind %} 1 {%- set mojom_type = enum|get_qualified_name_for_kind %}
2 2
3 template <> 3 template <>
4 struct EnumTraits<{{mojom_type}}, {{mojom_type}}> { 4 struct {{export_attribute}} EnumTraits<{{mojom_type}}, {{mojom_type}}> {
5 static {{mojom_type}} ToMojom({{mojom_type}} input) { return input; } 5 static {{mojom_type}} ToMojom({{mojom_type}} input) { return input; }
6 static bool FromMojom({{mojom_type}} input, {{mojom_type}}* output) { 6 static bool FromMojom({{mojom_type}} input, {{mojom_type}}* output) {
7 *output = input; 7 *output = input;
8 return true; 8 return true;
9 } 9 }
10 }; 10 };
11 11
12 namespace internal { 12 namespace internal {
13 13
14 template <typename MaybeConstUserType> 14 template <typename MaybeConstUserType>
15 struct Serializer<{{mojom_type}}, MaybeConstUserType> { 15 struct Serializer<{{mojom_type}}, MaybeConstUserType> {
16 using UserType = typename std::remove_const<MaybeConstUserType>::type; 16 using UserType = typename std::remove_const<MaybeConstUserType>::type;
17 using Traits = EnumTraits<{{mojom_type}}, UserType>; 17 using Traits = EnumTraits<{{mojom_type}}, UserType>;
18 18
19 static void Serialize(UserType input, int32_t* output) { 19 static void Serialize(UserType input, int32_t* output) {
20 *output = static_cast<int32_t>(Traits::ToMojom(input)); 20 *output = static_cast<int32_t>(Traits::ToMojom(input));
21 } 21 }
22 22
23 static bool Deserialize(int32_t input, UserType* output) { 23 static bool Deserialize(int32_t input, UserType* output) {
24 return Traits::FromMojom(static_cast<{{mojom_type}}>(input), output); 24 return Traits::FromMojom(static_cast<{{mojom_type}}>(input), output);
25 } 25 }
26 }; 26 };
27 27
28 } // namespace internal 28 } // namespace internal
OLDNEW
« no previous file with comments | « content/test/BUILD.gn ('k') | mojo/public/tools/bindings/generators/cpp_templates/interface_declaration.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698