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

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

Issue 294833002: Mojo: more idiomatic C++ bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more Created 6 years, 7 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_definition.tmpl
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/struct_builder_definition.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl
similarity index 84%
rename from mojo/public/tools/bindings/generators/cpp_templates/struct_builder_definition.tmpl
rename to mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl
index ea9c0e9b2c5f53cbceca38258bea1c0e81dba1b1..4e487d171c8db4d591b1e004a2ccb58d10b6b640 100644
--- a/mojo/public/tools/bindings/generators/cpp_templates/struct_builder_definition.tmpl
+++ b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl
@@ -47,6 +47,7 @@ tmp{{depth}}.set_{{subfield.name}}({{result}});
{%- endif %}
{%- endmacro %}
+#if 0
{{class_name}}::Builder::Builder(mojo::Buffer* buf)
: data_(Data::New(buf, {{dtor_name[0]}})) {
{%- for pf in struct.packed.packed_fields if pf.field.default %}
@@ -63,3 +64,20 @@ set_{{pf.field.name}}({{result}});
std::swap(data, data_);
return mojo::internal::Wrap(data);
}
+#endif
+
+// static
+{{class_name}}Ptr {{class_name}}::New() {
+ {{class_name}}Ptr rv;
+ mojo::internal::StructHelper<{{class_name}}>::Initialize(&rv);
+ return rv.Pass();
+}
+
+{{class_name}}::{{class_name}}()
+{%-for field in struct.fields %}
+ {% if loop.first %}:{% else %} {% endif %} {{field.name}}(){% if not loop.last %},{% endif %}
+{%- endfor %} {
+}
+
+{{class_name}}::~{{class_name}}() {
+}

Powered by Google App Engine
This is Rietveld 408576698