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

Unified Diff: mojo/public/bindings/generators/cpp_templates/struct_macros.tmpl

Issue 226263002: Mojo: Move mojo/public/bindings to mojo/public/tools/bindings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 9 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/bindings/generators/cpp_templates/struct_macros.tmpl
diff --git a/mojo/public/bindings/generators/cpp_templates/struct_macros.tmpl b/mojo/public/bindings/generators/cpp_templates/struct_macros.tmpl
deleted file mode 100644
index 106a18d8c99a5c6bf4db8370f1728921d44363e4..0000000000000000000000000000000000000000
--- a/mojo/public/bindings/generators/cpp_templates/struct_macros.tmpl
+++ /dev/null
@@ -1,83 +0,0 @@
-{%- macro setters(struct) %}
-{% for packed_field in struct.packed.packed_fields %}
-{%- set type = packed_field.field.kind|cpp_type %}
-{%- set name = packed_field.field.name %}
-{%- if packed_field.field.kind|is_object_kind %}
- void set_{{name}}({{type}} {{name}}) { {{name}}_.ptr = {{name}}; }
-{%- else %}
- void set_{{name}}({{type}} {{name}}) { {{name}}_ = {{name}}; }
-{%- endif %}
-{%- endfor %}
-{%- endmacro %}
-
-{%- macro getters(struct) %}
-{% for packed_field in struct.packed.packed_fields %}
-{%- set type = packed_field.field.kind|cpp_type %}
-{%- set name = packed_field.field.name %}
-{%- if packed_field.field.kind|is_object_kind %}
- const {{type}} {{name}}() const { return {{name}}_.ptr; }
-{%- elif packed_field.field.kind|is_handle_kind %}
- {{type}}* {{name}}() const { return &{{name}}_; }
-{%- else %}
- {{type}} {{name}}() const { return {{name}}_; }
-{%- endif %}
-{%- endfor %}
-{%- endmacro %}
-
-{%- macro field_line(field) %}
-{%- set type = field.kind|cpp_field_type %}
-{%- set name = field.name -%}
-{%- if field.kind.spec == 'b' -%}
- uint8_t {{name}}_ : 1;
-{%- elif field.kind|is_handle_kind -%}
- mutable {{type}} {{name}}_;
-{%- elif field.kind|is_enum_kind -%}
- int32_t {{name}}_;
-{%- else -%}
- {{type}} {{name}}_;
-{%- endif %}
-{%- endmacro %}
-
-{%- macro fields(struct) %}
-{%- for packed_field in struct.packed.packed_fields %}
- {{field_line(packed_field.field)}}
-{%- if not loop.last %}
-{%- set next_pf = struct.packed.packed_fields[loop.index0 + 1] %}
-{%- set pad = next_pf.offset - (packed_field.offset + packed_field.size) %}
-{%- if pad > 0 %}
- uint8_t _pad{{loop.index0}}_[{{pad}}];
-{%- endif %}
-{%- endif %}
-{%- endfor -%}
-
-{%- set num_fields = struct.packed.packed_fields|length %}
-{%- if num_fields > 0 %}
-{%- set last_field = struct.packed.packed_fields[num_fields - 1] %}
-{%- set offset = last_field.offset + last_field.size %}
-{%- set pad = offset|get_pad(8) -%}
-{%- if pad > 0 %}
- uint8_t _padfinal_[{{pad}}];
-{%- endif %}
-{%- endif %}
-{%- endmacro %}
-
-{%- macro encodes(struct) -%}
-{%- for pf in struct.packed.packed_fields if pf.field.kind|is_object_kind -%}
-mojo::internal::Encode(&{{pf.field.name}}_, handles);
-{% endfor %}
-{%- for pf in struct.packed.packed_fields if pf.field.kind|is_handle_kind -%}
-mojo::internal::EncodeHandle(&{{pf.field.name}}_, handles);
-{% endfor %}
-{%- endmacro -%}
-
-{%- macro decodes(struct) -%}
-{%- for pf in struct.packed.packed_fields if pf.field.kind|is_object_kind -%}
-if (!mojo::internal::Decode(&{{pf.field.name}}_, message))
- return false;
-{% endfor %}
-{%- for pf in struct.packed.packed_fields if pf.field.kind|is_handle_kind -%}
-if (!mojo::internal::DecodeHandle(&{{pf.field.name}}_,
- message->mutable_handles()))
- return false;
-{% endfor %}
-{%- endmacro -%}

Powered by Google App Engine
This is Rietveld 408576698