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

Side by Side Diff: mojo/public/bindings/generators/cpp_templates/struct_macros.tmpl

Issue 131033002: Mojo: Simplify object serialization (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix indentation error Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 {%- macro setters(struct) %} 1 {%- macro setters(struct) %}
2 {% for packed_field in struct.packed.packed_fields %} 2 {% for packed_field in struct.packed.packed_fields %}
3 {%- set type = packed_field.field.kind|cpp_type %} 3 {%- set type = packed_field.field.kind|cpp_type %}
4 {%- set name = packed_field.field.name %} 4 {%- set name = packed_field.field.name %}
5 {%- if packed_field.field.kind|is_object_kind %} 5 {%- if packed_field.field.kind|is_object_kind %}
6 void set_{{name}}({{type}} {{name}}) { {{name}}_.ptr = {{name}}; } 6 void set_{{name}}({{type}} {{name}}) { {{name}}_.ptr = {{name}}; }
7 {%- else %} 7 {%- else %}
8 void set_{{name}}({{type}} {{name}}) { {{name}}_ = {{name}}; } 8 void set_{{name}}({{type}} {{name}}) { {{name}}_ = {{name}}; }
9 {%- endif %} 9 {%- endif %}
10 {%- endfor %} 10 {%- endfor %}
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 {%- if num_fields > 0 %} 54 {%- if num_fields > 0 %}
55 {%- set last_field = struct.packed.packed_fields[num_fields - 1] %} 55 {%- set last_field = struct.packed.packed_fields[num_fields - 1] %}
56 {%- set offset = last_field.offset + last_field.size %} 56 {%- set offset = last_field.offset + last_field.size %}
57 {%- set pad = offset|get_pad(8) -%} 57 {%- set pad = offset|get_pad(8) -%}
58 {%- if pad > 0 %} 58 {%- if pad > 0 %}
59 uint8_t _pad{{pad_count}}_[{{pad}}]; 59 uint8_t _pad{{pad_count}}_[{{pad}}];
60 {%- endif %} 60 {%- endif %}
61 {%- endif %} 61 {%- endif %}
62 {%- endmacro %} 62 {%- endmacro %}
63 63
64 {%- macro encodes(struct, param_name) -%} 64 {%- macro encodes(struct) -%}
65 {%- for pf in struct.packed.packed_fields if pf.field.kind|is_object_kind -%} 65 {%- for pf in struct.packed.packed_fields if pf.field.kind|is_object_kind -%}
66 Encode(&{{param_name}}->{{pf.field.name}}_, handles); 66 mojo::internal::Encode(&{{pf.field.name}}_, handles);
67 {% endfor %} 67 {% endfor %}
68 {%- for pf in struct.packed.packed_fields if pf.field.kind|is_handle_kind -%} 68 {%- for pf in struct.packed.packed_fields if pf.field.kind|is_handle_kind -%}
69 EncodeHandle(&{{param_name}}->{{pf.field.name}}_, handles); 69 mojo::internal::EncodeHandle(&{{pf.field.name}}_, handles);
70 {% endfor %} 70 {% endfor %}
71 {%- endmacro -%} 71 {%- endmacro -%}
72 72
73 {%- macro decodes(struct, param_name) -%} 73 {%- macro decodes(struct) -%}
74 {%- for pf in struct.packed.packed_fields if pf.field.kind|is_object_kind -%} 74 {%- for pf in struct.packed.packed_fields if pf.field.kind|is_object_kind -%}
75 if (!Decode(&{{param_name}}->{{pf.field.name}}_, message)) 75 if (!mojo::internal::Decode(&{{pf.field.name}}_, message))
76 return false; 76 return false;
77 {% endfor %} 77 {% endfor %}
78 {%- for pf in struct.packed.packed_fields if pf.field.kind|is_handle_kind -%} 78 {%- for pf in struct.packed.packed_fields if pf.field.kind|is_handle_kind -%}
79 if (!DecodeHandle(&{{param_name}}->{{pf.field.name}}_, &message->handles)) 79 if (!mojo::internal::DecodeHandle(&{{pf.field.name}}_, &message->handles))
80 return false; 80 return false;
81 {% endfor %} 81 {% endfor %}
82 {%- endmacro -%} 82 {%- endmacro -%}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698