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

Unified Diff: mojo/public/tools/bindings/generators/cpp_templates/module.h.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/module.h.tmpl
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl
index 0a54e1d5a58a0901887af92d6af019ec84ae4d62..79710a396271c56d54c3bcc0b41f6d5a1dddacb7 100644
--- a/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl
+++ b/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl
@@ -14,6 +14,8 @@
#include "mojo/public/cpp/bindings/interface_ptr.h"
#include "mojo/public/cpp/bindings/message_filter.h"
#include "mojo/public/cpp/bindings/no_interface.h"
+#include "mojo/public/cpp/bindings/string.h"
+#include "mojo/public/cpp/bindings/struct_ptr.h"
#include "{{module.path}}-internal.h"
{%- for import in imports %}
#include "{{import.module.path}}.h"
@@ -39,9 +41,22 @@ class {{interface.name}};
typedef mojo::InterfacePtr<{{interface.name}}> {{interface.name}}Ptr;
{% endfor %}
+{#--- Struct Forward Declarations -#}
+{% for struct in structs %}
+class {{struct.name}};
+{% if struct|should_inline %}
+typedef mojo::InlinedStructPtr<{{struct.name}}> {{struct.name}}Ptr;
yzshen1 2014/05/22 17:13:53 It seems users always create/use FooPtr instead of
+{% include "wrapper_class_declaration.tmpl" %}
+{% else %}
+typedef mojo::StructPtr<{{struct.name}}> {{struct.name}}Ptr;
+{% endif %}
+{% endfor %}
+
{#--- Structs #}
{% for struct in structs %}
-{% include "wrapper_class_declaration.tmpl" %}
+{% if not struct|should_inline %}
+{% include "wrapper_class_declaration.tmpl" %}
+{% endif %}
{%- endfor %}
{#--- Interfaces -#}
@@ -69,19 +84,26 @@ typedef mojo::InterfacePtr<{{interface.name}}> {{interface.name}}Ptr;
{% include "interface_response_validator_declaration.tmpl" %}
{%- endfor %}
+{#--- Struct Serialization Helpers -#}
+{% if structs %}
+{% for struct in structs %}
+{% include "struct_serialization_declaration.tmpl" %}
+{%- endfor %}
+{%- endif %}
+
{%- for namespace in namespaces_as_array|reverse %}
} // namespace {{namespace}}
{%- endfor %}
{#--- Enum TypeTraits Specializations #}
-{% if enums %}
namespace mojo {
namespace internal {
+{% if enums %}
{% for enum in enums %}
{% include "enum_traits.tmpl" %}
{%- endfor %}
+{%- endif %}
} // namespace internal
} // namespace mojo
-{%- endif %}
#endif // {{header_guard}}

Powered by Google App Engine
This is Rietveld 408576698