| 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 263bc9fff4c566fc4906e4c972c8b3ad346b9ef3..c5c5e815c0aef6788b87963c949c155f144a4018 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
|
| @@ -33,9 +33,25 @@ class {{struct.name}} {
|
| {{struct.name}}();
|
| ~{{struct.name}}();
|
|
|
| -{% if struct|is_cloneable_kind %}
|
| - {{struct.name}}Ptr Clone() const;
|
| -{%- endif %}
|
| + // Clone() is a template so it is only instantiated if it is used. Thus, the
|
| + // bindings generator does not need to know whether typemapped native types
|
| + // support operator=.
|
| + template <typename StructPtrType = {{struct.name}}Ptr>
|
| + {{struct.name}}Ptr Clone() const {
|
| + // Use StructPtrType to prevent the compiler from trying to compile this
|
| + // without being asked.
|
| + StructPtrType rv(New());
|
| +{%- for field in struct.fields %}
|
| +{%- if field.kind|is_object_kind and not field.kind|is_string_kind and
|
| + not field.kind|is_typemapped_kind %}
|
| + rv->{{field.name}} = {{field.name}}.Clone();
|
| +{%- else %}
|
| + rv->{{field.name}} = {{field.name}};
|
| +{%- endif %}
|
| +{%- endfor %}
|
| + return rv;
|
| + }
|
| +
|
| // Equals() is a template so it is only instantiated if it is used. Thus, the
|
| // bindings generator does not need to know whether typemapped native types
|
| // support operator==.
|
|
|