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

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

Issue 683583002: Update mojo sdk to rev e083961bf11fd0c94d40be8853761da529b6d444 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: geolocation Created 6 years, 1 month 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) -%}
5 {%- if kind|is_reference_kind -%}
6 {%- if kind|is_array_kind -%}
7 {%- if kind.kind|is_reference_kind -%}
8 !java.util.Arrays.deepEquals({{v1}}, {{v2}})
9 {%- else -%}
10 !java.util.Arrays.equals({{v1}}, {{v2}})
11 {%- endif -%}
12 {%- else -%}
13 !org.chromium.mojo.bindings.BindingsHelper.equals({{v1}}, {{v2}})
14 {%- endif -%}
15 {%- else -%}
16 {{v1}} != {{v2}}
17 {%- endif -%}
18 {%- endmacro -%}
19
20 {%- macro hash(kind, v) -%}
21 {%- if kind|is_array_kind -%}
22 {%- if kind.kind|is_reference_kind -%}
23 java.util.Arrays.deepHashCode({{v}})
24 {%- else -%}
25 java.util.Arrays.hashCode({{v}})
26 {%- endif -%}
27 {%- else -%}
28 org.chromium.mojo.bindings.BindingsHelper.hashCode({{v}})
29 {%- endif -%}
30 {%- endmacro -%}
31
4 {% macro encode(variable, kind, offset, bit, level=0, check_for_null=True) %} 32 {% macro encode(variable, kind, offset, bit, level=0, check_for_null=True) %}
5 {% if kind|is_pointer_array_kind %} 33 {% if kind|is_pointer_array_kind %}
6 {% set sub_kind = kind.kind %} 34 {% set sub_kind = kind.kind %}
7 {% if check_for_null %} 35 {% if check_for_null %}
8 if ({{variable}} == null) { 36 if ({{variable}} == null) {
9 encoder{{level}}.encodeNullPointer({{offset}}, {{kind|is_nullable_kind|java_ true_false}}); 37 encoder{{level}}.encodeNullPointer({{offset}}, {{kind|is_nullable_kind|java_ true_false}});
10 } else { 38 } else {
11 {% else %} 39 {% else %}
12 { 40 {
13 {% endif %} 41 {% endif %}
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 encoder.getEncoderAtDataOffset(DEFAULT_STRUCT_INFO); 168 encoder.getEncoderAtDataOffset(DEFAULT_STRUCT_INFO);
141 {% else %} 169 {% else %}
142 org.chromium.mojo.bindings.Encoder encoder0 = encoder.getEncoderAtDataOf fset(DEFAULT_STRUCT_INFO); 170 org.chromium.mojo.bindings.Encoder encoder0 = encoder.getEncoderAtDataOf fset(DEFAULT_STRUCT_INFO);
143 {% endif %} 171 {% endif %}
144 {% for byte in struct.bytes %} 172 {% for byte in struct.bytes %}
145 {% for packed_field in byte.packed_fields %} 173 {% for packed_field in byte.packed_fields %}
146 {{encode(packed_field.field|name, packed_field.field.kind, 8+packed_fiel d.offset, packed_field.bit)|indent(8)}} 174 {{encode(packed_field.field|name, packed_field.field.kind, 8+packed_fiel d.offset, packed_field.bit)|indent(8)}}
147 {% endfor %} 175 {% endfor %}
148 {% endfor %} 176 {% endfor %}
149 } 177 }
178
179 /**
180 * @see Object#equals(Object)
181 */
182 @Override
183 public boolean equals(Object object) {
184 if (object == this)
185 return true;
186 if (object == null)
187 return false;
188 if (getClass() != object.getClass())
189 return false;
190 {{struct|name}} other = ({{struct|name}}) object;
191 {% for field in struct.fields %}
192 if ({{inequality(field.kind, field|name, 'other.'~field|name)}})
193 return false;
194 {% endfor %}
195 return true;
196 }
197
198 /**
199 * @see Object#hashCode()
200 */
201 @Override
202 public int hashCode() {
203 final int prime = 31;
204 int result = 1;
205 {% for field in struct.fields %}
206 result = prime * result + {{hash(field.kind, field|name)}};
207 {% endfor %}
208 return result;
209 }
150 } 210 }
151 {% endmacro %} 211 {% endmacro %}
OLDNEW
« no previous file with comments | « mojo/public/python/mojo/bindings/reflection.py ('k') | mojo/public/tools/bindings/generators/mojom_java_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698