14from databasebuilder
import *
19 def _create_input(self, idl_file_name, content):
20 file_name = os.path.join(self.
_input_dir, idl_file_name)
21 f = open(file_name,
'w')
26 def _assert_interface_exists(self, path):
28 self.assertTrue(os.path.exists(file_path))
30 def _assert_content_equals(self, path, expected_content):
34 filter(len, list(
map(str.strip, content.split(
'\n')))))
37 self.assertTrue(os.path.exists(file_path))
38 f = open(file_path,
'r')
39 actual_content = f.read()
41 if clean(actual_content) != clean(expected_content):
48''' % (file_path, expected_content, actual_content)
52 working_dir = tempfile.mkdtemp()
56 self.
_input_dir = os.path.join(working_dir,
'inputdir')
75 self._builder.import_idl_file(file_name)
76 self._builder.merge_imported_interfaces([])
85 readonly attribute int a;
86 int o(in int x,
in optional int y);
89 self._builder.import_idl_file(file_name)
90 self._builder.merge_imported_interfaces([])
96 getter attribute int a;
100 int o(
in int x,
in int y);
107 [Constructor(in T x)] interface I {
109 readonly attribute N::T attr;
113 self.
_builder.import_idl_file(file_name, options)
114 self.
_builder.merge_imported_interfaces([])
118 [Constructor(in t x)] interface i {
120 getter attribute t attr;
132 readonly attribute S attr;
136 self._builder.import_idl_file(file_name, options)
137 self._builder.merge_imported_interfaces([])
144 getter attribute T attr;
154 const int CONST_BOTH = 0;
155 const int CONST_ONLY_FIRST = 0;
156 const int CONST_BOTH_DIFFERENT_VALUE = 0;
158 readonly attribute int attr_only_first;
159 readonly attribute int attr_both;
160 readonly attribute int attr_both_readonly_difference;
161 readonly attribute int attr_both_int_long_difference;
165 int op_both_optionals_difference(int a,
167 int op_both_arg_rename(int arg);
173 source='1st', idl_syntax=idlparser.FREMONTCUT_SYNTAX))
178 const int CONST_BOTH = 0;
179 const int CONST_ONLY_SECOND = 0;
180 const int CONST_BOTH_DIFFERENT_VALUE = 1;
182 readonly attribute int attr_only_second;
183 readonly attribute int attr_both;
184 readonly attribute long attr_both_int_long_difference;
185 attribute int attr_both_readonly_difference;
187 int op_only_second();
189 int op_both_optionals_difference(int a,
191 int op_both_arg_rename(int betterName);
197 source='2nd', idl_syntax=idlparser.FREMONTCUT_SYNTAX))
198 self.
_builder.set_same_signatures({
'int':
'long'})
199 self.
_builder.merge_imported_interfaces([])
203 @1st(module=M) @2nd(module=M) interface I {
205 @1st @2nd const int CONST_BOTH = 0;
206 @1st const int CONST_BOTH_DIFFERENT_VALUE = 0;
207 @2nd const int CONST_BOTH_DIFFERENT_VALUE = 1;
208 @1st const int CONST_ONLY_FIRST = 0;
209 @2nd const int CONST_ONLY_SECOND = 0;
212 @1st @2nd getter attribute int attr_both;
213 @1st @2nd getter attribute int attr_both_int_long_difference;
214 @1st @2nd getter attribute int attr_both_readonly_difference;
215 @2nd setter attribute int attr_both_readonly_difference;
216 @1st getter attribute int attr_only_first;
217 @2nd getter attribute int attr_only_second;
220 @1st @2nd int op_both(in t a);
221 @1st @2nd int op_both_arg_rename(
in t betterName);
222 @1st @2nd int op_both_optionals_difference(
in t a);
223 @1st int op_both_optionals_difference(
in t a,
in int b);
224 @2nd int op_both_optionals_difference(
in t a,
in boolean b);
225 @1st int op_only_first();
226 @2nd int op_only_second();
234 [ImplementationFunction=foo] int member(in int a);
240 source='1st', idl_syntax=idlparser.FREMONTCUT_SYNTAX))
245 [DartName=bar] int member(in int a);
251 source='2nd', idl_syntax=idlparser.FREMONTCUT_SYNTAX))
252 self.
_builder.merge_imported_interfaces([])
256 @1st(module=M) @2nd(module=M) interface I {
258 @1st @2nd [DartName=bar, ImplementationFunction=foo] int member(in int a);
266 readonly attribute int a;
268 [Supplemental] interface I {
269 readonly attribute int b;
272 self._builder.import_idl_file(file_name,
274 self.
_builder.merge_imported_interfaces([])
278 @Src(module=M) [Supplemental] interface I {
280 @Src getter attribute int a;
281 @Src getter attribute int b;
291 self._builder.import_idl_file(file_name,
293 self.
_builder.merge_imported_interfaces([])
297 @Src(module=M) interface I :
306 readonly attribute int keep;
307 readonly attribute int obsolete; // Would be removed
310 self._builder.import_idl_file(file_name1,
316 readonly attribute int keep;
317 readonly attribute int new;
323 source='src', obsolete_old_declarations=
True))
324 self.
_builder.merge_imported_interfaces([])
328 @src(module=M) interface I {
330 @src getter attribute int keep;
331 @src getter attribute int new;
340 readonly attribute int a;
347 self.
_builder.merge_imported_interfaces([])
348 interface = self.
_db.GetInterface(
'I')
349 interface.parents[0].annotations[
'Src'][
'x'] =
'u'
350 interface.constants[0].annotations[
'Src'][
'z'] =
'w'
351 interface.attributes[0].annotations[
'Src'][
'x'] =
'u'
358 interface I :
@Src(x=u) J {
360 @Src(x=y, z=w) const int C = 0;
362 @Src(x=u) getter attribute int a;
368 self.
_builder.normalize_annotations([
'Src'])
375 interface I :
@Src(x=u) J {
377 @Src(z=w) const int C = 0;
379 @Src(x=u) getter attribute int a;
390 readonly attribute int attr;
393 self._builder.import_idl_file(file_name1,
399 readonly attribute int attr;
403 self._builder.import_idl_file(file_name2,
405 self.
_builder.merge_imported_interfaces([])
406 self.
_builder.fix_displacements(
'2nd')
410 @1st(module=M) @2nd(module=M) interface J :
415 getter attribute int attr;
419if __name__ == "__main__":
420 logging.config.fileConfig("logging.conf")
421 if __name__ ==
'__main__':
def test_mergeDartName(self)
def _assert_content_equals(self, path, expected_content)
def test_basic_import(self)
def _assert_interface_exists(self, path)
def test_supplemental(self)
def test_fix_displacements(self)
def _create_input(self, idl_file_name, content)
def test_annotation_normalization(self)
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>
static SkString join(const CommandLineFlags::StringArray &)