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

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
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..df17833b17dccd6f454831352fc1022045c9ea0c 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_DIRECT_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_DIRECT_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_DIRECT_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 #}

Powered by Google App Engine
This is Rietveld 408576698