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

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

Issue 917333003: Mojo C++ bindings templates: use the same templates for user-defined structs and method params. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 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/params_definition.tmpl
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/params_definition.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/params_definition.tmpl
deleted file mode 100644
index d2d9fd8bfeec975af1875e7907fa8d951f4b08c4..0000000000000000000000000000000000000000
--- a/mojo/public/tools/bindings/generators/cpp_templates/params_definition.tmpl
+++ /dev/null
@@ -1,33 +0,0 @@
-{%- import "struct_macros.tmpl" as struct_macros %}
-{%- set class_name = struct.name ~ "_Data" %}
-class {{class_name}} {
- public:
- static {{class_name}}* New(mojo::internal::Buffer* buf) {
- return new (buf->Allocate(sizeof({{class_name}})))
- {{class_name}}();
- }
-
- static bool Validate(const void* data,
- mojo::internal::BoundsChecker* bounds_checker) {
- {{struct_macros.validate(struct)|indent(2)}}
- }
-
- mojo::internal::StructHeader header_;
-{{struct_macros.fields(struct)}}
-
- void EncodePointersAndHandles(std::vector<mojo::Handle>* handles) {
- {{struct_macros.encodes(struct)|indent(2)}}
- }
-
- void DecodePointersAndHandles(std::vector<mojo::Handle>* handles) {
- {{struct_macros.decodes(struct)|indent(2)}}
- }
-
- private:
- {{class_name}}() {
- header_.num_bytes = sizeof(*this);
- header_.version = {{struct.versions[-1].version}};
- }
-};
-static_assert(sizeof({{class_name}}) == {{struct.versions[-1].num_bytes}},
- "Bad sizeof({{class_name}})");

Powered by Google App Engine
This is Rietveld 408576698