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

Side by Side Diff: mojo/public/tools/bindings/generators/java_templates/struct_definition.tmpl

Issue 799113004: Update mojo sdk to rev 59145288bae55b0fce4276b017df6a1117bcf00f (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add mojo's ply to checklicenses whitelist Created 6 years 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
OLDNEW
1 {% from "constant_definition.tmpl" import constant_def %} 1 {% from "constant_definition.tmpl" import constant_def %}
2 {% from "enum_definition.tmpl" import enum_def %} 2 {% from "enum_definition.tmpl" import enum_def %}
3 3
4 {%- macro inequality(kind, v1, v2) -%} 4 {%- macro inequality(kind, v1, v2) -%}
5 {%- if kind|is_reference_kind -%} 5 {%- if kind|is_reference_kind -%}
6 {%- if kind|is_array_kind -%} 6 {%- if kind|is_array_kind -%}
7 {%- if kind.kind|is_reference_kind -%} 7 {%- if kind.kind|is_reference_kind -%}
8 !java.util.Arrays.deepEquals({{v1}}, {{v2}}) 8 !java.util.Arrays.deepEquals({{v1}}, {{v2}})
9 {%- else -%} 9 {%- else -%}
10 !java.util.Arrays.equals({{v1}}, {{v2}}) 10 !java.util.Arrays.equals({{v1}}, {{v2}})
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 {% elif field.kind|is_handle %} 135 {% elif field.kind|is_handle %}
136 {{field|name}} = org.chromium.mojo.system.InvalidHandle.INSTANCE; 136 {{field|name}} = org.chromium.mojo.system.InvalidHandle.INSTANCE;
137 {% endif %} 137 {% endif %}
138 {% endfor %} 138 {% endfor %}
139 } 139 }
140 140
141 public static {{struct|name}} deserialize(org.chromium.mojo.bindings.Message message) { 141 public static {{struct|name}} deserialize(org.chromium.mojo.bindings.Message message) {
142 return decode(new org.chromium.mojo.bindings.Decoder(message)); 142 return decode(new org.chromium.mojo.bindings.Decoder(message));
143 } 143 }
144 144
145 @SuppressWarnings("unchecked")
145 public static {{struct|name}} decode(org.chromium.mojo.bindings.Decoder deco der0) { 146 public static {{struct|name}} decode(org.chromium.mojo.bindings.Decoder deco der0) {
146 if (decoder0 == null) { 147 if (decoder0 == null) {
147 return null; 148 return null;
148 } 149 }
149 {{struct|name}} result = new {{struct|name}}(); 150 {{struct|name}} result = new {{struct|name}}();
150 {% if not struct.bytes %} 151 {% if not struct.bytes %}
151 decoder0.readDataHeader(); 152 decoder0.readDataHeader();
152 {% else %} 153 {% else %}
153 DataHeader mainDataHeader = decoder0.readDataHeader(); 154 DataHeader mainDataHeader = decoder0.readDataHeader();
154 {% endif %} 155 {% endif %}
155 {% for byte in struct.bytes %} 156 {% for byte in struct.bytes %}
156 {% for packed_field in byte.packed_fields %} 157 {% for packed_field in byte.packed_fields %}
157 if (mainDataHeader.numFields > {{packed_field.ordinal}}) { 158 if (mainDataHeader.numFields > {{packed_field.ordinal}}) {
158 {{decode('result.' ~ packed_field.field|name, packed_field.field.kin d, 8+packed_field.offset, packed_field.bit)|indent(12)}} 159 {{decode('result.' ~ packed_field.field|name, packed_field.field.kin d, 8+packed_field.offset, packed_field.bit)|indent(12)}}
159 } 160 }
160 {% endfor %} 161 {% endfor %}
161 {% endfor %} 162 {% endfor %}
162 return result; 163 return result;
163 } 164 }
164 165
166 @SuppressWarnings("unchecked")
165 @Override 167 @Override
166 protected final void encode(org.chromium.mojo.bindings.Encoder encoder) { 168 protected final void encode(org.chromium.mojo.bindings.Encoder encoder) {
167 {% if not struct.bytes %} 169 {% if not struct.bytes %}
168 encoder.getEncoderAtDataOffset(DEFAULT_STRUCT_INFO); 170 encoder.getEncoderAtDataOffset(DEFAULT_STRUCT_INFO);
169 {% else %} 171 {% else %}
170 org.chromium.mojo.bindings.Encoder encoder0 = encoder.getEncoderAtDataOf fset(DEFAULT_STRUCT_INFO); 172 org.chromium.mojo.bindings.Encoder encoder0 = encoder.getEncoderAtDataOf fset(DEFAULT_STRUCT_INFO);
171 {% endif %} 173 {% endif %}
172 {% for byte in struct.bytes %} 174 {% for byte in struct.bytes %}
173 {% for packed_field in byte.packed_fields %} 175 {% for packed_field in byte.packed_fields %}
174 {{encode(packed_field.field|name, packed_field.field.kind, 8+packed_fiel d.offset, packed_field.bit)|indent(8)}} 176 {{encode(packed_field.field|name, packed_field.field.kind, 8+packed_fiel d.offset, packed_field.bit)|indent(8)}}
(...skipping 29 matching lines...) Expand all
204 public int hashCode() { 206 public int hashCode() {
205 final int prime = 31; 207 final int prime = 31;
206 int result = prime + getClass().hashCode(); 208 int result = prime + getClass().hashCode();
207 {% for field in struct.fields %} 209 {% for field in struct.fields %}
208 result = prime * result + {{hash(field.kind, field|name)}}; 210 result = prime * result + {{hash(field.kind, field|name)}};
209 {% endfor %} 211 {% endfor %}
210 return result; 212 return result;
211 } 213 }
212 } 214 }
213 {% endmacro %} 215 {% endmacro %}
OLDNEW
« no previous file with comments | « mojo/public/third_party/ply/yacc.py ('k') | mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698