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

Unified Diff: mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl

Issue 209453003: Add support for mojo::TypeConverter to control how convenient conversion should be. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/cpp/bindings/type_converter.h ('k') | mojo/services/gles2/command_buffer_type_conversions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl
index 7c429c01b4661424d45eda449d21072d815e8d03..f367227a047640cb93a96badb068fd49dda97e11 100644
--- a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl
+++ b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl
@@ -13,17 +13,20 @@ class {{struct.name}} {
template <typename U>
{{struct.name}}(const U& u, mojo::Buffer* buf = mojo::Buffer::current()) {
+ MOJO_INTERNAL_CHECK_ALLOW_IMPLICIT_TYPE_CONVERSION({{struct.name}}, U);
*this = mojo::TypeConverter<{{struct.name}},U>::ConvertFrom(u, buf);
}
template <typename U>
{{struct.name}}& operator=(const U& u) {
+ MOJO_INTERNAL_CHECK_ALLOW_IMPLICIT_TYPE_CONVERSION({{struct.name}}, U);
*this = mojo::TypeConverter<{{struct.name}},U>::ConvertFrom(u, mojo::Buffer::current());
return *this;
}
template <typename U>
operator U() const {
+ MOJO_INTERNAL_CHECK_ALLOW_IMPLICIT_TYPE_CONVERSION({{struct.name}}, U);
return To<U>();
}
@@ -32,6 +35,11 @@ class {{struct.name}} {
return mojo::TypeConverter<{{struct.name}},U>::ConvertTo(*this);
}
+ template <typename U>
+ static {{struct.name}} From(const U& u, mojo::Buffer* buf = mojo::Buffer::current()) {
+ return mojo::TypeConverter<{{struct.name}},U>::ConvertFrom(u, buf);
+ }
+
bool is_null() const { return !data_; }
{#--- Getters #}
« no previous file with comments | « mojo/public/cpp/bindings/type_converter.h ('k') | mojo/services/gles2/command_buffer_type_conversions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698