From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- .../tests/resources/webidl2/.gitignore | 4 + .../tests/resources/webidl2/.gitmodules | 3 + .../tests/resources/webidl2/.travis.yml | 3 + .../web-platform/tests/resources/webidl2/LICENSE | 21 + .../web-platform/tests/resources/webidl2/README.md | 760 ++++++++ .../tests/resources/webidl2/coverage.html | 341 ++++ .../web-platform/tests/resources/webidl2/index.js | 1 + .../tests/resources/webidl2/lib/webidl2.js | 1012 +++++++++++ .../tests/resources/webidl2/lib/writer.js | 236 +++ .../tests/resources/webidl2/package.json | 21 + .../tests/resources/webidl2/test/invalid.js | 42 + .../test/invalid/idl/dict-required-default.widl | 5 + .../resources/webidl2/test/invalid/idl/enum.widl | 1 + .../webidl2/test/invalid/idl/maplike-1type.widl | 3 + .../resources/webidl2/test/invalid/idl/module.widl | 25 + .../webidl2/test/invalid/idl/nonnullableany.widl | 3 + .../test/invalid/idl/nonnullableobjects.widl | 5 + .../resources/webidl2/test/invalid/idl/raises.widl | 18 + .../test/invalid/idl/readonly-iterable.widl | 3 + .../webidl2/test/invalid/idl/scopedname.widl | 2 + .../test/invalid/idl/sequenceAsAttribute.widl | 3 + .../webidl2/test/invalid/idl/setlike-2types.widl | 3 + .../test/invalid/idl/special-omittable.widl | 8 + .../webidl2/test/invalid/idl/stringconstants.idl | 3 + .../webidl2/test/invalid/idl/typedef-nested.widl | 22 + .../test/invalid/json/dict-required-default.json | 4 + .../resources/webidl2/test/invalid/json/enum.json | 4 + .../webidl2/test/invalid/json/maplike-1type.json | 4 + .../webidl2/test/invalid/json/module.json | 4 + .../webidl2/test/invalid/json/nonnullableany.json | 4 + .../test/invalid/json/nonnullableobjects.json | 4 + .../webidl2/test/invalid/json/raises.json | 4 + .../test/invalid/json/readonly-iterable.json | 4 + .../webidl2/test/invalid/json/scopedname.json | 4 + .../test/invalid/json/sequenceAsAttribute.json | 4 + .../webidl2/test/invalid/json/setlike-2types.json | 4 + .../test/invalid/json/special-omittable.json | 4 + .../webidl2/test/invalid/json/stringconstants.json | 4 + .../webidl2/test/invalid/json/typedef-nested.json | 4 + .../tests/resources/webidl2/test/mocha.opts | 1 + .../tests/resources/webidl2/test/syntax.js | 41 + .../webidl2/test/syntax/idl/allowany.widl | 6 + .../resources/webidl2/test/syntax/idl/array.widl | 5 + .../webidl2/test/syntax/idl/attributes.widl | 14 + .../webidl2/test/syntax/idl/callback.widl | 7 + .../resources/webidl2/test/syntax/idl/caller.widl | 5 + .../webidl2/test/syntax/idl/constants.widl | 18 + .../webidl2/test/syntax/idl/constructor.widl | 9 + .../test/syntax/idl/dictionary-inherits.widl | 9 + .../webidl2/test/syntax/idl/dictionary.widl | 15 + .../webidl2/test/syntax/idl/documentation-dos.widl | 33 + .../webidl2/test/syntax/idl/documentation.widl | 34 + .../resources/webidl2/test/syntax/idl/enum.widl | 10 + .../webidl2/test/syntax/idl/equivalent-decl.widl | 18 + .../test/syntax/idl/exception-inheritance.widl | 7 + .../webidl2/test/syntax/idl/exception.widl | 8 + .../test/syntax/idl/extended-attributes.widl | 6 + .../resources/webidl2/test/syntax/idl/generic.widl | 17 + .../webidl2/test/syntax/idl/getter-setter.widl | 7 + .../syntax/idl/identifier-qualified-names.widl | 44 + .../webidl2/test/syntax/idl/implements.widl | 14 + .../test/syntax/idl/indexed-properties.widl | 12 + .../webidl2/test/syntax/idl/inherits-getter.widl | 16 + .../test/syntax/idl/interface-inherits.widl | 12 + .../webidl2/test/syntax/idl/iterable.widl | 7 + .../webidl2/test/syntax/idl/iterator.widl | 35 + .../webidl2/test/syntax/idl/legacyiterable.widl | 3 + .../resources/webidl2/test/syntax/idl/map.widl | 5 + .../resources/webidl2/test/syntax/idl/maplike.widl | 7 + .../webidl2/test/syntax/idl/namedconstructor.widl | 6 + .../webidl2/test/syntax/idl/nointerfaceobject.widl | 5 + .../webidl2/test/syntax/idl/nullable.widl | 9 + .../webidl2/test/syntax/idl/nullableobjects.widl | 13 + .../test/syntax/idl/operation-optional-arg.widl | 4 + .../webidl2/test/syntax/idl/overloading.widl | 20 + .../webidl2/test/syntax/idl/overridebuiltins.widl | 6 + .../webidl2/test/syntax/idl/partial-interface.widl | 7 + .../webidl2/test/syntax/idl/primitives.widl | 19 + .../webidl2/test/syntax/idl/prototyperoot.widl | 5 + .../webidl2/test/syntax/idl/putforwards.widl | 5 + .../webidl2/test/syntax/idl/reg-operations.widl | 17 + .../webidl2/test/syntax/idl/replaceable.widl | 5 + .../webidl2/test/syntax/idl/sequence.widl | 12 + .../webidl2/test/syntax/idl/serializer.widl | 64 + .../resources/webidl2/test/syntax/idl/setlike.widl | 7 + .../resources/webidl2/test/syntax/idl/static.widl | 11 + .../test/syntax/idl/stringifier-attribute.widl | 6 + .../test/syntax/idl/stringifier-custom.widl | 9 + .../webidl2/test/syntax/idl/stringifier.widl | 8 + .../webidl2/test/syntax/idl/treatasnull.widl | 7 + .../webidl2/test/syntax/idl/treatasundefined.widl | 7 + .../webidl2/test/syntax/idl/typedef-nested.widl | 22 + .../resources/webidl2/test/syntax/idl/typedef.widl | 22 + .../webidl2/test/syntax/idl/typesuffixes.widl | 3 + .../webidl2/test/syntax/idl/uniontype.widl | 3 + .../test/syntax/idl/variadic-operations.widl | 7 + .../webidl2/test/syntax/json/allowany.json | 109 ++ .../resources/webidl2/test/syntax/json/array.json | 34 + .../webidl2/test/syntax/json/attributes.json | 56 + .../webidl2/test/syntax/json/callback.json | 119 ++ .../resources/webidl2/test/syntax/json/caller.json | 47 + .../webidl2/test/syntax/json/constants.json | 141 ++ .../webidl2/test/syntax/json/constructor.json | 103 ++ .../test/syntax/json/dictionary-inherits.json | 83 + .../webidl2/test/syntax/json/dictionary.json | 135 ++ .../test/syntax/json/documentation-dos.json | 10 + .../webidl2/test/syntax/json/documentation.json | 10 + .../resources/webidl2/test/syntax/json/enum.json | 115 ++ .../webidl2/test/syntax/json/equivalent-decl.json | 312 ++++ .../test/syntax/json/exception-inheritance.json | 37 + .../webidl2/test/syntax/json/exception.json | 35 + .../test/syntax/json/extended-attributes.json | 30 + .../webidl2/test/syntax/json/generic.json | 181 ++ .../webidl2/test/syntax/json/getter-setter.json | 114 ++ .../syntax/json/identifier-qualified-names.json | 217 +++ .../webidl2/test/syntax/json/implements.json | 107 ++ .../test/syntax/json/indexed-properties.json | 272 +++ .../webidl2/test/syntax/json/inherits-getter.json | 71 + .../test/syntax/json/interface-inherits.json | 80 + .../webidl2/test/syntax/json/iterable.json | 55 + .../webidl2/test/syntax/json/iterator.json | 301 ++++ .../webidl2/test/syntax/json/legacyiterable.json | 24 + .../resources/webidl2/test/syntax/json/map.json | 29 + .../webidl2/test/syntax/json/maplike.json | 67 + .../webidl2/test/syntax/json/namedconstructor.json | 42 + .../test/syntax/json/nointerfaceobject.json | 52 + .../webidl2/test/syntax/json/nullable.json | 48 + .../webidl2/test/syntax/json/nullableobjects.json | 99 ++ .../test/syntax/json/operation-optional-arg.json | 93 + .../webidl2/test/syntax/json/overloading.json | 312 ++++ .../webidl2/test/syntax/json/overridebuiltins.json | 69 + .../test/syntax/json/partial-interface.json | 53 + .../webidl2/test/syntax/json/primitives.json | 300 ++++ .../webidl2/test/syntax/json/prototyperoot.json | 33 + .../webidl2/test/syntax/json/putforwards.json | 54 + .../webidl2/test/syntax/json/reg-operations.json | 168 ++ .../webidl2/test/syntax/json/replaceable.json | 54 + .../webidl2/test/syntax/json/sequence.json | 113 ++ .../webidl2/test/syntax/json/serializer.json | 591 +++++++ .../webidl2/test/syntax/json/setlike.json | 47 + .../resources/webidl2/test/syntax/json/static.json | 151 ++ .../test/syntax/json/stringifier-attribute.json | 50 + .../test/syntax/json/stringifier-custom.json | 88 + .../webidl2/test/syntax/json/stringifier.json | 52 + .../webidl2/test/syntax/json/treatasnull.json | 90 + .../webidl2/test/syntax/json/treatasundefined.json | 90 + .../webidl2/test/syntax/json/typedef-nested.json | 226 +++ .../webidl2/test/syntax/json/typedef.json | 226 +++ .../webidl2/test/syntax/json/typesuffixes.json | 55 + .../webidl2/test/syntax/json/uniontype.json | 87 + .../test/syntax/json/variadic-operations.json | 100 ++ .../webidl2/test/syntax/opt/typedef-nested.json | 3 + .../resources/webidl2/test/web/make-web-tests.js | 51 + .../tests/resources/webidl2/test/web/run-tests.js | 48 + .../resources/webidl2/test/widlproc/.gitignore | 3 + .../tests/resources/webidl2/test/widlproc/LICENSE | 202 +++ .../tests/resources/webidl2/test/widlproc/Makefile | 158 ++ .../resources/webidl2/test/widlproc/README.md | 40 + .../webidl2/test/widlproc/doc/htmltodtd.xsl | 28 + .../webidl2/test/widlproc/doc/widlproc.html | 1124 ++++++++++++ .../webidl2/test/widlproc/examples/Makefile | 79 + .../webidl2/test/widlproc/examples/README | 41 + .../webidl2/test/widlproc/examples/bondi.widl | 227 +++ .../webidl2/test/widlproc/examples/filesystem.widl | 1038 +++++++++++ .../webidl2/test/widlproc/examples/spectowidl.xsl | 27 + .../webidl2/test/widlproc/examples/widlhtml.css | 100 ++ .../resources/webidl2/test/widlproc/src/comment.c | 1827 ++++++++++++++++++++ .../resources/webidl2/test/widlproc/src/comment.h | 25 + .../resources/webidl2/test/widlproc/src/entities.h | 271 +++ .../resources/webidl2/test/widlproc/src/lex.c | 560 ++++++ .../resources/webidl2/test/widlproc/src/lex.h | 141 ++ .../resources/webidl2/test/widlproc/src/main.c | 63 + .../resources/webidl2/test/widlproc/src/misc.c | 119 ++ .../resources/webidl2/test/widlproc/src/misc.h | 31 + .../resources/webidl2/test/widlproc/src/node.c | 331 ++++ .../resources/webidl2/test/widlproc/src/node.h | 65 + .../tests/resources/webidl2/test/widlproc/src/os.h | 31 + .../resources/webidl2/test/widlproc/src/parse.c | 1414 +++++++++++++++ .../resources/webidl2/test/widlproc/src/parse.h | 19 + .../resources/webidl2/test/widlproc/src/process.c | 319 ++++ .../resources/webidl2/test/widlproc/src/process.h | 27 + .../test/widlproc/src/widlprocxmltohtml.xsl | 828 +++++++++ .../resources/webidl2/test/widlproc/test/Makefile | 91 + .../test/widlproc/test/invalid/error/enum.txt | 1 + .../test/widlproc/test/invalid/error/module.txt | 1 + .../widlproc/test/invalid/error/nonnullableany.txt | 1 + .../test/invalid/error/nonnullableobjects.txt | 1 + .../widlproc/test/invalid/error/scopedname.txt | 1 + .../test/invalid/error/sequenceAsAttribute.txt | 1 + .../test/invalid/error/stringconstants.idl | 1 + .../test/widlproc/test/invalid/idl/enum.widl | 1 + .../test/widlproc/test/invalid/idl/module.widl | 25 + .../widlproc/test/invalid/idl/nonnullableany.widl | 3 + .../test/invalid/idl/nonnullableobjects.widl | 5 + .../test/widlproc/test/invalid/idl/raises.widl | 18 + .../test/widlproc/test/invalid/idl/scopedname.widl | 2 + .../test/invalid/idl/sequenceAsAttribute.widl | 3 + .../test/invalid/idl/special-omittable.widl | 8 + .../widlproc/test/invalid/idl/stringconstants.idl | 3 + .../test/widlproc/test/valid/idl/allowany.widl | 6 + .../test/widlproc/test/valid/idl/array.widl | 5 + .../test/widlproc/test/valid/idl/attributes.widl | 14 + .../test/widlproc/test/valid/idl/callback.widl | 5 + .../test/widlproc/test/valid/idl/caller.widl | 5 + .../test/widlproc/test/valid/idl/constants.widl | 18 + .../test/widlproc/test/valid/idl/constructor.widl | 9 + .../test/valid/idl/dictionary-inherits.widl | 9 + .../test/widlproc/test/valid/idl/dictionary.widl | 11 + .../widlproc/test/valid/idl/documentation-dos.widl | 33 + .../widlproc/test/valid/idl/documentation.widl | 34 + .../webidl2/test/widlproc/test/valid/idl/enum.widl | 8 + .../widlproc/test/valid/idl/equivalent-decl.widl | 18 + .../test/valid/idl/exception-inheritance.widl | 7 + .../test/widlproc/test/valid/idl/exception.widl | 8 + .../widlproc/test/valid/idl/getter-setter.widl | 7 + .../test/valid/idl/identifier-qualified-names.widl | 44 + .../test/widlproc/test/valid/idl/implements.widl | 14 + .../test/valid/idl/indexed-properties.widl | 12 + .../widlproc/test/valid/idl/inherits-getter.widl | 16 + .../test/valid/idl/interface-inherits.widl | 12 + .../test/widlproc/test/valid/idl/iterator.widl | 35 + .../widlproc/test/valid/idl/namedconstructor.widl | 6 + .../widlproc/test/valid/idl/nointerfaceobject.widl | 5 + .../test/widlproc/test/valid/idl/nullable.widl | 9 + .../widlproc/test/valid/idl/nullableobjects.widl | 13 + .../test/valid/idl/operation-optional-arg.widl | 4 + .../test/widlproc/test/valid/idl/overloading.widl | 20 + .../widlproc/test/valid/idl/overridebuiltins.widl | 6 + .../widlproc/test/valid/idl/partial-interface.widl | 7 + .../test/widlproc/test/valid/idl/primitives.widl | 19 + .../widlproc/test/valid/idl/prototyperoot.widl | 5 + .../test/widlproc/test/valid/idl/putforwards.widl | 5 + .../widlproc/test/valid/idl/reg-operations.widl | 17 + .../test/widlproc/test/valid/idl/replaceable.widl | 5 + .../test/widlproc/test/valid/idl/sequence.widl | 7 + .../test/widlproc/test/valid/idl/serializer.widl | 64 + .../test/widlproc/test/valid/idl/static.widl | 11 + .../test/valid/idl/stringifier-attribute.widl | 6 + .../test/valid/idl/stringifier-custom.widl | 9 + .../test/widlproc/test/valid/idl/stringifier.widl | 8 + .../test/widlproc/test/valid/idl/treatasnull.widl | 7 + .../widlproc/test/valid/idl/treatasundefined.widl | 7 + .../test/widlproc/test/valid/idl/typedef.widl | 22 + .../test/widlproc/test/valid/idl/typesuffixes.widl | 3 + .../test/widlproc/test/valid/idl/uniontype.widl | 3 + .../test/valid/idl/variadic-operations.widl | 7 + .../widlproc/test/valid/xml/allowany.widlprocxml | 44 + .../test/widlproc/test/valid/xml/array.widlprocxml | 27 + .../widlproc/test/valid/xml/attributes.widlprocxml | 38 + .../widlproc/test/valid/xml/callback.widlprocxml | 32 + .../widlproc/test/valid/xml/caller.widlprocxml | 21 + .../widlproc/test/valid/xml/constants.widlprocxml | 85 + .../test/valid/xml/constructor.widlprocxml | 51 + .../test/valid/xml/dictionary-inherits.widlprocxml | 44 + .../widlproc/test/valid/xml/dictionary.widlprocxml | 47 + .../test/valid/xml/documentation-dos.widlprocxml | 59 + .../test/valid/xml/documentation.widlprocxml | 61 + .../test/widlproc/test/valid/xml/enum.widlprocxml | 52 + .../test/valid/xml/equivalent-decl.widlprocxml | 111 ++ .../valid/xml/exception-inheritance.widlprocxml | 31 + .../widlproc/test/valid/xml/exception.widlprocxml | 23 + .../test/valid/xml/getter-setter.widlprocxml | 43 + .../xml/identifier-qualified-names.widlprocxml | 107 ++ .../widlproc/test/valid/xml/implements.widlprocxml | 51 + .../test/valid/xml/indexed-properties.widlprocxml | 92 + .../test/valid/xml/inherits-getter.widlprocxml | 44 + .../test/valid/xml/interface-inherits.widlprocxml | 48 + .../widlproc/test/valid/xml/iterator.widlprocxml | 132 ++ .../widlproc/test/valid/xml/module.widlprocxml | 99 ++ .../test/valid/xml/namedconstructor.widlprocxml | 30 + .../test/valid/xml/namespaceobject.widlprocxml | 60 + .../test/valid/xml/nointerfaceobject.widlprocxml | 28 + .../widlproc/test/valid/xml/nullable.widlprocxml | 29 + .../test/valid/xml/nullableobjects.widlprocxml | 46 + .../valid/xml/operation-optional-arg.widlprocxml | 30 + .../test/valid/xml/overloading.widlprocxml | 113 ++ .../test/valid/xml/overridebuiltins.widlprocxml | 34 + .../test/valid/xml/partial-interface.widlprocxml | 29 + .../widlproc/test/valid/xml/primitives.widlprocxml | 112 ++ .../test/valid/xml/prototyperoot.widlprocxml | 23 + .../test/valid/xml/putforwards.widlprocxml | 27 + .../test/valid/xml/reg-operations.widlprocxml | 70 + .../test/valid/xml/replaceable.widlprocxml | 28 + .../widlproc/test/valid/xml/sequence.widlprocxml | 32 + .../widlproc/test/valid/xml/serializer.widlprocxml | 296 ++++ .../test/valid/xml/special-omittable.widlprocxml | 37 + .../widlproc/test/valid/xml/static.widlprocxml | 58 + .../valid/xml/stringifier-attribute.widlprocxml | 29 + .../test/valid/xml/stringifier-custom.widlprocxml | 44 + .../test/valid/xml/stringifier.widlprocxml | 29 + .../test/valid/xml/treatasnull.widlprocxml | 40 + .../test/valid/xml/treatasundefined.widlprocxml | 40 + .../widlproc/test/valid/xml/typedef.widlprocxml | 100 ++ .../test/valid/xml/typesuffixes.widlprocxml | 25 + .../widlproc/test/valid/xml/uniontype.widlprocxml | 26 + .../test/valid/xml/variadic-operations.widlprocxml | 40 + 296 files changed, 22383 insertions(+) create mode 100644 testing/web-platform/tests/resources/webidl2/.gitignore create mode 100644 testing/web-platform/tests/resources/webidl2/.gitmodules create mode 100644 testing/web-platform/tests/resources/webidl2/.travis.yml create mode 100644 testing/web-platform/tests/resources/webidl2/LICENSE create mode 100644 testing/web-platform/tests/resources/webidl2/README.md create mode 100644 testing/web-platform/tests/resources/webidl2/coverage.html create mode 100644 testing/web-platform/tests/resources/webidl2/index.js create mode 100644 testing/web-platform/tests/resources/webidl2/lib/webidl2.js create mode 100644 testing/web-platform/tests/resources/webidl2/lib/writer.js create mode 100644 testing/web-platform/tests/resources/webidl2/package.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid.js create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/idl/dict-required-default.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/idl/enum.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/idl/maplike-1type.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/idl/module.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/idl/nonnullableany.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/idl/nonnullableobjects.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/idl/raises.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/idl/readonly-iterable.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/idl/scopedname.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/idl/sequenceAsAttribute.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/idl/setlike-2types.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/idl/special-omittable.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/idl/stringconstants.idl create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/idl/typedef-nested.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/json/dict-required-default.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/json/enum.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/json/maplike-1type.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/json/module.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/json/nonnullableany.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/json/nonnullableobjects.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/json/raises.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/json/readonly-iterable.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/json/scopedname.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/json/sequenceAsAttribute.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/json/setlike-2types.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/json/special-omittable.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/json/stringconstants.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/invalid/json/typedef-nested.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/mocha.opts create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax.js create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/allowany.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/array.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/attributes.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/callback.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/caller.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/constants.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/constructor.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/dictionary-inherits.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/dictionary.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/documentation-dos.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/documentation.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/enum.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/equivalent-decl.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/exception-inheritance.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/exception.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/extended-attributes.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/generic.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/getter-setter.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/identifier-qualified-names.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/implements.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/indexed-properties.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/inherits-getter.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/interface-inherits.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/iterable.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/iterator.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/legacyiterable.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/map.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/maplike.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/namedconstructor.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/nointerfaceobject.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/nullable.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/nullableobjects.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/operation-optional-arg.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/overloading.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/overridebuiltins.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/partial-interface.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/primitives.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/prototyperoot.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/putforwards.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/reg-operations.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/replaceable.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/sequence.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/serializer.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/setlike.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/static.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/stringifier-attribute.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/stringifier-custom.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/stringifier.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/treatasnull.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/treatasundefined.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/typedef-nested.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/typedef.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/typesuffixes.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/uniontype.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/idl/variadic-operations.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/allowany.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/array.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/attributes.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/callback.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/caller.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/constants.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/constructor.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/dictionary-inherits.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/dictionary.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/documentation-dos.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/documentation.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/enum.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/equivalent-decl.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/exception-inheritance.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/exception.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/extended-attributes.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/generic.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/getter-setter.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/identifier-qualified-names.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/implements.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/indexed-properties.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/inherits-getter.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/interface-inherits.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/iterable.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/iterator.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/legacyiterable.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/map.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/maplike.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/namedconstructor.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/nointerfaceobject.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/nullable.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/nullableobjects.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/operation-optional-arg.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/overloading.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/overridebuiltins.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/partial-interface.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/primitives.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/prototyperoot.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/putforwards.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/reg-operations.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/replaceable.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/sequence.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/serializer.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/setlike.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/static.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/stringifier-attribute.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/stringifier-custom.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/stringifier.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/treatasnull.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/treatasundefined.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/typedef-nested.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/typedef.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/typesuffixes.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/uniontype.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/json/variadic-operations.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/syntax/opt/typedef-nested.json create mode 100644 testing/web-platform/tests/resources/webidl2/test/web/make-web-tests.js create mode 100644 testing/web-platform/tests/resources/webidl2/test/web/run-tests.js create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/.gitignore create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/LICENSE create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/Makefile create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/README.md create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/doc/htmltodtd.xsl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/doc/widlproc.html create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/examples/Makefile create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/examples/README create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/examples/bondi.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/examples/filesystem.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/examples/spectowidl.xsl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/examples/widlhtml.css create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/src/comment.c create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/src/comment.h create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/src/entities.h create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/src/lex.c create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/src/lex.h create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/src/main.c create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/src/misc.c create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/src/misc.h create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/src/node.c create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/src/node.h create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/src/os.h create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/src/parse.c create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/src/parse.h create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/src/process.c create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/src/process.h create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/src/widlprocxmltohtml.xsl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/Makefile create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/enum.txt create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/module.txt create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/nonnullableany.txt create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/nonnullableobjects.txt create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/scopedname.txt create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/sequenceAsAttribute.txt create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/stringconstants.idl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/enum.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/module.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/nonnullableany.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/nonnullableobjects.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/raises.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/scopedname.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/sequenceAsAttribute.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/special-omittable.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/stringconstants.idl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/allowany.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/array.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/attributes.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/callback.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/caller.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/constants.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/constructor.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/dictionary-inherits.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/dictionary.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/documentation-dos.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/documentation.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/enum.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/equivalent-decl.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/exception-inheritance.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/exception.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/getter-setter.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/identifier-qualified-names.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/implements.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/indexed-properties.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/inherits-getter.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/interface-inherits.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/iterator.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/namedconstructor.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/nointerfaceobject.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/nullable.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/nullableobjects.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/operation-optional-arg.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/overloading.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/overridebuiltins.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/partial-interface.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/primitives.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/prototyperoot.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/putforwards.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/reg-operations.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/replaceable.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/sequence.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/serializer.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/static.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/stringifier-attribute.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/stringifier-custom.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/stringifier.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/treatasnull.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/treatasundefined.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/typedef.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/typesuffixes.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/uniontype.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/variadic-operations.widl create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/allowany.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/array.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/attributes.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/callback.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/caller.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/constants.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/constructor.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/dictionary-inherits.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/dictionary.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/documentation-dos.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/documentation.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/enum.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/equivalent-decl.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/exception-inheritance.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/exception.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/getter-setter.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/identifier-qualified-names.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/implements.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/indexed-properties.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/inherits-getter.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/interface-inherits.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/iterator.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/module.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/namedconstructor.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/namespaceobject.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/nointerfaceobject.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/nullable.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/nullableobjects.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/operation-optional-arg.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/overloading.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/overridebuiltins.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/partial-interface.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/primitives.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/prototyperoot.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/putforwards.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/reg-operations.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/replaceable.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/sequence.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/serializer.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/special-omittable.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/static.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/stringifier-attribute.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/stringifier-custom.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/stringifier.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/treatasnull.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/treatasundefined.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/typedef.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/typesuffixes.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/uniontype.widlprocxml create mode 100644 testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/variadic-operations.widlprocxml (limited to 'testing/web-platform/tests/resources/webidl2') diff --git a/testing/web-platform/tests/resources/webidl2/.gitignore b/testing/web-platform/tests/resources/webidl2/.gitignore new file mode 100644 index 000000000..1d72980cd --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/.gitignore @@ -0,0 +1,4 @@ +scratch +node_modules +lib-cov +browser-tests.html diff --git a/testing/web-platform/tests/resources/webidl2/.gitmodules b/testing/web-platform/tests/resources/webidl2/.gitmodules new file mode 100644 index 000000000..a3f5485cd --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/.gitmodules @@ -0,0 +1,3 @@ +[submodule "test/widlproc"] + path = test/widlproc + url = https://github.com/dontcallmedom/widlproc.git diff --git a/testing/web-platform/tests/resources/webidl2/.travis.yml b/testing/web-platform/tests/resources/webidl2/.travis.yml new file mode 100644 index 000000000..6e5919de3 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: + - "0.10" diff --git a/testing/web-platform/tests/resources/webidl2/LICENSE b/testing/web-platform/tests/resources/webidl2/LICENSE new file mode 100644 index 000000000..fd21d439b --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Robin Berjon + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/testing/web-platform/tests/resources/webidl2/README.md b/testing/web-platform/tests/resources/webidl2/README.md new file mode 100644 index 000000000..f7d03fcde --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/README.md @@ -0,0 +1,760 @@ + +# WebIDL 2 + +[![NPM version](https://badge.fury.io/js/webidl2.png)](http://badge.fury.io/js/webidl2) + +Purpose +======= + +This is a parser for the [WebIDL](http://dev.w3.org/2006/webapi/WebIDL/) language. If +you don't know what that is, then you probably don't need it. It is meant to be used +both in Node and in the browser (the parser likely works in other JS environments, but +not the test suite). + +What of v1? +----------- +There was a previous incarnation of this project. I had written it in the most quick +and dirty manner that was handy because I required it as a dependency in an experiment. +As these things tend to happen, some people started using that, which then had to be +maintained. But since it was not built on solid foundations, it was painful to keep +up to date with the specification, which is a bit of a moving target. + +So I started from scratch. Compared to the previous version (which used a parser generator) +this one is about 6x less code (which translates to 4x smaller minified or 2x smaller +minizipped) and 4x faster. The test suite is reasonably complete (95% coverage), much more +than previously. This version is up to date with WebIDL, rather than a couple years' behind. +It also has *far* better error reporting. + +The AST you get from parsing is very similar to the one you got in v1, but some adjustments +have been made in order to be more systematic, and to map better to what's actually in the spec +now. If you used v1, you will need to tweak your code but the result ought to be simpler and +you ought to be able to be a fair bit less defensive against irregularities in the way +information is represented. + +Installation +============ + +Just the usual. For Node: + + npm install webidl2 + +In the browser: + + + +Documentation +============= + +The API to WebIDL2 is trivial: you parse a string of WebIDL and it returns a syntax tree. + +Parsing +------- +In Node, that happens with: + + var WebIDL2 = require("webidl2"); + var tree = WebIDL2.parse("string of WebIDL"); + +In the browser: + + + + +Advanced Parsing +---------------- + +`parse()` can optionally accept a second parameter, an options object, which can be used to +modify parsing behavior. + +The following options are recognized: +```javascript +{ + allowNestedTypedefs: false # +} +``` +And their meanings are as follows: + +* `allowNestedTypedefs`: Boolean indicating whether the parser should accept `typedef`s as valid members of `interface`s. This is non-standard syntax and therefore the default is `false`. + +Errors +------ +When there is a syntax error in the WebIDL, it throws an exception object with the following +properties: + +* `message`: the error message +* `line`: the line at which the error occurred. +* `input`: a short peek at the text at the point where the error happened +* `tokens`: the five tokens at the point of error, as understood by the tokeniser + (this is the same content as `input`, but seen from the tokeniser's point of view) + +The exception also has a `toString()` method that hopefully should produce a decent +error message. + +AST (Abstract Syntax Tree) +-------------------------- +The `parse()` method returns a tree object representing the parse tree of the IDL. +Comment and white space are not represented in the AST. + +The root of this object is always an array of definitions (where definitions are +any of interfaces, exceptions, callbacks, etc. — anything that can occur at the root +of the IDL). + +### IDL Type + +This structure is used in many other places (operation return types, argument types, etc.). +It captures a WebIDL type with a number of options. Types look like this and are typically +attached to a field called `idlType`: + + { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + } + +Where the fields are as follows: + +* `sequence`: Boolean indicating whether this is a sequence or not. Deprecated. Use + `generic` instead. +* `generic`: String indicating the generic type (e.g. "Promise", "sequence"). `null` + otherwise. +* `nullable`: Boolean indicating whether this is nullable or not. +* `array`: Either `false` to indicate that it is not an array, or a number for the level of + array nesting. +* `union`: Boolean indicating whether this is a union type or not. +* `idlType`: Can be different things depending on context. In most cases, this will just + be a string with the type name. But the reason this field isn't called "typeName" is + because it can take more complex values. If the type is a union, then this contains an + array of the types it unites. If it is a generic type, it contains the IDL type + description for the type in the sequence, the eventual value of the promise, etc. + +#### Interactions between `nullable` and `array` + +A more complex data model for our AST would likely represent `Foo[][][]` as a series of +nested types four levels deep with three anonymous array types eventually containing a +`Foo` type. But experience shows that such structures are cumbersome to use, and so we +have a simpler model in which the depth of the array is specified with the `array` field. + +This is all fine and well, and in the vast majority of cases is actually simpler. But it +does run afoul of cases in which it is necessary to distinguish between `Foo[][][]?`, +`Foo?[][][]`, `Foo[][]?[]`, or even `Foo?[]?[]?[]?`. + +For this, when a type is an array type an additional `nullableArray` field is made available +that captures which of the arrays contain nullable elements. It contains booleans that are +true if the given array depth contains nullable elements, and false otherwise (mapping that to +the syntax, and item is true if there is a `?` preceding the `[]`). These examples ought to +clarify the model: + + Foo[][][]? + -> nullable: true + -> nullableArray: [false, false, false] + Foo?[][][] + -> nullable: false + -> nullableArray: [true, false, false] + Foo[][]?[] + -> nullable: false + -> nullableArray: [false, false, true] + Foo?[]?[]?[]? + -> nullable: true + -> nullableArray: [true, true, true] + +Of particular importance, please note that the overall type is only `nullable` if there is +a `?` at the end. + +### Interface +Interfaces look like this: + + { + "type": "interface", + "name": "Animal", + "partial": false, + "members": [...], + "inheritance": null, + "extAttrs": [...] + }, + { + "type": "interface", + "name": "Human", + "partial": false, + "members": [...], + "inheritance": "Animal", + "extAttrs": [...] + } + +The fields are as follows: + +* `type`: Always "interface". +* `name`: The name of the interface +* `partial`: A boolean indicating whether it's a partial interface. +* `members`: An array of interface members (attributes, operations, etc.). Empty if there are none. +* `inheritance`: A string giving the name of an interface this one inherits from, `null` otherwise. + **NOTE**: In v1 this was an array, but multiple inheritance is no longer supported so this didn't make + sense. +* `extAttrs`: A list of [extended attributes](#extended-attributes). + +### Callback Interfaces + +These are captured by the same structure as [Interfaces](#interface) except that +their `type` field is "callback interface". + +### Callback + +A callback looks like this: + + { + "type": "callback", + "name": "AsyncOperationCallback", + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "arguments": [...], + "extAttrs": [] + } + +The fields are as follows: + +* `type`: Always "callback". +* `name`: The name of the callback. +* `idlType`: An [IDL Type](#idl-type) describing what the callback returns. +* `arguments`: A list of [arguments](#arguments), as in function paramters. +* `extAttrs`: A list of [extended attributes](#extended-attributes). + +### Dictionary + +A dictionary looks like this: + + { + "type": "dictionary", + "name": "PaintOptions", + "partial": false, + "members": [ + { + "type": "field", + "name": "fillPattern", + "required": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": true, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "extAttrs": [], + "default": { + "type": "string", + "value": "black" + } + } + ], + "inheritance": null, + "extAttrs": [] + } + +The fields are as follows: + +* `type`: Always "dictionary". +* `name`: The dictionary name. +* `partial`: Boolean indicating whether it's a partial dictionary. +* `members`: An array of members (see below). +* `inheritance`: A string indicating which dictionary is being inherited from, `null` otherwise. +* `extAttrs`: A list of [extended attributes](#extended-attributes). + +All the members are fields as follows: + +* `type`: Always "field". +* `name`: The name of the field. +* `required`: Boolean indicating whether this is a [required](https://heycam.github.io/webidl/#required-dictionary-member) field. +* `idlType`: An [IDL Type](#idl-type) describing what field's type. +* `extAttrs`: A list of [extended attributes](#extended-attributes). +* `default`: A [default value](#default-and-const-values), absent if there is none. + +### Exception + +An exception looks like this: + + { + "type": "exception", + "name": "HierarchyRequestError", + "members": [ + { + "type": "field", + "name": "code", + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned short" + }, + "extAttrs": [] + } + ], + "inheritance": "DOMException", + "extAttrs": [] + } + +The fields are as follows: + +* `type`: Always "exception". +* `name`: The exception name. +* `members`: An array of members (constants or fields, where fields are described below). +* `inheritance`: A string indicating which exception is being inherited from, `null` otherwise. +* `extAttrs`: A list of [extended attributes](#extended-attributes). + +Members that aren't [constants](#constants) have the following fields: + +* `type`: Always "field". +* `name`: The field's name. +* `idlType`: An [IDL Type](#idl-type) describing what field's type. +* `extAttrs`: A list of [extended attributes](#extended-attributes). + +### Enum + +An enum looks like this: + + { + "type": "enum", + "name": "MealType", + "values": [ + "rice", + "noodles", + "other" + ], + "extAttrs": [] + } + +The fields are as follows: + +* `type`: Always "enum". +* `name`: The enum's name. +* `value`: An array of values (strings). +* `extAttrs`: A list of [extended attributes](#extended-attributes). + +### Typedef + +A typedef looks like this: + + { + "type": "typedef", + "typeExtAttrs": [], + "idlType": { + "sequence": true, + "generic": "sequence", + "nullable": false, + "array": false, + "union": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Point" + } + }, + "name": "PointSequence", + "extAttrs": [] + } + +The fields are as follows: + +* `type`: Always "typedef". +* `name`: The typedef's name. +* `idlType`: An [IDL Type](#idl-type) describing what typedef's type. +* `extAttrs`: A list of [extended attributes](#extended-attributes). +* `typeExtAttrs`: A list of [extended attributes](#extended-attributes) that apply to the +type rather than to the typedef as a whole. + +### Implements + +An implements definition looks like this: + + { + "type": "implements", + "target": "Node", + "implements": "EventTarget", + "extAttrs": [] + } + +The fields are as follows: + +* `type`: Always "implements". +* `target`: The interface that implements another. +* `implements`: The interface that is being implemented by the target. +* `extAttrs`: A list of [extended attributes](#extended-attributes). + +### Operation Member + +An operation looks like this: + + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "intersection", + "arguments": [ + { + "optional": false, + "variadic": true, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "long" + }, + "name": "ints" + } + ], + "extAttrs": [] + } + +The fields are as follows: + +* `type`: Always "operation". +* `getter`: True if a getter operation. +* `setter`: True if a setter operation. +* `creator`: True if a creator operation. +* `deleter`: True if a deleter operation. +* `legacycaller`: True if a legacycaller operation. +* `static`: True if a static operation. +* `stringifier`: True if a stringifier operation. +* `idlType`: An [IDL Type](#idl-type) of what the operation returns. If a stringifier, may be absent. +* `name`: The name of the operation. If a stringifier, may be `null`. +* `arguments`: An array of [arguments](#arguments) for the operation. +* `extAttrs`: A list of [extended attributes](#extended-attributes). + +### Attribute Member + +An attribute member looks like this: + + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "RegExp" + }, + "name": "regexp", + "extAttrs": [] + } + +The fields are as follows: + +* `type`: Always "attribute". +* `name`: The attribute's name. +* `static`: True if it's a static attribute. +* `stringifier`: True if it's a stringifier attribute. +* `inherit`: True if it's an inherit attribute. +* `readonly`: True if it's a read-only attribute. +* `idlType`: An [IDL Type](#idl-type) for the attribute. +* `extAttrs`: A list of [extended attributes](#extended-attributes). + +### Constant Member + +A constant member looks like this: + + { + "type": "const", + "nullable": false, + "idlType": "boolean", + "name": "DEBUG", + "value": { + "type": "boolean", + "value": false + }, + "extAttrs": [] + } + +The fields are as follows: + +* `type`: Always "const". +* `nullable`: Whether its type is nullable. +* `idlType`: The type of the constant (a simple type, the type name). +* `name`: The name of the constant. +* `value`: The constant value as described by [Const Values](#default-and-const-values) +* `extAttrs`: A list of [extended attributes](#extended-attributes). + +### Serializer Member + +Serializers come in many shapes, which are best understood by looking at the +examples below that map the IDL to the produced AST. + + // serializer; + { + "type": "serializer", + "extAttrs": [] + } + + // serializer DOMString serialize(); + { + "type": "serializer", + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "operation": { + "name": "serialize", + "arguments": [] + }, + "extAttrs": [] + } + + // serializer = { from, to, amount, description }; + { + "type": "serializer", + "patternMap": true, + "names": [ + "from", + "to", + "amount", + "description" + ], + "extAttrs": [] + } + + // serializer = number; + { + "type": "serializer", + "name": "number", + "extAttrs": [] + } + + // serializer = [ name, number ]; + { + "type": "serializer", + "patternList": true, + "names": [ + "name", + "number" + ], + "extAttrs": [] + } + +The common fields are as follows: + +* `type`: Always "serializer". +* `extAttrs`: A list of [extended attributes](#extended-attributes). + +For a simple serializer, that's all there is. If the serializer is an operation, it will +have: + +* `idlType`: An [IDL Type](#idl-type) describing what the serializer returns. +* `operation`: An object with the following fields: + * `name`: The name of the operation. + * `arguments`: An array of [arguments](#arguments) for the operation. + +If the serializer is a pattern map: + +* `patternMap`: Always true. +* `names`: An array of names in the pattern map. + +If the serializer is a pattern list: + +* `patternList`: Always true. +* `names`: An array of names in the pattern list. + +Finally, if the serializer is a named serializer: + +* `name`: The serializer's name. + +### Iterator Member + +Iterator members look like this + + { + "type": "iterator", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Session2" + }, + "iteratorObject": "SessionIterator", + "extAttrs": [] + } + +* `type`: Always "iterator". +* `iteratorObject`: The string on the right-hand side; absent if there isn't one. +* the rest: same as on [operations](#operation-member). + +### Arguments + +The arguments (e.g. for an operation) look like this: + + "arguments": [ + { + "optional": false, + "variadic": true, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "long" + }, + "name": "ints" + } + ] + +The fields are as follows: + +* `optional`: True if the argument is optional. +* `variadic`: True if the argument is variadic. +* `idlType`: An [IDL Type](#idl-type) describing the type of the argument. +* `name`: The argument's name. +* `extAttrs`: A list of [extended attributes](#extended-attributes). + +### Extended Attributes + +Extended attributes are arrays of items that look like this: + + "extAttrs": [ + { + "name": "TreatNullAs", + "arguments": null, + "rhs": { + "type": "identifier", + "value": "EmptyString" + } + } + ] + +The fields are as follows: + +* `name`: The extended attribute's name. +* `arguments`: If the extended attribute takes arguments (e.g. `[Foo()]`) or if + its right-hand side does (e.g. `[NamedConstructor=Name(DOMString blah)]`) they + are listed here. Note that an empty arguments list will produce an empty array, + whereas the lack thereof will yield a `null`. If there is an `rhs` field then + they are the right-hand side's arguments, otherwise they apply to the extended + attribute directly. +* `rhs`: If there is a right-hand side, this will capture its `type` (which can be + "identifier" or "identifier-list") and its `value`. +* `typePair`: If the extended attribute is a `MapClass` this will capture the + map's key type and value type respectively. + +### Default and Const Values + +Dictionary fields and operation arguments can take default values, and constants take +values, all of which have the following fields: + +* `type`: One of string, number, boolean, null, Infinity, NaN, or sequence. + +For string, number, boolean, and sequence: + +* `value`: The value of the given type. For sequence, the only possible value is `[]`. + +For Infinity: + +* `negative`: Boolean indicating whether this is negative Infinity or not. + +### `iterable<>`, `legacyiterable<>`, `maplike<>`, `setlike<>` declarations + +These appear as members of interfaces that look like this: + + { + "type": "maplike", // or "legacyiterable" / "iterable" / "setlike" + "idlType": /* One or two types */, + "readonly": false, // only for maplike and setlike + "extAttrs": [] + } + +The fields are as follows: + +* `type`: Always one of "iterable", "legacyiterable", "maplike" or "setlike". +* `idlType`: An [IDL Type](#idl-type) (or an array of two types) representing the declared type arguments. +* `readonly`: Whether the maplike or setlike is declared as read only. +* `extAttrs`: A list of [extended attributes](#extended-attributes). + + +Testing +======= + +In order to run the tests you need to ensure that the widlproc submodule inside `test` is +initialised and up to date: + + git submodule init + git submodule update + +Running +------- +The test runs with mocha and expect.js. Normally, running mocha in the root directory +should be enough once you're set up. + +Coverage +-------- +Current test coverage, as documented in `coverage.html`, is 95%. You can run your own +coverage analysis with: + + jscoverage lib lib-cov + +That will create the lib-cov directory with instrumented code; the test suite knows +to use that if needed. You can then run the tests with: + + JSCOV=1 mocha --reporter html-cov > coverage.html + +Note that I've been getting weirdly overescaped results from the html-cov reporter, +so you might wish to try this instead: + + JSCOV=1 mocha --reporter html-cov | sed "s/<//g" | sed "s/"/\"/g" > coverage.html + +Browser tests +------------- +In order to test in the browser, get inside `test/web` and run `make-web-tests.js`. This +will generate a `browser-tests.html` file that you can open in a browser. As of this +writing tests pass in the latest Firefox, Chrome, Opera, and Safari. Testing on IE +and older versions will happen progressively. + +TODO +==== + +* add some tests to address coverage limitations +* add a push API for processors that need to process things like comments diff --git a/testing/web-platform/tests/resources/webidl2/coverage.html b/testing/web-platform/tests/resources/webidl2/coverage.html new file mode 100644 index 000000000..46e7ed324 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/coverage.html @@ -0,0 +1,341 @@ +Coverage +

Coverage

95%
572
548
24

webidl2.js

95%
572
548
24
LineHitsSource
1
2
31(function () {
41 var tokenise = function (str) {
547 var tokens = []
6 , re = {
7 "float": /^-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][-+]?[0-9]+)?|[0-9]+[Ee][-+]?[0-9]+)/
8 , "integer": /^-?(0([Xx][0-9A-Fa-f]+|[0-7]*)|[1-9][0-9]*)/
9 , "identifier": /^[A-Z_a-z][0-9A-Z_a-z]*/
10 , "string": /^"[^"]*"/
11 , "whitespace": /^(?:[\t\n\r ]+|[\t\n\r ]*((\/\/.*|\/\*(.|\n|\r)*?\*\/)[\t\n\r ]*))+/
12 , "other": /^[^\t\n\r 0-9A-Z_a-z]/
13 }
14 , types = []
15 ;
16329 for (var k in re) types.push(k);
1747 while (str.length > 0) {
182914 var matched = false;
192914 for (var i = 0, n = types.length; i < n; i++) {
2013325 var type = types[i];
2113325 str = str.replace(re[type], function (tok) {
222914 tokens.push({ type: type, value: tok });
232914 matched = true;
242914 return "";
25 });
2616239 if (matched) break;
27 }
285828 if (matched) continue;
290 throw new Error("Token stream not progressing");
30 }
3147 return tokens;
32 };
33
341 var parse = function (tokens) {
3547 var line = 1;
3647 tokens = tokens.slice();
37
3847 var FLOAT = "float"
39 , INT = "integer"
40 , ID = "identifier"
41 , STR = "string"
42 , OTHER = "other"
43 ;
44
4547 var WebIDLParseError = function (str, line, input, tokens) {
460 this.message = str;
470 this.line = line;
480 this.input = input;
490 this.tokens = tokens;
50 };
5147 WebIDLParseError.prototype.toString = function () {
520 return this.message + ", line " + this.line + " (tokens: '" + this.input + "')\n" +
53 JSON.stringify(this.tokens, null, 4);
54 };
55
5647 var error = function (str) {
570 var tok = "", numTokens = 0, maxTokens = 5;
580 while (numTokens < maxTokens && tokens.length > numTokens) {
590 tok += tokens[numTokens].value;
600 numTokens++;
61 }
620 throw new WebIDLParseError(str, line, tok, tokens.slice(0, 5));
63 };
64
6547 var last_token = null;
66
6747 var consume = function (type, value) {
688778 if (!tokens.length || tokens[0].type !== type) return;
695470 if (typeof value === "undefined" || tokens[0].value === value) {
701738 last_token = tokens.shift();
711738 return last_token;
72 }
73 };
74
7547 var ws = function () {
766961 if (!tokens.length) return;
77 // console.log("tokens.length", tokens.length, tokens[0]);
786115 if (tokens[0].type === "whitespace") {
791172 var t = tokens.shift();
802294 t.value.replace(/\n/g, function (m) { line++; return m; });
811172 return t;
82 }
83 };
84
8547 var all_ws = function () {
865366 var t = { type: "whitespace", value: "" };
875366 while (true) {
886538 var w = ws();
8911904 if (!w) break;
901172 t.value += w.value;
91 }
926538 if (t.value.length > 0) return t;
93 };
94
9547 var integer_type = function () {
96273 var ret = "";
97273 all_ws();
98312 if (consume(ID, "unsigned")) ret = "unsigned ";
99273 all_ws();
100287 if (consume(ID, "short")) return ret + "short";
101259 if (consume(ID, "long")) {
10241 ret += "long";
10341 all_ws();
10443 if (consume(ID, "long")) return ret + " long";
10539 return ret;
106 }
107218 if (ret) error("Failed to parse integer type");
108 };
109
11047 var float_type = function () {
111218 var ret = "";
112218 all_ws();
113222 if (consume(ID, "unrestricted")) ret = "unrestricted ";
114218 all_ws();
115257 if (consume(ID, "float")) return ret + "float";
116182 if (consume(ID, "double")) return ret + "double";
117176 if (ret) error("Failed to parse float type");
118 };
119
12047 var primitive_type = function () {
121273 var num_type = integer_type() || float_type();
122370 if (num_type) return num_type;
123176 all_ws();
124186 if (consume(ID, "boolean")) return "boolean";
125167 if (consume(ID, "byte")) return "byte";
126168 if (consume(ID, "octet")) return "octet";
127 };
128
12947 var const_value = function () {
13017 if (consume(ID, "true")) return true;
13119 if (consume(ID, "false")) return false;
13217 if (consume(ID, "null")) return null;
13314 if (consume(ID, "Infinity")) return Infinity;
13413 if (consume(ID, "NaN")) return NaN;
13511 var ret = consume(FLOAT) || consume(INT);
13619 if (ret) return 1 * ret.value;
1373 var tok = consume(OTHER, "-");
1383 if (tok) {
1392 if (consume(ID, "Infinity")) return -Infinity;
1400 else tokens.unshift(tok);
141 }
142 };
143
14447 var type_suffix = function (obj) {
145249 while (true) {
146263 all_ws();
147263 if (consume(OTHER, "?")) {
14811 if (obj.nullable) error("Can't nullable more than once");
14911 obj.nullable = true;
150 }
151252 else if (consume(OTHER, "[")) {
1523 all_ws();
1533 consume(OTHER, "]") || error("Unterminated array type");
1545 if (!obj.array) obj.array = 1;
1551 else obj.array++;
156 }
157249 else return;
158 }
159 };
160
16147 var single_type = function () {
162261 var prim = primitive_type()
163 , ret = { sequence: false, nullable: false, array: false, union: false }
164 ;
165261 if (prim) {
16699 ret.idlType = prim;
167 }
168162 else if (consume(ID, "sequence")) {
1694 all_ws();
1704 if (!consume(OTHER, "<")) {
1710 ret.idlType = "sequence";
172 }
173 else {
1744 ret.sequence = true;
1754 ret.idlType = type() || error("Error parsing sequence type");
1764 all_ws();
1774 if (!consume(OTHER, ">")) error("Unterminated sequence");
1784 all_ws();
1795 if (consume(OTHER, "?")) ret.nullable = true;
1804 return ret;
181 }
182 }
183 else {
184158 var name = consume(ID);
185169 if (!name) return;
186147 ret.idlType = name.value;
187 }
188246 type_suffix(ret);
189246 if (ret.nullable && ret.idlType === "any") error("Type any cannot be made nullable");
190246 return ret;
191 };
192
19347 var union_type = function () {
19411 all_ws();
19519 if (!consume(OTHER, "(")) return;
1963 var ret = { sequence: false, nullable: false, array: false, union: true, idlType: [] };
1973 var fst = type() || error("Union type with no content");
1983 ret.idlType.push(fst);
1993 while (true) {
2007 all_ws();
20110 if (!consume(ID, "or")) break;
2024 var typ = type() || error("No type after 'or' in union type");
2034 ret.idlType.push(typ);
204 }
2053 if (!consume(OTHER, ")")) error("Unterminated union type");
2063 type_suffix(ret);
2073 return ret;
208 };
209
21047 var type = function () {
211261 return single_type() || union_type();
212 };
213
21447 var argument = function () {
21579 var ret = { optional: false, variadic: false };
21679 ret.extAttrs = extended_attrs();
21779 all_ws();
21879 if (consume(ID, "optional")) {
2192 ret.optional = true;
2202 all_ws();
221 }
22279 ret.type = type();
22387 if (!ret.type) return;
22471 if (!ret.optional) {
22569 all_ws();
22669 if (tokens.length >= 3 &&
227 tokens[0].type === "other" && tokens[0].value === "." &&
228 tokens[1].type === "other" && tokens[1].value === "." &&
229 tokens[2].type === "other" && tokens[2].value === "."
230 ) {
2314 tokens.shift();
2324 tokens.shift();
2334 tokens.shift();
2344 ret.variadic = true;
235 }
236 }
23771 all_ws();
23871 var name = consume(ID) || error("No name in argument");
23971 ret.name = name.value;
24071 if (ret.optional) {
2412 all_ws();
2422 ret["default"] = default_();
243 }
24471 return ret;
245 };
246
24747 var argument_list = function () {
24859 var arg = argument(), ret = [];
24967 if (!arg) return ret;
25051 ret.push(arg);
25151 while (true) {
25271 all_ws();
253122 if (!consume(OTHER, ",")) return ret;
25420 all_ws();
25520 var nxt = argument() || error("Trailing comma in arguments list");
25620 ret.push(nxt);
257 }
258 };
259
26047 var simple_extended_attr = function () {
26117 all_ws();
26217 var name = consume(ID);
26317 if (!name) return;
26417 var ret = {
265 name: name.value
266 , "arguments": null
267 };
26817 all_ws();
26917 var eq = consume(OTHER, "=");
27017 if (eq) {
2715 all_ws();
2725 ret.rhs = consume(ID);
2735 if (!ret.rhs) return error("No right hand side to extended attribute assignment");
274 }
27517 all_ws();
27617 if (consume(OTHER, "(")) {
2772 ret["arguments"] = argument_list();
2782 all_ws();
2792 consume(OTHER, ")") || error("Unclosed argument in extended attribute");
280 }
28117 return ret;
282 };
283
284 // Note: we parse something simpler than the official syntax. It's all that ever
285 // seems to be used
28647 var extended_attrs = function () {
287415 var eas = [];
288415 all_ws();
289815 if (!consume(OTHER, "[")) return eas;
29015 eas[0] = simple_extended_attr() || error("Extended attribute with not content");
29115 all_ws();
29215 while (consume(OTHER, ",")) {
2932 all_ws();
2942 eas.push(simple_extended_attr() || error("Trailing comma in extended attribute"));
2952 all_ws();
296 }
29715 consume(OTHER, "]") || error("No end of extended attribute");
29815 return eas;
299 };
300
30147 var default_ = function () {
30211 all_ws();
30311 if (consume(OTHER, "=")) {
3045 all_ws();
3055 var def = const_value();
3065 if (typeof def !== "undefined") {
3073 return def;
308 }
309 else {
3102 var str = consume(STR) || error("No value for default");
3112 return str;
312 }
313 }
314 };
315
31647 var const_ = function () {
317180 all_ws();
318348 if (!consume(ID, "const")) return;
31912 var ret = { type: "const", nullable: false };
32012 all_ws();
32112 var typ = primitive_type();
32212 if (!typ) {
3230 typ = consume(ID) || error("No type for const");
3240 typ = typ.value;
325 }
32612 ret.idlType = typ;
32712 all_ws();
32812 if (consume(OTHER, "?")) {
3291 ret.nullable = true;
3301 all_ws();
331 }
33212 var name = consume(ID) || error("No name for const");
33312 ret.name = name.value;
33412 all_ws();
33512 consume(OTHER, "=") || error("No value assignment for const");
33612 all_ws();
33712 var cnt = const_value();
33824 if (typeof cnt !== "undefined") ret.value = cnt;
3390 else error("No value for const");
34012 all_ws();
34112 consume(OTHER, ";") || error("Unterminated const");
34212 return ret;
343 };
344
34547 var inheritance = function () {
34689 all_ws();
34789 if (consume(OTHER, ":")) {
3489 all_ws();
3499 var inh = consume(ID) || error ("No type in inheritance");
3509 return inh.value;
351 }
352 };
353
35447 var operation_rest = function (ret) {
35556 all_ws();
35657 if (!ret) ret = {};
35756 var name = consume(ID);
35856 ret.name = name ? name.value : null;
35956 all_ws();
36056 consume(OTHER, "(") || error("Invalid operation");
36156 ret["arguments"] = argument_list();
36256 all_ws();
36356 consume(OTHER, ")") || error("Unterminated operation");
36456 all_ws();
36556 consume(OTHER, ";") || error("Unterminated operation");
36656 return ret;
367 };
368
36947 var callback = function () {
370144 all_ws();
371144 var ret;
372286 if (!consume(ID, "callback")) return;
3732 all_ws();
3742 var tok = consume(ID, "interface");
3752 if (tok) {
3761 tokens.unshift(tok);
3771 ret = interface_();
3781 ret.type = "callback interface";
3791 return ret;
380 }
3811 var name = consume(ID) || error("No name for callback");
3821 ret = { type: "callback", name: name.value };
3831 all_ws();
3841 consume(OTHER, "=") || error("No assignment in callback");
3851 all_ws();
3861 ret.idlType = return_type();
3871 all_ws();
3881 consume(OTHER, "(") || error("No arguments in callback");
3891 ret["arguments"] = argument_list();
3901 all_ws();
3911 consume(OTHER, ")") || error("Unterminated callback");
3921 all_ws();
3931 consume(OTHER, ";") || error("Unterminated callback");
3941 return ret;
395 };
396
39747 var attribute = function () {
398154 all_ws();
399154 var grabbed = []
400 , ret = {
401 type: "attribute"
402 , "static": false
403 , stringifier: false
404 , inherit: false
405 , readonly: false
406 };
407154 if (consume(ID, "static")) {
4082 ret["static"] = true;
4092 grabbed.push(last_token);
410 }
411152 else if (consume(ID, "stringifier")) {
4124 ret.stringifier = true;
4134 grabbed.push(last_token);
414 }
415154 var w = all_ws();
416159 if (w) grabbed.push(w);
417154 if (consume(ID, "inherit")) {
4181 if (ret["static"] || ret.stringifier) error("Cannot have a static or stringifier inherit");
4191 ret.inherit = true;
4201 grabbed.push(last_token);
4211 var w = all_ws();
4222 if (w) grabbed.push(w);
423 }
424154 if (consume(ID, "readonly")) {
42532 ret.readonly = true;
42632 grabbed.push(last_token);
42732 var w = all_ws();
42864 if (w) grabbed.push(w);
429 }
430154 if (!consume(ID, "attribute")) {
43160 tokens = grabbed.concat(tokens);
43260 return;
433 }
43494 all_ws();
43594 ret.idlType = type() || error("No type in attribute");
43694 if (ret.idlType.sequence) error("Attributes cannot accept sequence types");
43794 all_ws();
43894 var name = consume(ID) || error("No name in attribute");
43994 ret.name = name.value;
44094 all_ws();
44194 consume(OTHER, ";") || error("Unterminated attribute");
44294 return ret;
443 };
444
44547 var return_type = function () {
44661 var typ = type();
44761 if (!typ) {
4480 if (consume(ID, "void")) {
4490 return "void";
450 }
4510 else error("No return type");
452 }
45361 return typ;
454 };
455
45647 var operation = function () {
45760 all_ws();
45860 var ret = {
459 type: "operation"
460 , getter: false
461 , setter: false
462 , creator: false
463 , deleter: false
464 , legacycaller: false
465 , "static": false
466 , stringifier: false
467 };
46860 while (true) {
46978 all_ws();
47087 if (consume(ID, "getter")) ret.getter = true;
47174 else if (consume(ID, "setter")) ret.setter = true;
47265 else if (consume(ID, "creator")) ret.creator = true;
47365 else if (consume(ID, "deleter")) ret.deleter = true;
47462 else if (consume(ID, "legacycaller")) ret.legacycaller = true;
47560 else break;
476 }
47760 if (ret.getter || ret.setter || ret.creator || ret.deleter || ret.legacycaller) {
47817 all_ws();
47917 ret.idlType = return_type();
48017 operation_rest(ret);
48117 return ret;
482 }
48343 if (consume(ID, "static")) {
4841 ret["static"] = true;
4851 ret.idlType = return_type();
4861 operation_rest(ret);
4871 return ret;
488 }
48942 else if (consume(ID, "stringifier")) {
4903 ret.stringifier = true;
4913 all_ws();
4924 if (consume(OTHER, ";")) return ret;
4932 ret.idlType = return_type();
4942 operation_rest(ret);
4952 return ret;
496 }
49739 ret.idlType = return_type();
49839 all_ws();
49939 if (consume(ID, "iterator")) {
5004 all_ws();
5014 ret.type = "iterator";
5024 if (consume(ID, "object")) {
5031 ret.iteratorObject = "object";
504 }
5053 else if (consume(OTHER, "=")) {
5062 all_ws();
5072 var name = consume(ID) || error("No right hand side in iterator");
5082 ret.iteratorObject = name.value;
509 }
5104 all_ws();
5114 consume(OTHER, ";") || error("Unterminated iterator");
5124 return ret;
513 }
514 else {
51535 operation_rest(ret);
51635 return ret;
517 }
518 };
519
52047 var identifiers = function (arr) {
5215 while (true) {
52211 all_ws();
52311 if (consume(OTHER, ",")) {
5246 all_ws();
5256 var name = consume(ID) || error("Trailing comma in identifiers list");
5266 arr.push(name.value);
527 }
5285 else break;
529 }
530 };
531
53247 var serialiser = function () {
533164 all_ws();
534318 if (!consume(ID, "serializer")) return;
53510 var ret = { type: "serializer" };
53610 all_ws();
53710 if (consume(OTHER, "=")) {
5388 all_ws();
5398 if (consume(OTHER, "{")) {
5405 ret.patternMap = true;
5415 all_ws();
5425 var id = consume(ID);
5435 if (id && id.value === "getter") {
5441 ret.names = ["getter"];
545 }
5464 else if (id && id.value === "inherit") {
5472 ret.names = ["inherit"];
5482 identifiers(ret.names);
549 }
5502 else if (id) {
5512 ret.names = [id.value];
5522 identifiers(ret.names);
553 }
554 else {
5550 ret.names = [];
556 }
5575 all_ws();
5585 consume(OTHER, "}") || error("Unterminated serializer pattern map");
559 }
5603 else if (consume(OTHER, "[")) {
5612 ret.patternList = true;
5622 all_ws();
5632 var id = consume(ID);
5642 if (id && id.value === "getter") {
5651 ret.names = ["getter"];
566 }
5671 else if (id) {
5681 ret.names = [id.value];
5691 identifiers(ret.names);
570 }
571 else {
5720 ret.names = [];
573 }
5742 all_ws();
5752 consume(OTHER, "]") || error("Unterminated serializer pattern list");
576 }
577 else {
5781 var name = consume(ID) || error("Invalid serializer");
5791 ret.name = name.value;
580 }
5818 all_ws();
5828 consume(OTHER, ";") || error("Unterminated serializer");
5838 return ret;
584 }
5852 else if (consume(OTHER, ";")) {
586 // noop, just parsing
587 }
588 else {
5891 ret.idlType = return_type();
5901 all_ws();
5911 ret.operation = operation_rest();
592 }
5932 return ret;
594 };
595
59647 var interface_ = function (isPartial) {
597144 all_ws();
598210 if (!consume(ID, "interface")) return;
59978 all_ws();
60078 var name = consume(ID) || error("No name for interface");
60178 var ret = {
602 type: "interface"
603 , name: name.value
604 , partial: false
605 , members: []
606 };
607155 if (!isPartial) ret.inheritance = inheritance() || null;
60878 all_ws();
60978 consume(OTHER, "{") || error("Bodyless interface");
61078 while (true) {
611251 all_ws();
612251 if (consume(OTHER, "}")) {
61378 all_ws();
61478 consume(OTHER, ";") || error("Missing semicolon after interface");
61578 return ret;
616 }
617173 var ea = extended_attrs();
618173 all_ws();
619173 var cnt = const_();
620173 if (cnt) {
6219 cnt.extAttrs = ea;
6229 ret.members.push(cnt);
6239 continue;
624 }
625164 var mem = serialiser() || attribute() || operation() || error("Unknown member");
626164 mem.extAttrs = ea;
627164 ret.members.push(mem);
628 }
629 };
630
63147 var partial = function () {
63266 all_ws();
633130 if (!consume(ID, "partial")) return;
6342 var thing = dictionary(true) || interface_(true) || error("Partial doesn't apply to anything");
6352 thing.partial = true;
6362 return thing;
637 };
638
63947 var dictionary = function (isPartial) {
64066 all_ws();
641128 if (!consume(ID, "dictionary")) return;
6424 all_ws();
6434 var name = consume(ID) || error("No name for dictionary");
6444 var ret = {
645 type: "dictionary"
646 , name: name.value
647 , partial: false
648 , members: []
649 };
6507 if (!isPartial) ret.inheritance = inheritance() || null;
6514 all_ws();
6524 consume(OTHER, "{") || error("Bodyless dictionary");
6534 while (true) {
65413 all_ws();
65513 if (consume(OTHER, "}")) {
6564 all_ws();
6574 consume(OTHER, ";") || error("Missing semicolon after dictionary");
6584 return ret;
659 }
6609 var ea = extended_attrs();
6619 all_ws();
6629 var typ = type() || error("No type for dictionary member");
6639 all_ws();
6649 var name = consume(ID) || error("No name for dictionary member");
6659 ret.members.push({
666 type: "field"
667 , name: name.value
668 , idlType: typ
669 , extAttrs: ea
670 , "default": default_()
671 });
6729 all_ws();
6739 consume(OTHER, ";") || error("Unterminated dictionary member");
674 }
675 };
676
67747 var exception = function () {
67861 all_ws();
679113 if (!consume(ID, "exception")) return;
6809 all_ws();
6819 var name = consume(ID) || error("No name for exception");
6829 var ret = {
683 type: "exception"
684 , name: name.value
685 , members: []
686 };
6879 ret.inheritance = inheritance() || null;
6889 all_ws();
6899 consume(OTHER, "{") || error("Bodyless exception");
6909 while (true) {
69116 all_ws();
69216 if (consume(OTHER, "}")) {
6939 all_ws();
6949 consume(OTHER, ";") || error("Missing semicolon after exception");
6959 return ret;
696 }
6977 var ea = extended_attrs();
6987 all_ws();
6997 var cnt = const_();
7007 if (cnt) {
7013 cnt.extAttrs = ea;
7023 ret.members.push(cnt);
703 }
704 else {
7054 var typ = type();
7064 all_ws();
7074 var name = consume(ID);
7084 all_ws();
7094 if (!typ || !name || !consume(OTHER, ";")) error("Unknown member in exception body");
7104 ret.members.push({
711 type: "field"
712 , name: name.value
713 , idlType: typ
714 , extAttrs: ea
715 });
716 }
717 }
718 };
719
72047 var enum_ = function () {
72152 all_ws();
722103 if (!consume(ID, "enum")) return;
7231 all_ws();
7241 var name = consume(ID) || error("No name for enum");
7251 var ret = {
726 type: "enum"
727 , name: name.value
728 , values: []
729 };
7301 all_ws();
7311 consume(OTHER, "{") || error("No curly for enum");
7321 var saw_comma = false;
7331 while (true) {
7344 all_ws();
7354 if (consume(OTHER, "}")) {
7361 all_ws();
7371 if (saw_comma) error("Trailing comma in enum");
7381 consume(OTHER, ";") || error("No semicolon after enum");
7391 return ret;
740 }
7413 var val = consume(STR) || error("Unexpected value in enum");
7423 ret.values.push(val.value.replace(/"/g, ""));
7433 all_ws();
7443 if (consume(OTHER, ",")) {
7452 all_ws();
7462 saw_comma = true;
747 }
748 else {
7491 saw_comma = false;
750 }
751 }
752 };
753
75447 var typedef = function () {
75551 all_ws();
75699 if (!consume(ID, "typedef")) return;
7573 var ret = {
758 type: "typedef"
759 };
7603 all_ws();
7613 ret.extAttrs = extended_attrs();
7623 all_ws();
7633 ret.idlType = type() || error("No type in typedef");
7643 all_ws();
7653 var name = consume(ID) || error("No name in typedef");
7663 ret.name = name.value;
7673 all_ws();
7683 consume(OTHER, ";") || error("Unterminated typedef");
7693 return ret;
770 };
771
77247 var implements_ = function () {
77348 all_ws();
77448 var target = consume(ID);
77595 if (!target) return;
7761 var w = all_ws();
7771 if (consume(ID, "implements")) {
7781 var ret = {
779 type: "implements"
780 , target: target.value
781 };
7821 all_ws();
7831 var imp = consume(ID) || error("Incomplete implements statement");
7841 ret["implements"] = imp.value;
7851 all_ws();
7861 consume(OTHER, ";") || error("No terminating ; for implements statement");
7871 return ret;
788 }
789 else {
790 // rollback
7910 tokens.unshift(w);
7920 tokens.unshift(target);
793 }
794 };
795
79647 var definition = function () {
797144 return callback() ||
798 interface_() ||
799 partial() ||
800 dictionary() ||
801 exception() ||
802 enum_() ||
803 typedef() ||
804 implements_()
805 ;
806 };
807
80847 var definitions = function () {
80947 if (!tokens.length) return [];
81047 var defs = [];
81147 while (true) {
812144 var ea = extended_attrs()
813 , def = definition();
814144 if (!def) {
81547 if (ea.length) error("Stray extended attributes");
81647 break;
817 }
81897 def.extAttrs = ea;
81997 defs.push(def);
820 }
82147 return defs;
822 };
82347 var res = definitions();
82447 if (tokens.length) error("Unrecognised tokens");
82547 return res;
826 };
827
8281 var obj = {
829 parse: function (str) {
83047 var tokens = tokenise(str);
831 // console.log(tokens);
83247 return parse(tokens);
833 }
834 };
8351 if (typeof module !== "undefined" && module.exports) {
8361 module.exports = obj;
837 }
838 else {
8390 window.WebIDL2 = obj;
840 }
841}());
diff --git a/testing/web-platform/tests/resources/webidl2/index.js b/testing/web-platform/tests/resources/webidl2/index.js new file mode 100644 index 000000000..09f9eb46a --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/index.js @@ -0,0 +1 @@ +module.exports = require("./lib/webidl2.js"); diff --git a/testing/web-platform/tests/resources/webidl2/lib/webidl2.js b/testing/web-platform/tests/resources/webidl2/lib/webidl2.js new file mode 100644 index 000000000..9e504fc6e --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/lib/webidl2.js @@ -0,0 +1,1012 @@ + + +(function () { + var tokenise = function (str) { + var tokens = [] + , re = { + "float": /^-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][-+]?[0-9]+)?|[0-9]+[Ee][-+]?[0-9]+)/ + , "integer": /^-?(0([Xx][0-9A-Fa-f]+|[0-7]*)|[1-9][0-9]*)/ + , "identifier": /^[A-Z_a-z][0-9A-Z_a-z]*/ + , "string": /^"[^"]*"/ + , "whitespace": /^(?:[\t\n\r ]+|[\t\n\r ]*((\/\/.*|\/\*(.|\n|\r)*?\*\/)[\t\n\r ]*))+/ + , "other": /^[^\t\n\r 0-9A-Z_a-z]/ + } + , types = [] + ; + for (var k in re) types.push(k); + while (str.length > 0) { + var matched = false; + for (var i = 0, n = types.length; i < n; i++) { + var type = types[i]; + str = str.replace(re[type], function (tok) { + tokens.push({ type: type, value: tok }); + matched = true; + return ""; + }); + if (matched) break; + } + if (matched) continue; + throw new Error("Token stream not progressing"); + } + return tokens; + }; + + var parse = function (tokens, opt) { + var line = 1; + tokens = tokens.slice(); + + var FLOAT = "float" + , INT = "integer" + , ID = "identifier" + , STR = "string" + , OTHER = "other" + ; + + var WebIDLParseError = function (str, line, input, tokens) { + this.message = str; + this.line = line; + this.input = input; + this.tokens = tokens; + }; + WebIDLParseError.prototype.toString = function () { + return this.message + ", line " + this.line + " (tokens: '" + this.input + "')\n" + + JSON.stringify(this.tokens, null, 4); + }; + + var error = function (str) { + var tok = "", numTokens = 0, maxTokens = 5; + while (numTokens < maxTokens && tokens.length > numTokens) { + tok += tokens[numTokens].value; + numTokens++; + } + throw new WebIDLParseError(str, line, tok, tokens.slice(0, 5)); + }; + + var last_token = null; + + var consume = function (type, value) { + if (!tokens.length || tokens[0].type !== type) return; + if (typeof value === "undefined" || tokens[0].value === value) { + last_token = tokens.shift(); + if (type === ID) last_token.value = last_token.value.replace(/^_/, ""); + return last_token; + } + }; + + var ws = function () { + if (!tokens.length) return; + if (tokens[0].type === "whitespace") { + var t = tokens.shift(); + t.value.replace(/\n/g, function (m) { line++; return m; }); + return t; + } + }; + + var all_ws = function (store, pea) { // pea == post extended attribute, tpea = same for types + var t = { type: "whitespace", value: "" }; + while (true) { + var w = ws(); + if (!w) break; + t.value += w.value; + } + if (t.value.length > 0) { + if (store) { + var w = t.value + , re = { + "ws": /^([\t\n\r ]+)/ + , "line-comment": /^\/\/(.*)\n?/m + , "multiline-comment": /^\/\*((?:.|\n|\r)*?)\*\// + } + , wsTypes = [] + ; + for (var k in re) wsTypes.push(k); + while (w.length) { + var matched = false; + for (var i = 0, n = wsTypes.length; i < n; i++) { + var type = wsTypes[i]; + w = w.replace(re[type], function (tok, m1) { + store.push({ type: type + (pea ? ("-" + pea) : ""), value: m1 }); + matched = true; + return ""; + }); + if (matched) break; + } + if (matched) continue; + throw new Error("Surprising white space construct."); // this shouldn't happen + } + } + return t; + } + }; + + var integer_type = function () { + var ret = ""; + all_ws(); + if (consume(ID, "unsigned")) ret = "unsigned "; + all_ws(); + if (consume(ID, "short")) return ret + "short"; + if (consume(ID, "long")) { + ret += "long"; + all_ws(); + if (consume(ID, "long")) return ret + " long"; + return ret; + } + if (ret) error("Failed to parse integer type"); + }; + + var float_type = function () { + var ret = ""; + all_ws(); + if (consume(ID, "unrestricted")) ret = "unrestricted "; + all_ws(); + if (consume(ID, "float")) return ret + "float"; + if (consume(ID, "double")) return ret + "double"; + if (ret) error("Failed to parse float type"); + }; + + var primitive_type = function () { + var num_type = integer_type() || float_type(); + if (num_type) return num_type; + all_ws(); + if (consume(ID, "boolean")) return "boolean"; + if (consume(ID, "byte")) return "byte"; + if (consume(ID, "octet")) return "octet"; + }; + + var const_value = function () { + if (consume(ID, "true")) return { type: "boolean", value: true }; + if (consume(ID, "false")) return { type: "boolean", value: false }; + if (consume(ID, "null")) return { type: "null" }; + if (consume(ID, "Infinity")) return { type: "Infinity", negative: false }; + if (consume(ID, "NaN")) return { type: "NaN" }; + var ret = consume(FLOAT) || consume(INT); + if (ret) return { type: "number", value: 1 * ret.value }; + var tok = consume(OTHER, "-"); + if (tok) { + if (consume(ID, "Infinity")) return { type: "Infinity", negative: true }; + else tokens.unshift(tok); + } + }; + + var type_suffix = function (obj) { + while (true) { + all_ws(); + if (consume(OTHER, "?")) { + if (obj.nullable) error("Can't nullable more than once"); + obj.nullable = true; + } + else if (consume(OTHER, "[")) { + all_ws(); + consume(OTHER, "]") || error("Unterminated array type"); + if (!obj.array) { + obj.array = 1; + obj.nullableArray = [obj.nullable]; + } + else { + obj.array++; + obj.nullableArray.push(obj.nullable); + } + obj.nullable = false; + } + else return; + } + }; + + var single_type = function () { + var prim = primitive_type() + , ret = { sequence: false, generic: null, nullable: false, array: false, union: false } + , name + , value + ; + if (prim) { + ret.idlType = prim; + } + else if (name = consume(ID)) { + value = name.value; + all_ws(); + // Generic types + if (consume(OTHER, "<")) { + // backwards compat + if (value === "sequence") { + ret.sequence = true; + } + ret.generic = value; + ret.idlType = type() || error("Error parsing generic type " + value); + all_ws(); + if (!consume(OTHER, ">")) error("Unterminated generic type " + value); + type_suffix(ret); + return ret; + } + else { + ret.idlType = value; + } + } + else { + return; + } + type_suffix(ret); + if (ret.nullable && !ret.array && ret.idlType === "any") error("Type any cannot be made nullable"); + return ret; + }; + + var union_type = function () { + all_ws(); + if (!consume(OTHER, "(")) return; + var ret = { sequence: false, generic: null, nullable: false, array: false, union: true, idlType: [] }; + var fst = type() || error("Union type with no content"); + ret.idlType.push(fst); + while (true) { + all_ws(); + if (!consume(ID, "or")) break; + var typ = type() || error("No type after 'or' in union type"); + ret.idlType.push(typ); + } + if (!consume(OTHER, ")")) error("Unterminated union type"); + type_suffix(ret); + return ret; + }; + + var type = function () { + return single_type() || union_type(); + }; + + var argument = function (store) { + var ret = { optional: false, variadic: false }; + ret.extAttrs = extended_attrs(store); + all_ws(store, "pea"); + var opt_token = consume(ID, "optional"); + if (opt_token) { + ret.optional = true; + all_ws(); + } + ret.idlType = type(); + if (!ret.idlType) { + if (opt_token) tokens.unshift(opt_token); + return; + } + var type_token = last_token; + if (!ret.optional) { + all_ws(); + if (tokens.length >= 3 && + tokens[0].type === "other" && tokens[0].value === "." && + tokens[1].type === "other" && tokens[1].value === "." && + tokens[2].type === "other" && tokens[2].value === "." + ) { + tokens.shift(); + tokens.shift(); + tokens.shift(); + ret.variadic = true; + } + } + all_ws(); + var name = consume(ID); + if (!name) { + if (opt_token) tokens.unshift(opt_token); + tokens.unshift(type_token); + return; + } + ret.name = name.value; + if (ret.optional) { + all_ws(); + ret["default"] = default_(); + } + return ret; + }; + + var argument_list = function (store) { + var ret = [] + , arg = argument(store ? ret : null) + ; + if (!arg) return; + ret.push(arg); + while (true) { + all_ws(store ? ret : null); + if (!consume(OTHER, ",")) return ret; + var nxt = argument(store ? ret : null) || error("Trailing comma in arguments list"); + ret.push(nxt); + } + }; + + var type_pair = function () { + all_ws(); + var k = type(); + if (!k) return; + all_ws() + if (!consume(OTHER, ",")) return; + all_ws(); + var v = type(); + if (!v) return; + return [k, v]; + }; + + var simple_extended_attr = function (store) { + all_ws(); + var name = consume(ID); + if (!name) return; + var ret = { + name: name.value + , "arguments": null + }; + all_ws(); + var eq = consume(OTHER, "="); + if (eq) { + var rhs; + all_ws(); + if (rhs = consume(ID)) { + ret.rhs = rhs + } + else if (consume(OTHER, "(")) { + // [Exposed=(Window,Worker)] + rhs = []; + var id = consume(ID); + if (id) { + rhs = [id.value]; + } + identifiers(rhs); + consume(OTHER, ")") || error("Unexpected token in extended attribute argument list or type pair"); + ret.rhs = { + type: "identifier-list", + value: rhs + }; + } + if (!ret.rhs) return error("No right hand side to extended attribute assignment"); + } + all_ws(); + if (consume(OTHER, "(")) { + var args, pair; + // [Constructor(DOMString str)] + if (args = argument_list(store)) { + ret["arguments"] = args; + } + // [MapClass(DOMString, DOMString)] + else if (pair = type_pair()) { + ret.typePair = pair; + } + // [Constructor()] + else { + ret["arguments"] = []; + } + all_ws(); + consume(OTHER, ")") || error("Unexpected token in extended attribute argument list or type pair"); + } + return ret; + }; + + // Note: we parse something simpler than the official syntax. It's all that ever + // seems to be used + var extended_attrs = function (store) { + var eas = []; + all_ws(store); + if (!consume(OTHER, "[")) return eas; + eas[0] = simple_extended_attr(store) || error("Extended attribute with not content"); + all_ws(); + while (consume(OTHER, ",")) { + eas.push(simple_extended_attr(store) || error("Trailing comma in extended attribute")); + all_ws(); + } + consume(OTHER, "]") || error("No end of extended attribute"); + return eas; + }; + + var default_ = function () { + all_ws(); + if (consume(OTHER, "=")) { + all_ws(); + var def = const_value(); + if (def) { + return def; + } + else if (consume(OTHER, "[")) { + if (!consume(OTHER, "]")) error("Default sequence value must be empty"); + return { type: "sequence", value: [] }; + } + else { + var str = consume(STR) || error("No value for default"); + str.value = str.value.replace(/^"/, "").replace(/"$/, ""); + return str; + } + } + }; + + var const_ = function (store) { + all_ws(store, "pea"); + if (!consume(ID, "const")) return; + var ret = { type: "const", nullable: false }; + all_ws(); + var typ = primitive_type(); + if (!typ) { + typ = consume(ID) || error("No type for const"); + typ = typ.value; + } + ret.idlType = typ; + all_ws(); + if (consume(OTHER, "?")) { + ret.nullable = true; + all_ws(); + } + var name = consume(ID) || error("No name for const"); + ret.name = name.value; + all_ws(); + consume(OTHER, "=") || error("No value assignment for const"); + all_ws(); + var cnt = const_value(); + if (cnt) ret.value = cnt; + else error("No value for const"); + all_ws(); + consume(OTHER, ";") || error("Unterminated const"); + return ret; + }; + + var inheritance = function () { + all_ws(); + if (consume(OTHER, ":")) { + all_ws(); + var inh = consume(ID) || error ("No type in inheritance"); + return inh.value; + } + }; + + var operation_rest = function (ret, store) { + all_ws(); + if (!ret) ret = {}; + var name = consume(ID); + ret.name = name ? name.value : null; + all_ws(); + consume(OTHER, "(") || error("Invalid operation"); + ret["arguments"] = argument_list(store) || []; + all_ws(); + consume(OTHER, ")") || error("Unterminated operation"); + all_ws(); + consume(OTHER, ";") || error("Unterminated operation"); + return ret; + }; + + var callback = function (store) { + all_ws(store, "pea"); + var ret; + if (!consume(ID, "callback")) return; + all_ws(); + var tok = consume(ID, "interface"); + if (tok) { + tokens.unshift(tok); + ret = interface_(); + ret.type = "callback interface"; + return ret; + } + var name = consume(ID) || error("No name for callback"); + ret = { type: "callback", name: name.value }; + all_ws(); + consume(OTHER, "=") || error("No assignment in callback"); + all_ws(); + ret.idlType = return_type(); + all_ws(); + consume(OTHER, "(") || error("No arguments in callback"); + ret["arguments"] = argument_list(store) || []; + all_ws(); + consume(OTHER, ")") || error("Unterminated callback"); + all_ws(); + consume(OTHER, ";") || error("Unterminated callback"); + return ret; + }; + + var attribute = function (store) { + all_ws(store, "pea"); + var grabbed = [] + , ret = { + type: "attribute" + , "static": false + , stringifier: false + , inherit: false + , readonly: false + }; + if (consume(ID, "static")) { + ret["static"] = true; + grabbed.push(last_token); + } + else if (consume(ID, "stringifier")) { + ret.stringifier = true; + grabbed.push(last_token); + } + var w = all_ws(); + if (w) grabbed.push(w); + if (consume(ID, "inherit")) { + if (ret["static"] || ret.stringifier) error("Cannot have a static or stringifier inherit"); + ret.inherit = true; + grabbed.push(last_token); + var w = all_ws(); + if (w) grabbed.push(w); + } + if (consume(ID, "readonly")) { + ret.readonly = true; + grabbed.push(last_token); + var w = all_ws(); + if (w) grabbed.push(w); + } + if (!consume(ID, "attribute")) { + tokens = grabbed.concat(tokens); + return; + } + all_ws(); + ret.idlType = type() || error("No type in attribute"); + if (ret.idlType.sequence) error("Attributes cannot accept sequence types"); + all_ws(); + var name = consume(ID) || error("No name in attribute"); + ret.name = name.value; + all_ws(); + consume(OTHER, ";") || error("Unterminated attribute"); + return ret; + }; + + var return_type = function () { + var typ = type(); + if (!typ) { + if (consume(ID, "void")) { + return "void"; + } + else error("No return type"); + } + return typ; + }; + + var operation = function (store) { + all_ws(store, "pea"); + var ret = { + type: "operation" + , getter: false + , setter: false + , creator: false + , deleter: false + , legacycaller: false + , "static": false + , stringifier: false + }; + while (true) { + all_ws(); + if (consume(ID, "getter")) ret.getter = true; + else if (consume(ID, "setter")) ret.setter = true; + else if (consume(ID, "creator")) ret.creator = true; + else if (consume(ID, "deleter")) ret.deleter = true; + else if (consume(ID, "legacycaller")) ret.legacycaller = true; + else break; + } + if (ret.getter || ret.setter || ret.creator || ret.deleter || ret.legacycaller) { + all_ws(); + ret.idlType = return_type(); + operation_rest(ret, store); + return ret; + } + if (consume(ID, "static")) { + ret["static"] = true; + ret.idlType = return_type(); + operation_rest(ret, store); + return ret; + } + else if (consume(ID, "stringifier")) { + ret.stringifier = true;- + all_ws(); + if (consume(OTHER, ";")) return ret; + ret.idlType = return_type(); + operation_rest(ret, store); + return ret; + } + ret.idlType = return_type(); + all_ws(); + if (consume(ID, "iterator")) { + all_ws(); + ret.type = "iterator"; + if (consume(ID, "object")) { + ret.iteratorObject = "object"; + } + else if (consume(OTHER, "=")) { + all_ws(); + var name = consume(ID) || error("No right hand side in iterator"); + ret.iteratorObject = name.value; + } + all_ws(); + consume(OTHER, ";") || error("Unterminated iterator"); + return ret; + } + else { + operation_rest(ret, store); + return ret; + } + }; + + var identifiers = function (arr) { + while (true) { + all_ws(); + if (consume(OTHER, ",")) { + all_ws(); + var name = consume(ID) || error("Trailing comma in identifiers list"); + arr.push(name.value); + } + else break; + } + }; + + var serialiser = function (store) { + all_ws(store, "pea"); + if (!consume(ID, "serializer")) return; + var ret = { type: "serializer" }; + all_ws(); + if (consume(OTHER, "=")) { + all_ws(); + if (consume(OTHER, "{")) { + ret.patternMap = true; + all_ws(); + var id = consume(ID); + if (id && id.value === "getter") { + ret.names = ["getter"]; + } + else if (id && id.value === "inherit") { + ret.names = ["inherit"]; + identifiers(ret.names); + } + else if (id) { + ret.names = [id.value]; + identifiers(ret.names); + } + else { + ret.names = []; + } + all_ws(); + consume(OTHER, "}") || error("Unterminated serializer pattern map"); + } + else if (consume(OTHER, "[")) { + ret.patternList = true; + all_ws(); + var id = consume(ID); + if (id && id.value === "getter") { + ret.names = ["getter"]; + } + else if (id) { + ret.names = [id.value]; + identifiers(ret.names); + } + else { + ret.names = []; + } + all_ws(); + consume(OTHER, "]") || error("Unterminated serializer pattern list"); + } + else { + var name = consume(ID) || error("Invalid serializer"); + ret.name = name.value; + } + all_ws(); + consume(OTHER, ";") || error("Unterminated serializer"); + return ret; + } + else if (consume(OTHER, ";")) { + // noop, just parsing + } + else { + ret.idlType = return_type(); + all_ws(); + ret.operation = operation_rest(null, store); + } + return ret; + }; + + var iterable_type = function() { + if (consume(ID, "iterable")) return "iterable"; + else if (consume(ID, "legacyiterable")) return "legacyiterable"; + else if (consume(ID, "maplike")) return "maplike"; + else if (consume(ID, "setlike")) return "setlike"; + else return; + } + + var readonly_iterable_type = function() { + if (consume(ID, "maplike")) return "maplike"; + else if (consume(ID, "setlike")) return "setlike"; + else return; + } + + var iterable = function (store) { + all_ws(store, "pea"); + var grabbed = [], + ret = {type: null, idlType: null, readonly: false}; + if (consume(ID, "readonly")) { + ret.readonly = true; + grabbed.push(last_token); + var w = all_ws(); + if (w) grabbed.push(w); + } + var consumeItType = ret.readonly ? readonly_iterable_type : iterable_type; + + var ittype = consumeItType(); + if (!ittype) { + tokens = grabbed.concat(tokens); + return; + } + + var secondTypeRequired = ittype === "maplike"; + var secondTypeAllowed = secondTypeRequired || ittype === "iterable"; + ret.type = ittype; + if (ret.type !== 'maplike' && ret.type !== 'setlike') + delete ret.readonly; + all_ws(); + if (consume(OTHER, "<")) { + ret.idlType = type() || error("Error parsing " + ittype + " declaration"); + all_ws(); + if (secondTypeAllowed) { + var type2 = null; + if (consume(OTHER, ",")) { + all_ws(); + type2 = type(); + all_ws(); + } + if (type2) + ret.idlType = [ret.idlType, type2]; + else if (secondTypeRequired) + error("Missing second type argument in " + ittype + " declaration"); + } + if (!consume(OTHER, ">")) error("Unterminated " + ittype + " declaration"); + all_ws(); + if (!consume(OTHER, ";")) error("Missing semicolon after " + ittype + " declaration"); + } + else + error("Error parsing " + ittype + " declaration"); + + return ret; + } + + var interface_ = function (isPartial, store) { + all_ws(isPartial ? null : store, "pea"); + if (!consume(ID, "interface")) return; + all_ws(); + var name = consume(ID) || error("No name for interface"); + var mems = [] + , ret = { + type: "interface" + , name: name.value + , partial: false + , members: mems + }; + if (!isPartial) ret.inheritance = inheritance() || null; + all_ws(); + consume(OTHER, "{") || error("Bodyless interface"); + while (true) { + all_ws(store ? mems : null); + if (consume(OTHER, "}")) { + all_ws(); + consume(OTHER, ";") || error("Missing semicolon after interface"); + return ret; + } + var ea = extended_attrs(store ? mems : null); + all_ws(); + var cnt = const_(store ? mems : null); + if (cnt) { + cnt.extAttrs = ea; + ret.members.push(cnt); + continue; + } + var mem = (opt.allowNestedTypedefs && typedef(store ? mems : null)) || + iterable(store ? mems : null) || + serialiser(store ? mems : null) || + attribute(store ? mems : null) || + operation(store ? mems : null) || + error("Unknown member"); + mem.extAttrs = ea; + ret.members.push(mem); + } + }; + + var partial = function (store) { + all_ws(store, "pea"); + if (!consume(ID, "partial")) return; + var thing = dictionary(true, store) || + interface_(true, store) || + error("Partial doesn't apply to anything"); + thing.partial = true; + return thing; + }; + + var dictionary = function (isPartial, store) { + all_ws(isPartial ? null : store, "pea"); + if (!consume(ID, "dictionary")) return; + all_ws(); + var name = consume(ID) || error("No name for dictionary"); + var mems = [] + , ret = { + type: "dictionary" + , name: name.value + , partial: false + , members: mems + }; + if (!isPartial) ret.inheritance = inheritance() || null; + all_ws(); + consume(OTHER, "{") || error("Bodyless dictionary"); + while (true) { + all_ws(store ? mems : null); + if (consume(OTHER, "}")) { + all_ws(); + consume(OTHER, ";") || error("Missing semicolon after dictionary"); + return ret; + } + var ea = extended_attrs(store ? mems : null); + all_ws(store ? mems : null, "pea"); + var required = consume(ID, "required"); + var typ = type() || error("No type for dictionary member"); + all_ws(); + var name = consume(ID) || error("No name for dictionary member"); + var dflt = default_(); + if (required && dflt) error("Required member must not have a default"); + ret.members.push({ + type: "field" + , name: name.value + , required: !!required + , idlType: typ + , extAttrs: ea + , "default": dflt + }); + all_ws(); + consume(OTHER, ";") || error("Unterminated dictionary member"); + } + }; + + var exception = function (store) { + all_ws(store, "pea"); + if (!consume(ID, "exception")) return; + all_ws(); + var name = consume(ID) || error("No name for exception"); + var mems = [] + , ret = { + type: "exception" + , name: name.value + , members: mems + }; + ret.inheritance = inheritance() || null; + all_ws(); + consume(OTHER, "{") || error("Bodyless exception"); + while (true) { + all_ws(store ? mems : null); + if (consume(OTHER, "}")) { + all_ws(); + consume(OTHER, ";") || error("Missing semicolon after exception"); + return ret; + } + var ea = extended_attrs(store ? mems : null); + all_ws(store ? mems : null, "pea"); + var cnt = const_(); + if (cnt) { + cnt.extAttrs = ea; + ret.members.push(cnt); + } + else { + var typ = type(); + all_ws(); + var name = consume(ID); + all_ws(); + if (!typ || !name || !consume(OTHER, ";")) error("Unknown member in exception body"); + ret.members.push({ + type: "field" + , name: name.value + , idlType: typ + , extAttrs: ea + }); + } + } + }; + + var enum_ = function (store) { + all_ws(store, "pea"); + if (!consume(ID, "enum")) return; + all_ws(); + var name = consume(ID) || error("No name for enum"); + var vals = [] + , ret = { + type: "enum" + , name: name.value + , values: vals + }; + all_ws(); + consume(OTHER, "{") || error("No curly for enum"); + var saw_comma = false; + while (true) { + all_ws(store ? vals : null); + if (consume(OTHER, "}")) { + all_ws(); + consume(OTHER, ";") || error("No semicolon after enum"); + return ret; + } + var val = consume(STR) || error("Unexpected value in enum"); + ret.values.push(val.value.replace(/"/g, "")); + all_ws(store ? vals : null); + if (consume(OTHER, ",")) { + if (store) vals.push({ type: "," }); + all_ws(store ? vals : null); + saw_comma = true; + } + else { + saw_comma = false; + } + } + }; + + var typedef = function (store) { + all_ws(store, "pea"); + if (!consume(ID, "typedef")) return; + var ret = { + type: "typedef" + }; + all_ws(); + ret.typeExtAttrs = extended_attrs(); + all_ws(store, "tpea"); + ret.idlType = type() || error("No type in typedef"); + all_ws(); + var name = consume(ID) || error("No name in typedef"); + ret.name = name.value; + all_ws(); + consume(OTHER, ";") || error("Unterminated typedef"); + return ret; + }; + + var implements_ = function (store) { + all_ws(store, "pea"); + var target = consume(ID); + if (!target) return; + var w = all_ws(); + if (consume(ID, "implements")) { + var ret = { + type: "implements" + , target: target.value + }; + all_ws(); + var imp = consume(ID) || error("Incomplete implements statement"); + ret["implements"] = imp.value; + all_ws(); + consume(OTHER, ";") || error("No terminating ; for implements statement"); + return ret; + } + else { + // rollback + tokens.unshift(w); + tokens.unshift(target); + } + }; + + var definition = function (store) { + return callback(store) || + interface_(false, store) || + partial(store) || + dictionary(false, store) || + exception(store) || + enum_(store) || + typedef(store) || + implements_(store) + ; + }; + + var definitions = function (store) { + if (!tokens.length) return []; + var defs = []; + while (true) { + var ea = extended_attrs(store ? defs : null) + , def = definition(store ? defs : null); + if (!def) { + if (ea.length) error("Stray extended attributes"); + break; + } + def.extAttrs = ea; + defs.push(def); + } + return defs; + }; + var res = definitions(opt.ws); + if (tokens.length) error("Unrecognised tokens"); + return res; + }; + + var inNode = typeof module !== "undefined" && module.exports + , obj = { + parse: function (str, opt) { + if (!opt) opt = {}; + var tokens = tokenise(str); + return parse(tokens, opt); + } + }; + + if (inNode) module.exports = obj; + else self.WebIDL2 = obj; +}()); diff --git a/testing/web-platform/tests/resources/webidl2/lib/writer.js b/testing/web-platform/tests/resources/webidl2/lib/writer.js new file mode 100644 index 000000000..ba8363738 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/lib/writer.js @@ -0,0 +1,236 @@ + +(function () { + + var write = function (ast, opt) { + var curPea = "" + , curTPea = "" + , opt = opt || {} + , noop = function (str) { return str; } + , optNames = "type".split(" ") + , context = [] + ; + for (var i = 0, n = optNames.length; i < n; i++) { + var o = optNames[i]; + if (!opt[o]) opt[o] = noop; + } + + var literal = function (it) { + return it.value; + }; + var wsPea = function (it) { + curPea += it.value; + return ""; + }; + var wsTPea = function (it) { + curTPea += it.value; + return ""; + }; + var lineComment = function (it) { + return "//" + it.value + "\n"; + }; + var multilineComment = function (it) { + return "/*" + it.value + "*/"; + }; + var type = function (it) { + if (typeof it === "string") return opt.type(it); // XXX should maintain some context + if (it.union) return "(" + it.idlType.map(type).join(" or ") + ")"; + var ret = ""; + if (it.sequence) ret += "sequence<"; + ret += type(it.idlType); + if (it.array) { + for (var i = 0, n = it.nullableArray.length; i < n; i++) { + var val = it.nullableArray[i]; + if (val) ret += "?"; + ret += "[]"; + } + } + if (it.sequence) ret += ">"; + if (it.nullable) ret += "?"; + + return ret; + }; + var const_value = function (it) { + var tp = it. type; + if (tp === "boolean") return it.value ? "true" : "false"; + else if (tp === "null") return "null"; + else if (tp === "Infinity") return (it.negative ? "-" : "") + "Infinity"; + else if (tp === "NaN") return "NaN"; + else if (tp === "number") return it.value; + else return '"' + it.value + '"'; + }; + var argument = function (arg, pea) { + var ret = extended_attributes(arg.extAttrs, pea); + if (arg.optional) ret += "optional "; + ret += type(arg.idlType); + if (arg.variadic) ret += "..."; + ret += " " + arg.name; + if (arg["default"]) ret += " = " + const_value(arg["default"]); + return ret; + }; + var args = function (its) { + var res = "" + , pea = "" + ; + for (var i = 0, n = its.length; i < n; i++) { + var arg = its[i]; + if (arg.type === "ws") res += arg.value; + else if (arg.type === "ws-pea") pea += arg.value; + else { + res += argument(arg, pea); + if (i < n - 1) res += ","; + pea = ""; + } + } + return res; + }; + var make_ext_at = function (it) { + if (it["arguments"] === null) return it.name; + context.unshift(it); + var ret = it.name + "(" + (it["arguments"].length ? args(it["arguments"]) : "") + ")"; + context.shift(); // XXX need to add more contexts, but not more than needed for ReSpec + return ret; + }; + var extended_attributes = function (eats, pea) { + if (!eats || !eats.length) return ""; + return "[" + eats.map(make_ext_at).join(", ") + "]" + pea; + }; + + var modifiers = "getter setter creator deleter legacycaller stringifier static".split(" "); + var operation = function (it) { + var ret = extended_attributes(it.extAttrs, curPea); + curPea = ""; + if (it.stringifier && !it.idlType) return "stringifier;"; + for (var i = 0, n = modifiers.length; i < n; i++) { + var mod = modifiers[i]; + if (it[mod]) ret += mod + " "; + } + ret += type(it.idlType) + " "; + if (it.name) ret += it.name; + ret += "(" + args(it["arguments"]) + ");"; + return ret; + }; + + var attribute = function (it) { + var ret = extended_attributes(it.extAttrs, curPea); + curPea = ""; + if (it["static"]) ret += "static "; + if (it.stringifier) ret += "stringifier "; + if (it.readonly) ret += "readonly "; + if (it.inherit) ret += "inherit "; + ret += "attribute " + type(it.idlType) + " " + it.name + ";"; + return ret; + }; + + var interface_ = function (it) { + var ret = extended_attributes(it.extAttrs, curPea); + curPea = ""; + if (it.partial) ret += "partial "; + ret += "interface " + it.name + " "; + if (it.inheritance) ret += ": " + it.inheritance + " "; + ret += "{" + iterate(it.members) + "};"; + return ret; + }; + + var dictionary = function (it) { + var ret = extended_attributes(it.extAttrs, curPea); + curPea = ""; + if (it.partial) ret += "partial "; + ret += "dictionary " + it.name + " "; + ret += "{" + iterate(it.members) + "};"; + return ret; + }; + var field = function (it) { + var ret = extended_attributes(it.extAttrs, curPea); + curPea = ""; + ret += type(it.idlType) + " " + it.name; + if (it["default"]) ret += " = " + const_value(it["default"]); + ret += ";"; + return ret; + }; + var exception = function (it) { + var ret = extended_attributes(it.extAttrs, curPea); + curPea = ""; + ret += "exception " + it.name + " "; + if (it.inheritance) ret += ": " + it.inheritance + " "; + ret += "{" + iterate(it.members) + "};"; + return ret; + }; + var const_ = function (it) { + var ret = extended_attributes(it.extAttrs, curPea); + curPea = ""; + return ret + "const " + type(it.idlType) + " " + it.name + " = " + const_value(it.value) + ";"; + }; + var typedef = function (it) { + var ret = extended_attributes(it.extAttrs, curPea); + curPea = ""; + ret += "typedef " + extended_attributes(it.typeExtAttrs, curTPea); + curTPea = ""; + return ret + type(it.idlType) + " " + it.name + ";"; + }; + var implements_ = function (it) { + var ret = extended_attributes(it.extAttrs, curPea); + curPea = ""; + return ret + it.target + " implements " + it["implements"] + ";"; + }; + var callback = function (it) { + var ret = extended_attributes(it.extAttrs, curPea); + curPea = ""; + return ret + "callback " + it.name + " = " + type(it.idlType) + + "(" + args(it["arguments"]) + ");"; + }; + var enum_ = function (it) { + var ret = extended_attributes(it.extAttrs, curPea); + curPea = ""; + ret += "enum " + it.name + " {"; + for (var i = 0, n = it.values.length; i < n; i++) { + var v = it.values[i]; + if (typeof v === "string") ret += '"' + v + '"'; + else if (v.type === "ws") ret += v.value; + else if (v.type === ",") ret += ","; + } + return ret + "};"; + }; + + var table = { + ws: literal + , "ws-pea": wsPea + , "ws-tpea": wsTPea + , "line-comment": lineComment + , "multiline-comment": multilineComment + , "interface": interface_ + , operation: operation + , attribute: attribute + , dictionary: dictionary + , field: field + , exception: exception + , "const": const_ + , typedef: typedef + , "implements": implements_ + , callback: callback + , "enum": enum_ + }; + var dispatch = function (it) { + return table[it.type](it); + }; + var iterate = function (things) { + if (!things) return; + var ret = ""; + for (var i = 0, n = things.length; i < n; i++) ret += dispatch(things[i]); + return ret; + }; + return iterate(ast); + }; + + + var inNode = typeof module !== "undefined" && module.exports + , obj = { + write: function (ast, opt) { + if (!opt) opt = {}; + return write(ast, opt); + } + }; + + if (inNode) module.exports = obj; + else window.WebIDL2Writer = obj; + +}()); diff --git a/testing/web-platform/tests/resources/webidl2/package.json b/testing/web-platform/tests/resources/webidl2/package.json new file mode 100644 index 000000000..c5ae7da2d --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/package.json @@ -0,0 +1,21 @@ +{ + "name": "webidl2", + "description": "A WebIDL Parser", + "version": "2.0.11", + "author": "Robin Berjon ", + "license": "MIT", + "dependencies": {}, + "devDependencies": { + "mocha": "2.2.5", + "expect.js": "0.3.1", + "underscore": "1.8.3", + "jsondiffpatch": "0.1.31", + "benchmark": "*", + "microtime": "1.4.2" + }, + "scripts": { + "test": "mocha" + }, + "repository": "git://github.com/darobin/webidl2.js", + "main": "index" +} diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid.js b/testing/web-platform/tests/resources/webidl2/test/invalid.js new file mode 100644 index 000000000..c98218037 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid.js @@ -0,0 +1,42 @@ + +// NOTES: +// - the errors actually still need to be reviewed to check that they +// are fully correct interpretations of the IDLs + +var wp = process.env.JSCOV ? require("../lib-cov/webidl2") : require("../lib/webidl2") +, expect = require("expect.js") +, pth = require("path") +, fs = require("fs") +; +describe("Parses all of the invalid IDLs to check that they blow up correctly", function () { + var dir = pth.join(__dirname, "invalid/idl") + , skip = {} + , idls = fs.readdirSync(dir) + .filter(function (it) { return (/\.w?idl$/).test(it) && !skip[it]; }) + .map(function (it) { return pth.join(dir, it); }) + , errors = idls.map(function (it) { return pth.join(__dirname, "invalid", "json", pth.basename(it).replace(/\.w?idl/, ".json")); }) + ; + + for (var i = 0, n = idls.length; i < n; i++) { + var idl = idls[i], error = JSON.parse(fs.readFileSync(errors[i], "utf8")); + var func = (function (idl, err) { + return function () { + var error; + try { + var ast = wp.parse(fs.readFileSync(idl, "utf8")); + console.log(JSON.stringify(ast, null, 4)); + } + catch (e) { + error = e; + } + finally { + expect(error).to.be.ok(); + expect(error.message).to.equal(err.message); + expect(error.line).to.equal(err.line); + } + + }; + }(idl, error)); + it("should produce the right error for " + idl, func); + } +}); diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/idl/dict-required-default.widl b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/dict-required-default.widl new file mode 100644 index 000000000..412448d22 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/dict-required-default.widl @@ -0,0 +1,5 @@ +// https://heycam.github.io/webidl/#required-dictionary-member +// "A required dictionary member must not have a default value." +dictionary Dict { + required long member = 0; +}; diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/idl/enum.widl b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/enum.widl new file mode 100644 index 000000000..c355c3251 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/enum.widl @@ -0,0 +1 @@ +enum foo { 1, 2, 3}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/idl/maplike-1type.widl b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/maplike-1type.widl new file mode 100644 index 000000000..33c274b8b --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/maplike-1type.widl @@ -0,0 +1,3 @@ +interface MapLikeOneType { + maplike; +} \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/idl/module.widl b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/module.widl new file mode 100644 index 000000000..a4c79fdf1 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/module.widl @@ -0,0 +1,25 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +module gfx { + + module geom { + interface Shape { /* ... */ }; + interface Rectangle : Shape { /* ... */ }; + interface Path : Shape { /* ... */ }; + }; + + interface GraphicsContext { + void fillShape(geom::Shape s); + void strokeShape(geom::Shape s); + }; +}; + +module gui { + + interface Widget { /* ... */ }; + + interface Window : Widget { + gfx::GraphicsContext getGraphicsContext(); + }; + + interface Button : Widget { /* ... */ }; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/idl/nonnullableany.widl b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/nonnullableany.widl new file mode 100644 index 000000000..389576555 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/nonnullableany.widl @@ -0,0 +1,3 @@ +interface NonNullable { + attribute any? foo; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/idl/nonnullableobjects.widl b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/nonnullableobjects.widl new file mode 100644 index 000000000..1deac5aee --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/nonnullableobjects.widl @@ -0,0 +1,5 @@ +interface Foo {}; + +interface NonNullable { + attribute Foo?? foo; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/idl/raises.widl b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/raises.widl new file mode 100644 index 000000000..ff65522f2 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/raises.widl @@ -0,0 +1,18 @@ +// getraises and setraises are not longer valid Web IDL +interface Person { + + // An attribute that can raise an exception if it is set to an invalid value. + attribute DOMString name setraises (InvalidName); + + // An attribute whose value cannot be assigned to, and which can raise an + // exception some circumstances. + readonly attribute DOMString petName getraises (NoSuchPet); +}; + +exception SomeException { +}; + +interface ExceptionThrower { + // This attribute always throws a SomeException and never returns a value. + attribute long valueOf getraises(SomeException); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/idl/readonly-iterable.widl b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/readonly-iterable.widl new file mode 100644 index 000000000..fc4ae2be9 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/readonly-iterable.widl @@ -0,0 +1,3 @@ +interface ReadonlyIterable { + readonly iterable; +} \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/idl/scopedname.widl b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/scopedname.widl new file mode 100644 index 000000000..cfcb1ccc9 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/scopedname.widl @@ -0,0 +1,2 @@ +// scoped names are no longer valid in WebIDL + typedef gfx::geom::geom2d::Point Point; diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/idl/sequenceAsAttribute.widl b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/sequenceAsAttribute.widl new file mode 100644 index 000000000..c23da82ac --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/sequenceAsAttribute.widl @@ -0,0 +1,3 @@ +interface sequenceAsAttribute { + attribute sequence invalid; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/idl/setlike-2types.widl b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/setlike-2types.widl new file mode 100644 index 000000000..1ecae22c0 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/setlike-2types.widl @@ -0,0 +1,3 @@ +interface SetLikeTwoTypes { + setlike; +} \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/idl/special-omittable.widl b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/special-omittable.widl new file mode 100644 index 000000000..bdfbfa709 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/special-omittable.widl @@ -0,0 +1,8 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +// omittable is no longer a recognized keywoard as of 20110905 +interface Dictionary { + readonly attribute unsigned long propertyCount; + + omittable getter float getProperty(DOMString propertyName); + omittable setter void setProperty(DOMString propertyName, float propertyValue); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/idl/stringconstants.idl b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/stringconstants.idl new file mode 100644 index 000000000..44fd3ff13 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/stringconstants.idl @@ -0,0 +1,3 @@ +interface Util { + const DOMString hello = "world"; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/idl/typedef-nested.widl b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/typedef-nested.widl new file mode 100644 index 000000000..106f30b8f --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/idl/typedef-nested.widl @@ -0,0 +1,22 @@ + + interface Point { + attribute float x; + attribute float y; + }; + + + interface Rect { + attribute Point topleft; + attribute Point bottomright; + }; + + interface Widget { + typedef sequence PointSequence; + + readonly attribute Rect bounds; + + boolean pointWithinBounds(Point p); + boolean allPointsWithinBounds(PointSequence ps); + }; + + typedef [Clamp] octet value; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/json/dict-required-default.json b/testing/web-platform/tests/resources/webidl2/test/invalid/json/dict-required-default.json new file mode 100644 index 000000000..c5afeca85 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/json/dict-required-default.json @@ -0,0 +1,4 @@ +{ + "message": "Required member must not have a default" +, "line": 4 +} diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/json/enum.json b/testing/web-platform/tests/resources/webidl2/test/invalid/json/enum.json new file mode 100644 index 000000000..166115801 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/json/enum.json @@ -0,0 +1,4 @@ +{ + "message": "Unexpected value in enum" +, "line": 1 +} diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/json/maplike-1type.json b/testing/web-platform/tests/resources/webidl2/test/invalid/json/maplike-1type.json new file mode 100644 index 000000000..859a820a4 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/json/maplike-1type.json @@ -0,0 +1,4 @@ +{ + "message": "Missing second type argument in maplike declaration", + "line": 2 +} \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/json/module.json b/testing/web-platform/tests/resources/webidl2/test/invalid/json/module.json new file mode 100644 index 000000000..3b0984d97 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/json/module.json @@ -0,0 +1,4 @@ +{ + "message": "Unrecognised tokens" +, "line": 2 +} diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/json/nonnullableany.json b/testing/web-platform/tests/resources/webidl2/test/invalid/json/nonnullableany.json new file mode 100644 index 000000000..cf5229e8e --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/json/nonnullableany.json @@ -0,0 +1,4 @@ +{ + "message": "Type any cannot be made nullable" +, "line": 2 +} diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/json/nonnullableobjects.json b/testing/web-platform/tests/resources/webidl2/test/invalid/json/nonnullableobjects.json new file mode 100644 index 000000000..23cbb3e5d --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/json/nonnullableobjects.json @@ -0,0 +1,4 @@ +{ + "message": "Can't nullable more than once" +, "line": 4 +} diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/json/raises.json b/testing/web-platform/tests/resources/webidl2/test/invalid/json/raises.json new file mode 100644 index 000000000..8b67afe4f --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/json/raises.json @@ -0,0 +1,4 @@ +{ + "message": "Unterminated attribute" +, "line": 5 +} diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/json/readonly-iterable.json b/testing/web-platform/tests/resources/webidl2/test/invalid/json/readonly-iterable.json new file mode 100644 index 000000000..c6f52a246 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/json/readonly-iterable.json @@ -0,0 +1,4 @@ +{ + "message": "Invalid operation", + "line": 2 +} \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/json/scopedname.json b/testing/web-platform/tests/resources/webidl2/test/invalid/json/scopedname.json new file mode 100644 index 000000000..8e2cd8032 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/json/scopedname.json @@ -0,0 +1,4 @@ +{ + "message": "No name in typedef" +, "line": 2 +} diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/json/sequenceAsAttribute.json b/testing/web-platform/tests/resources/webidl2/test/invalid/json/sequenceAsAttribute.json new file mode 100644 index 000000000..b714f5d92 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/json/sequenceAsAttribute.json @@ -0,0 +1,4 @@ +{ + "message": "Attributes cannot accept sequence types" +, "line": 2 +} diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/json/setlike-2types.json b/testing/web-platform/tests/resources/webidl2/test/invalid/json/setlike-2types.json new file mode 100644 index 000000000..c9e49b675 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/json/setlike-2types.json @@ -0,0 +1,4 @@ +{ + "message": "Unterminated setlike declaration", + "line": 2 +} \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/json/special-omittable.json b/testing/web-platform/tests/resources/webidl2/test/invalid/json/special-omittable.json new file mode 100644 index 000000000..7acb08834 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/json/special-omittable.json @@ -0,0 +1,4 @@ +{ + "message": "Invalid operation" +, "line": 6 +} diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/json/stringconstants.json b/testing/web-platform/tests/resources/webidl2/test/invalid/json/stringconstants.json new file mode 100644 index 000000000..d5bf1a883 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/json/stringconstants.json @@ -0,0 +1,4 @@ +{ + "message": "No value for const" +, "line": 2 +} diff --git a/testing/web-platform/tests/resources/webidl2/test/invalid/json/typedef-nested.json b/testing/web-platform/tests/resources/webidl2/test/invalid/json/typedef-nested.json new file mode 100644 index 000000000..d7fb9182f --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/invalid/json/typedef-nested.json @@ -0,0 +1,4 @@ +{ + "message": "Invalid operation" +, "line": 14 +} \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/mocha.opts b/testing/web-platform/tests/resources/webidl2/test/mocha.opts new file mode 100644 index 000000000..5ada47be1 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/mocha.opts @@ -0,0 +1 @@ +--reporter spec diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax.js b/testing/web-platform/tests/resources/webidl2/test/syntax.js new file mode 100644 index 000000000..712542a6b --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax.js @@ -0,0 +1,41 @@ + +var wp = process.env.JSCOV ? require("../lib-cov/webidl2") : require("../lib/webidl2") +, expect = require("expect.js") +, pth = require("path") +, fs = require("fs") +, jdp = require("jsondiffpatch") +, debug = true +; +describe("Parses all of the IDLs to produce the correct ASTs", function () { + var dir = pth.join(__dirname, "syntax/idl") + , skip = {} // use if we have a broken test + , idls = fs.readdirSync(dir) + .filter(function (it) { return (/\.widl$/).test(it) && !skip[it]; }) + .map(function (it) { return pth.join(dir, it); }) + , jsons = idls.map(function (it) { return pth.join(__dirname, "syntax/json", pth.basename(it).replace(".widl", ".json")); }) + ; + + for (var i = 0, n = idls.length; i < n; i++) { + var idl = idls[i], json = jsons[i]; + + var func = (function (idl, json) { + return function () { + try { + var optFile = pth.join(__dirname, "syntax/opt", pth.basename(json)); + var opt = undefined; + if (fs.existsSync(optFile)) + opt = JSON.parse(fs.readFileSync(optFile, "utf8")); + var diff = jdp.diff(JSON.parse(fs.readFileSync(json, "utf8")), + wp.parse(fs.readFileSync(idl, "utf8"), opt)); + if (diff && debug) console.log(JSON.stringify(diff, null, 4)); + expect(diff).to.be(undefined); + } + catch (e) { + console.log(e.toString()); + throw e; + } + }; + }(idl, json)); + it("should produce the same AST for " + idl, func); + } +}); diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/allowany.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/allowany.widl new file mode 100644 index 000000000..2343bb963 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/allowany.widl @@ -0,0 +1,6 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface B { + void g(); + void g(B b); + void g([AllowAny] DOMString s); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/array.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/array.widl new file mode 100644 index 000000000..22e21fb65 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/array.widl @@ -0,0 +1,5 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +[Constructor] +interface LotteryResults { + readonly attribute unsigned short[][] numbers; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/attributes.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/attributes.widl new file mode 100644 index 000000000..7e1d691cb --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/attributes.widl @@ -0,0 +1,14 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +exception InvalidName { + DOMString reason; +}; + +exception NoSuchPet { }; + +interface Person { + + // A simple attribute that can be set to any value the range an unsigned + // short can take. + attribute unsigned short age; + +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/callback.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/callback.widl new file mode 100644 index 000000000..adaf75e04 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/callback.widl @@ -0,0 +1,7 @@ +callback AsyncOperationCallback = void (DOMString status); + +callback interface EventHandler { + void eventOccurred(DOMString details); +}; + +callback SortCallback = boolean (any a, any b); diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/caller.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/caller.widl new file mode 100644 index 000000000..92acb1c01 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/caller.widl @@ -0,0 +1,5 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface NumberQuadrupler { + // This operation simply returns four times the given number x. + legacycaller float compute(float x); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/constants.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/constants.widl new file mode 100644 index 000000000..5e28ae9c1 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/constants.widl @@ -0,0 +1,18 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface Util { + const boolean DEBUG = false; + const short negative = -1; + const octet LF = 10; + const unsigned long BIT_MASK = 0x0000fc00; + const float AVOGADRO = 6.022e23; + const unrestricted float sobig = Infinity; + const unrestricted double minusonedividedbyzero = -Infinity; + const short notanumber = NaN; +}; + +exception Error { + const short ERR_UNKNOWN = 0; + const short ERR_OUT_OF_MEMORY = 1; + + short errorCode; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/constructor.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/constructor.widl new file mode 100644 index 000000000..f93ec08a6 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/constructor.widl @@ -0,0 +1,9 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +[Constructor, + Constructor(float radius)] +interface Circle { + attribute float r; + attribute float cx; + attribute float cy; + readonly attribute float circumference; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/dictionary-inherits.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/dictionary-inherits.widl new file mode 100644 index 000000000..48f8a0fdc --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/dictionary-inherits.widl @@ -0,0 +1,9 @@ +dictionary PaintOptions { + DOMString? fillPattern = "black"; + DOMString? strokePattern = null; + Point position; +}; + +dictionary WetPaintOptions : PaintOptions { + float hydrometry; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/dictionary.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/dictionary.widl new file mode 100644 index 000000000..c64a14c85 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/dictionary.widl @@ -0,0 +1,15 @@ +// Extracted from Web IDL editors draft May 31 2011 +dictionary PaintOptions { + DOMString? fillPattern = "black"; + DOMString? strokePattern = null; + Point position; + // https://heycam.github.io/webidl/#dfn-optional-argument-default-value allows sequences to default to "[]". + sequence seq = []; + // https://heycam.github.io/webidl/#required-dictionary-member + required long reqSeq; +}; + +partial dictionary A { + long h; + long d; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/documentation-dos.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/documentation-dos.widl new file mode 100644 index 000000000..fb801101f --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/documentation-dos.widl @@ -0,0 +1,33 @@ +/** +* \brief Testing documentation features +* +* This is a +* single paragraph +* +*

This is valid.

+*

This is valid.

+*

This is valid.

+*

This is valid.

+*
    +*
  • This
  • +*
  • is
  • +*
  • valid
  • +*
+*
+*
This
+*
valid
+*
+* +* +* +* +* +* +* +* +*
thisis
valid
+*

This is
valid.

+*

This is
valid.

+*

This is
valid.

+*/ +interface Documentation {}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/documentation.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/documentation.widl new file mode 100644 index 000000000..003e9226f --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/documentation.widl @@ -0,0 +1,34 @@ +/** +* \brief Testing documentation features +* +* This is a +* single paragraph +* +*

This is valid.

+*

This is valid.

+*

This is valid.

+*

This is valid.

+*
    +*
  • This
  • +*
  • is
  • +*
  • valid
  • +*
+*
+*
This
+*
valid
+*
+* +* +* +* +* +* +* +* +*
thisis
valid
+*

This is
valid.

+*

This is
valid.

+*

This is
valid.

+*

Valid

+*/ +interface Documentation {}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/enum.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/enum.widl new file mode 100644 index 000000000..37c4ffdde --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/enum.widl @@ -0,0 +1,10 @@ +enum MealType { "rice", "noodles", "other" }; + +interface Meal { + attribute MealType type; + attribute float size; // in grams + + void initialize(MealType type, float size); +}; + +enum AltMealType { "rice", "noodles", "other", }; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/equivalent-decl.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/equivalent-decl.widl new file mode 100644 index 000000000..6b3e0eda2 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/equivalent-decl.widl @@ -0,0 +1,18 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface Dictionary { + readonly attribute unsigned long propertyCount; + + getter float getProperty(DOMString propertyName); + setter void setProperty(DOMString propertyName, float propertyValue); +}; + + +interface Dictionary { + readonly attribute unsigned long propertyCount; + + float getProperty(DOMString propertyName); + void setProperty(DOMString propertyName, float propertyValue); + + getter float (DOMString propertyName); + setter void (DOMString propertyName, float propertyValue); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/exception-inheritance.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/exception-inheritance.widl new file mode 100644 index 000000000..258fdeba6 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/exception-inheritance.widl @@ -0,0 +1,7 @@ +// from http://lists.w3.org/Archives/Public/public-script-coord/2010OctDec/0112.html + exception DOMException { + unsigned short code; + }; + + exception HierarchyRequestError : DOMException { }; + exception NoModificationAllowedError : DOMException { }; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/exception.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/exception.widl new file mode 100644 index 000000000..f4b6ae29e --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/exception.widl @@ -0,0 +1,8 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface Dahut { + attribute DOMString type; +}; + +exception SomeException { +}; + diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/extended-attributes.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/extended-attributes.widl new file mode 100644 index 000000000..f769c2559 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/extended-attributes.widl @@ -0,0 +1,6 @@ +// Extracted from http://www.w3.org/TR/2015/WD-service-workers-20150205/ + +[Global=(Worker,ServiceWorker), Exposed=ServiceWorker] +interface ServiceWorkerGlobalScope : WorkerGlobalScope { + +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/generic.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/generic.widl new file mode 100644 index 000000000..02b64572a --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/generic.widl @@ -0,0 +1,17 @@ +interface Foo { + Promise>> bar(); + readonly attribute Promise[] baz; +}; + +// Extracted from https://slightlyoff.github.io/ServiceWorker/spec/service_worker/ on 2014-05-08 + +interface ServiceWorkerClients { + Promise getServiced(); + Promise reloadAll(); +}; + +// Extracted from https://slightlyoff.github.io/ServiceWorker/spec/service_worker/ on 2014-05-13 + +interface FetchEvent : Event { + ResponsePromise default(); +}; diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/getter-setter.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/getter-setter.widl new file mode 100644 index 000000000..bdf87e1c7 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/getter-setter.widl @@ -0,0 +1,7 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface Dictionary { + readonly attribute unsigned long propertyCount; + + getter float (DOMString propertyName); + setter void (DOMString propertyName, float propertyValue); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/identifier-qualified-names.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/identifier-qualified-names.widl new file mode 100644 index 000000000..33893d4c6 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/identifier-qualified-names.widl @@ -0,0 +1,44 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 + // Typedef identifier: "number" + // Qualified name: "::framework::number" + typedef float number; + + // Exception identifier: "FrameworkException" + // Qualified name: "::framework::FrameworkException" + exception FrameworkException { + + // Constant identifier: "ERR_NOT_FOUND" + // Qualified name: "::framework::FrameworkException::ERR_NOT_FOUND" + const long ERR_NOT_FOUND = 1; + + // Exception field identifier: "code" + long code; + }; + + // Interface identifier: "System" + // Qualified name: "::framework::System" + interface System { + + // Operation identifier: "createObject" + // Operation argument identifier: "interface" + object createObject(DOMString _interface); + + // Operation has no identifier; it declares a getter. + getter DOMString (DOMString keyName); + }; + + + // Interface identifier: "TextField" + // Qualified name: "::framework::gui::TextField" + interface TextField { + + // Attribute identifier: "const" + attribute boolean _const; + + // Attribute identifier: "value" + attribute DOMString? _value; + }; + +interface Foo { + void op(object interface); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/implements.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/implements.widl new file mode 100644 index 000000000..7a310926f --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/implements.widl @@ -0,0 +1,14 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 + interface Node { + readonly attribute unsigned short nodeType; + // ... + }; + + interface EventTarget { + void addEventListener(DOMString type, + EventListener listener, + boolean useCapture); + // ... + }; + + Node implements EventTarget; diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/indexed-properties.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/indexed-properties.widl new file mode 100644 index 000000000..acf0ed3bf --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/indexed-properties.widl @@ -0,0 +1,12 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface OrderedMap { + readonly attribute unsigned long size; + + getter any getByIndex(unsigned long index); + setter void setByIndex(unsigned long index, any value); + deleter void removeByIndex(unsigned long index); + + getter any get(DOMString name); + setter creator void set(DOMString name, any value); + deleter void remove(DOMString name); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/inherits-getter.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/inherits-getter.widl new file mode 100644 index 000000000..558e81164 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/inherits-getter.widl @@ -0,0 +1,16 @@ +interface Animal { + + // A simple attribute that can be set to any string value. + readonly attribute DOMString name; +}; + +interface Person : Animal { + + // An attribute whose value cannot be assigned to. + readonly attribute unsigned short age; + + // An attribute that can raise an exception if it is set to an invalid value. + // Its getter behavior is inherited from Animal, and need not be specified + // the description of Person. + inherit attribute DOMString name; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/interface-inherits.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/interface-inherits.widl new file mode 100644 index 000000000..7921def77 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/interface-inherits.widl @@ -0,0 +1,12 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface Animal { + attribute DOMString name; +}; + +interface Human : Animal { + attribute Dog pet; +}; + +interface Dog : Animal { + attribute Human owner; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/iterable.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/iterable.widl new file mode 100644 index 000000000..c7dfafa4d --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/iterable.widl @@ -0,0 +1,7 @@ +interface IterableOne { + iterable; +}; + +interface IterableTwo { + iterable; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/iterator.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/iterator.widl new file mode 100644 index 000000000..3bf1b36de --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/iterator.widl @@ -0,0 +1,35 @@ +interface SessionManager { + Session getSessionForUser(DOMString username); + readonly attribute unsigned long sessionCount; + + Session iterator; +}; + +interface Session { + readonly attribute DOMString username; + // ... +}; + +interface SessionManager2 { + Session2 getSessionForUser(DOMString username); + readonly attribute unsigned long sessionCount; + + Session2 iterator = SessionIterator; +}; + +interface Session2 { + readonly attribute DOMString username; + // ... +}; + +interface SessionIterator { + readonly attribute unsigned long remainingSessions; +}; + + interface NodeList { + Node iterator = NodeIterator; + }; + + interface NodeIterator { + Node iterator object; + }; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/legacyiterable.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/legacyiterable.widl new file mode 100644 index 000000000..eafa7cf04 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/legacyiterable.widl @@ -0,0 +1,3 @@ +interface LegacyIterable { + legacyiterable; +}; diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/map.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/map.widl new file mode 100644 index 000000000..19b54f80a --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/map.widl @@ -0,0 +1,5 @@ +// Extracted from https://slightlyoff.github.io/ServiceWorker/spec/service_worker/ on 2014-05-06 + +[MapClass(DOMString, DOMString)] +interface HeaderMap { +}; diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/maplike.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/maplike.widl new file mode 100644 index 000000000..7b79b3888 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/maplike.widl @@ -0,0 +1,7 @@ +interface MapLike { + maplike; +}; + +interface ReadOnlyMapLike { + readonly maplike; +}; diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/namedconstructor.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/namedconstructor.widl new file mode 100644 index 000000000..c468b78f8 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/namedconstructor.widl @@ -0,0 +1,6 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +[NamedConstructor=Audio, + NamedConstructor=Audio(DOMString src)] +interface HTMLAudioElement : HTMLMediaElement { + // ... +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/nointerfaceobject.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/nointerfaceobject.widl new file mode 100644 index 000000000..c17d75ff8 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/nointerfaceobject.widl @@ -0,0 +1,5 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +[NoInterfaceObject] +interface Query { + any lookupEntry(unsigned long key); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/nullable.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/nullable.widl new file mode 100644 index 000000000..ccbf625ff --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/nullable.widl @@ -0,0 +1,9 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface MyConstants { + const boolean? ARE_WE_THERE_YET = false; +}; + +interface Node { + readonly attribute DOMString? namespaceURI; + // ... +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/nullableobjects.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/nullableobjects.widl new file mode 100644 index 000000000..83d1d40b2 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/nullableobjects.widl @@ -0,0 +1,13 @@ +// Extracted from WebIDL spec 2011-05-23 + +interface A { + // ... +}; +interface B { + // ... +}; +interface C { + void f(A? x); + void f(B? x); + +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/operation-optional-arg.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/operation-optional-arg.widl new file mode 100644 index 000000000..379053b45 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/operation-optional-arg.widl @@ -0,0 +1,4 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface ColorCreator { + object createColor(float v1, float v2, float v3, optional float alpha = 3.5); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/overloading.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/overloading.widl new file mode 100644 index 000000000..ef1288a88 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/overloading.widl @@ -0,0 +1,20 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface A { + // ... +}; + +interface B { + // ... +}; + +interface C { + void f(A x); + void f(B x); +}; + +interface A { + /* f1 */ void f(DOMString a); + /* f2 */ void f([AllowAny] DOMString a, DOMString b, float... c); + /* f3 */ void f(); + /* f4 */ void f(long a, DOMString b, optional DOMString c, float... d); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/overridebuiltins.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/overridebuiltins.widl new file mode 100644 index 000000000..79211c29e --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/overridebuiltins.widl @@ -0,0 +1,6 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +[OverrideBuiltins] +interface StringMap2 { + readonly attribute unsigned long length; + getter DOMString lookup(DOMString key); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/partial-interface.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/partial-interface.widl new file mode 100644 index 000000000..90e7e0ea4 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/partial-interface.widl @@ -0,0 +1,7 @@ +interface Foo { + attribute DOMString bar; +}; + +partial interface Foo { + attribute DOMString quux; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/primitives.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/primitives.widl new file mode 100644 index 000000000..92939601a --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/primitives.widl @@ -0,0 +1,19 @@ +interface Primitives { + attribute boolean truth; + attribute byte character; + attribute octet value; + attribute short number; + attribute unsigned short positive; + attribute long big; + attribute unsigned long bigpositive; + attribute long long bigbig; + attribute unsigned long long bigbigpositive; + attribute float real; + attribute double bigreal; + attribute unrestricted float realwithinfinity; + attribute unrestricted double bigrealwithinfinity; + attribute DOMString string; + attribute ByteString bytes; + attribute Date date; + attribute RegExp regexp; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/prototyperoot.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/prototyperoot.widl new file mode 100644 index 000000000..30dd5cbca --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/prototyperoot.widl @@ -0,0 +1,5 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +[PrototypeRoot] +interface Node { + readonly attribute unsigned short nodeType; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/putforwards.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/putforwards.widl new file mode 100644 index 000000000..1e50a4ee3 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/putforwards.widl @@ -0,0 +1,5 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface Person { + [PutForwards=full] readonly attribute Name name; + attribute unsigned short age; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/reg-operations.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/reg-operations.widl new file mode 100644 index 000000000..13997cb1d --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/reg-operations.widl @@ -0,0 +1,17 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface Dimensions { + attribute unsigned long width; + attribute unsigned long height; +}; + +exception NoPointerDevice { }; + +interface Button { + + // An operation that takes no arguments, returns a boolean + boolean isMouseOver(); + + // Overloaded operations. + void setDimensions(Dimensions size); + void setDimensions(unsigned long width, unsigned long height); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/replaceable.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/replaceable.widl new file mode 100644 index 000000000..c14d0c376 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/replaceable.widl @@ -0,0 +1,5 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface Counter { + [Replaceable] readonly attribute unsigned long value; + void increment(); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/sequence.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/sequence.widl new file mode 100644 index 000000000..6ba0d390d --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/sequence.widl @@ -0,0 +1,12 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +// edited to remove sequence as attributes, now invalid +interface Canvas { + void drawPolygon(sequence coordinates); + sequence getInflectionPoints(); + // ... +}; + +// Make sure sequence can still be registered as a type. +interface Foo { + sequence bar(); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/serializer.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/serializer.widl new file mode 100644 index 000000000..6f6ccd0e8 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/serializer.widl @@ -0,0 +1,64 @@ +interface Transaction { + readonly attribute Account from; + readonly attribute Account to; + readonly attribute float amount; + readonly attribute DOMString description; + readonly attribute unsigned long number; + + serializer; +}; + +interface Account { + attribute DOMString name; + attribute unsigned long number; + serializer DOMString serialize(); +}; + +interface Transaction2 { + readonly attribute Account2 from; + readonly attribute Account2 to; + readonly attribute float amount; + readonly attribute DOMString description; + readonly attribute unsigned long number; + + serializer = { from, to, amount, description }; +}; + +interface Account2 { + attribute DOMString name; + attribute unsigned long number; + serializer = number; +}; + +interface Account3 { + attribute DOMString name; + attribute unsigned long number; + + serializer = { attribute }; +}; + +interface Account4 { + getter object getItem(unsigned long index); + serializer = { getter }; +}; + +interface Account5 : Account { + attribute DOMString secondname; + serializer = { inherit, secondname }; +}; + +interface Account6 : Account { + attribute DOMString secondname; + serializer = { inherit, attribute }; +}; + +interface Account7 { + attribute DOMString name; + attribute unsigned long number; + serializer = [ name, number ]; +}; + +interface Account8 { + getter object getItem(unsigned long index); + serializer = [ getter ]; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/setlike.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/setlike.widl new file mode 100644 index 000000000..890e8e5a7 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/setlike.widl @@ -0,0 +1,7 @@ +interface SetLike { + setlike; +}; + +interface ReadOnlySetLike { + readonly setlike; +}; diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/static.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/static.widl new file mode 100644 index 000000000..5b2cd3659 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/static.widl @@ -0,0 +1,11 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface Point { /* ... */ }; + +interface Circle { + attribute float cx; + attribute float cy; + attribute float radius; + + static readonly attribute long triangulationCount; + static Point triangulate(Circle c1, Circle c2, Circle c3); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/stringifier-attribute.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/stringifier-attribute.widl new file mode 100644 index 000000000..c964ecb93 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/stringifier-attribute.widl @@ -0,0 +1,6 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +[Constructor] +interface Student { + attribute unsigned long id; + stringifier attribute DOMString name; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/stringifier-custom.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/stringifier-custom.widl new file mode 100644 index 000000000..b5d7c87e7 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/stringifier-custom.widl @@ -0,0 +1,9 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +[Constructor] +interface Student { + attribute unsigned long id; + attribute DOMString? familyName; + attribute DOMString givenName; + + stringifier DOMString (); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/stringifier.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/stringifier.widl new file mode 100644 index 000000000..4eb483d9b --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/stringifier.widl @@ -0,0 +1,8 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface A { + stringifier DOMString (); +}; + +interface A { + stringifier; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/treatasnull.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/treatasnull.widl new file mode 100644 index 000000000..d3c55b008 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/treatasnull.widl @@ -0,0 +1,7 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface Dog { + attribute DOMString name; + attribute DOMString owner; + + boolean isMemberOfBreed([TreatNullAs=EmptyString] DOMString breedName); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/treatasundefined.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/treatasundefined.widl new file mode 100644 index 000000000..e30050f84 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/treatasundefined.widl @@ -0,0 +1,7 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface Cat { + attribute DOMString name; + attribute DOMString owner; + + boolean isMemberOfBreed([TreatUndefinedAs=EmptyString] DOMString breedName); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/typedef-nested.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/typedef-nested.widl new file mode 100644 index 000000000..106f30b8f --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/typedef-nested.widl @@ -0,0 +1,22 @@ + + interface Point { + attribute float x; + attribute float y; + }; + + + interface Rect { + attribute Point topleft; + attribute Point bottomright; + }; + + interface Widget { + typedef sequence PointSequence; + + readonly attribute Rect bounds; + + boolean pointWithinBounds(Point p); + boolean allPointsWithinBounds(PointSequence ps); + }; + + typedef [Clamp] octet value; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/typedef.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/typedef.widl new file mode 100644 index 000000000..b4c17d8d3 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/typedef.widl @@ -0,0 +1,22 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 + interface Point { + attribute float x; + attribute float y; + }; + + typedef sequence PointSequence; + + interface Rect { + attribute Point topleft; + attribute Point bottomright; + }; + + interface Widget { + + readonly attribute Rect bounds; + + boolean pointWithinBounds(Point p); + boolean allPointsWithinBounds(PointSequence ps); + }; + + typedef [Clamp] octet value; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/typesuffixes.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/typesuffixes.widl new file mode 100644 index 000000000..95e31c169 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/typesuffixes.widl @@ -0,0 +1,3 @@ +interface Suffixes { + void test(sequence? foo); +}; diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/uniontype.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/uniontype.widl new file mode 100644 index 000000000..4d99f0196 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/uniontype.widl @@ -0,0 +1,3 @@ +interface Union { + attribute (float or (Date or Event) or (Node or DOMString)?) test; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/idl/variadic-operations.widl b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/variadic-operations.widl new file mode 100644 index 000000000..51fae4cc1 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/idl/variadic-operations.widl @@ -0,0 +1,7 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface IntegerSet { + readonly attribute unsigned long cardinality; + + void union(long... ints); + void intersection(long... ints); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/allowany.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/allowany.json new file mode 100644 index 000000000..8abc7f9e0 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/allowany.json @@ -0,0 +1,109 @@ +[ + { + "type": "interface", + "name": "B", + "partial": false, + "members": [ + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "g", + "arguments": [], + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "g", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "B" + }, + "name": "b" + } + ], + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "g", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [ + { + "name": "AllowAny", + "arguments": null + } + ], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "s" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/array.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/array.json new file mode 100644 index 000000000..39afaf6c8 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/array.json @@ -0,0 +1,34 @@ +[ + { + "type": "interface", + "name": "LotteryResults", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": 2, + "nullableArray": [false, false], + "union": false, + "idlType": "unsigned short" + }, + "name": "numbers", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [ + { + "name": "Constructor", + "arguments": null + } + ] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/attributes.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/attributes.json new file mode 100644 index 000000000..cdf46b0ec --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/attributes.json @@ -0,0 +1,56 @@ +[ + { + "type": "exception", + "name": "InvalidName", + "members": [ + { + "type": "field", + "name": "reason", + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "exception", + "name": "NoSuchPet", + "members": [], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "Person", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned short" + }, + "name": "age", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/callback.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/callback.json new file mode 100644 index 000000000..43a517510 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/callback.json @@ -0,0 +1,119 @@ +[ + { + "type": "callback", + "name": "AsyncOperationCallback", + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "status" + } + ], + "extAttrs": [] + }, + { + "type": "callback interface", + "name": "EventHandler", + "partial": false, + "members": [ + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "eventOccurred", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "details" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "callback", + "name": "SortCallback", + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "boolean" + }, + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "any" + }, + "name": "a" + }, + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "any" + }, + "name": "b" + } + ], + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/caller.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/caller.json new file mode 100644 index 000000000..a0fb5e396 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/caller.json @@ -0,0 +1,47 @@ +[ + { + "type": "interface", + "name": "NumberQuadrupler", + "partial": false, + "members": [ + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": true, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "compute", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "x" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/constants.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/constants.json new file mode 100644 index 000000000..0fe6e92af --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/constants.json @@ -0,0 +1,141 @@ +[ + { + "type": "interface", + "name": "Util", + "partial": false, + "members": [ + { + "type": "const", + "nullable": false, + "idlType": "boolean", + "name": "DEBUG", + "value": { + "type": "boolean", + "value": false + }, + "extAttrs": [] + }, + { + "type": "const", + "nullable": false, + "idlType": "short", + "name": "negative", + "value": { + "type": "number", + "value": -1 + }, + "extAttrs": [] + }, + { + "type": "const", + "nullable": false, + "idlType": "octet", + "name": "LF", + "value": { + "type": "number", + "value": 10 + }, + "extAttrs": [] + }, + { + "type": "const", + "nullable": false, + "idlType": "unsigned long", + "name": "BIT_MASK", + "value": { + "type": "number", + "value": 64512 + }, + "extAttrs": [] + }, + { + "type": "const", + "nullable": false, + "idlType": "float", + "name": "AVOGADRO", + "value": { + "type": "number", + "value": 6.022e+23 + }, + "extAttrs": [] + }, + { + "type": "const", + "nullable": false, + "idlType": "unrestricted float", + "name": "sobig", + "value": { + "type": "Infinity", + "negative": false + }, + "extAttrs": [] + }, + { + "type": "const", + "nullable": false, + "idlType": "unrestricted double", + "name": "minusonedividedbyzero", + "value": { + "type": "Infinity", + "negative": true + }, + "extAttrs": [] + }, + { + "type": "const", + "nullable": false, + "idlType": "short", + "name": "notanumber", + "value": { + "type": "NaN" + }, + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "exception", + "name": "Error", + "members": [ + { + "type": "const", + "nullable": false, + "idlType": "short", + "name": "ERR_UNKNOWN", + "value": { + "type": "number", + "value": 0 + }, + "extAttrs": [] + }, + { + "type": "const", + "nullable": false, + "idlType": "short", + "name": "ERR_OUT_OF_MEMORY", + "value": { + "type": "number", + "value": 1 + }, + "extAttrs": [] + }, + { + "type": "field", + "name": "errorCode", + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "short" + }, + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/constructor.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/constructor.json new file mode 100644 index 000000000..e5944f32e --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/constructor.json @@ -0,0 +1,103 @@ +[ + { + "type": "interface", + "name": "Circle", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "r", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "cx", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "cy", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "circumference", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [ + { + "name": "Constructor", + "arguments": null + }, + { + "name": "Constructor", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "radius" + } + ] + } + ] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/dictionary-inherits.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/dictionary-inherits.json new file mode 100644 index 000000000..fbb2338a8 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/dictionary-inherits.json @@ -0,0 +1,83 @@ +[ + { + "type": "dictionary", + "name": "PaintOptions", + "partial": false, + "members": [ + { + "type": "field", + "name": "fillPattern", + "required": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": true, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "extAttrs": [], + "default": { + "type": "string", + "value": "black" + } + }, + { + "type": "field", + "name": "strokePattern", + "required": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": true, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "extAttrs": [], + "default": { + "type": "null" + } + }, + { + "type": "field", + "name": "position", + "required": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Point" + }, + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "dictionary", + "name": "WetPaintOptions", + "partial": false, + "members": [ + { + "type": "field", + "name": "hydrometry", + "required": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "extAttrs": [] + } + ], + "inheritance": "PaintOptions", + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/dictionary.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/dictionary.json new file mode 100644 index 000000000..a7c89caab --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/dictionary.json @@ -0,0 +1,135 @@ +[ + { + "type": "dictionary", + "name": "PaintOptions", + "partial": false, + "members": [ + { + "type": "field", + "name": "fillPattern", + "required": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": true, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "extAttrs": [], + "default": { + "type": "string", + "value": "black" + } + }, + { + "type": "field", + "name": "strokePattern", + "required": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": true, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "extAttrs": [], + "default": { + "type": "null" + } + }, + { + "type": "field", + "name": "position", + "required": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Point" + }, + "extAttrs": [] + }, + { + "type": "field", + "name": "seq", + "required": false, + "idlType": { + "sequence": true, + "generic": "sequence", + "nullable": false, + "array": false, + "union": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "long" + } + }, + "extAttrs": [], + "default": { + "type": "sequence", + "value": [] + } + }, + { + "type": "field", + "name": "reqSeq", + "required": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "long" + }, + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "dictionary", + "name": "A", + "partial": true, + "members": [ + { + "type": "field", + "name": "h", + "required": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "long" + }, + "extAttrs": [] + }, + { + "type": "field", + "name": "d", + "required": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "long" + }, + "extAttrs": [] + } + ], + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/documentation-dos.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/documentation-dos.json new file mode 100644 index 000000000..340e039b4 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/documentation-dos.json @@ -0,0 +1,10 @@ +[ + { + "type": "interface", + "name": "Documentation", + "partial": false, + "members": [], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/documentation.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/documentation.json new file mode 100644 index 000000000..340e039b4 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/documentation.json @@ -0,0 +1,10 @@ +[ + { + "type": "interface", + "name": "Documentation", + "partial": false, + "members": [], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/enum.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/enum.json new file mode 100644 index 000000000..196ee4e64 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/enum.json @@ -0,0 +1,115 @@ +[ + { + "type": "enum", + "name": "MealType", + "values": [ + "rice", + "noodles", + "other" + ], + "extAttrs": [] + }, + { + "type": "interface", + "name": "Meal", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "MealType" + }, + "name": "type", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "size", + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "initialize", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "MealType" + }, + "name": "type" + }, + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "size" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "enum", + "name": "AltMealType", + "values": [ + "rice", + "noodles", + "other" + ], + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/equivalent-decl.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/equivalent-decl.json new file mode 100644 index 000000000..55a787fdc --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/equivalent-decl.json @@ -0,0 +1,312 @@ +[ + { + "type": "interface", + "name": "Dictionary", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "propertyCount", + "extAttrs": [] + }, + { + "type": "operation", + "getter": true, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "getProperty", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "propertyName" + } + ], + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": true, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "setProperty", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "propertyName" + }, + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "propertyValue" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "Dictionary", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "propertyCount", + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "getProperty", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "propertyName" + } + ], + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "setProperty", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "propertyName" + }, + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "propertyValue" + } + ], + "extAttrs": [] + }, + { + "type": "operation", + "getter": true, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": null, + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "propertyName" + } + ], + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": true, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": null, + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "propertyName" + }, + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "propertyValue" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/exception-inheritance.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/exception-inheritance.json new file mode 100644 index 000000000..f4dc68699 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/exception-inheritance.json @@ -0,0 +1,37 @@ +[ + { + "type": "exception", + "name": "DOMException", + "members": [ + { + "type": "field", + "name": "code", + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned short" + }, + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "exception", + "name": "HierarchyRequestError", + "members": [], + "inheritance": "DOMException", + "extAttrs": [] + }, + { + "type": "exception", + "name": "NoModificationAllowedError", + "members": [], + "inheritance": "DOMException", + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/exception.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/exception.json new file mode 100644 index 000000000..3f16de828 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/exception.json @@ -0,0 +1,35 @@ +[ + { + "type": "interface", + "name": "Dahut", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "type", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "exception", + "name": "SomeException", + "members": [], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/extended-attributes.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/extended-attributes.json new file mode 100644 index 000000000..228c4b824 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/extended-attributes.json @@ -0,0 +1,30 @@ +[ + { + "type": "interface", + "name": "ServiceWorkerGlobalScope", + "partial": false, + "members": [], + "inheritance": "WorkerGlobalScope", + "extAttrs": [ + { + "name": "Global", + "arguments": null, + "rhs": { + "type": "identifier-list", + "value": [ + "Worker", + "ServiceWorker" + ] + } + }, + { + "name": "Exposed", + "arguments": null, + "rhs": { + "type": "identifier", + "value": "ServiceWorker" + } + } + ] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/generic.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/generic.json new file mode 100644 index 000000000..e39654ffd --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/generic.json @@ -0,0 +1,181 @@ +[ + { + "type": "interface", + "name": "Foo", + "partial": false, + "members": [ + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": "Promise", + "nullable": false, + "array": false, + "union": false, + "idlType": { + "sequence": false, + "generic": "ResponsePromise", + "nullable": false, + "array": false, + "union": false, + "idlType": { + "sequence": true, + "generic": "sequence", + "nullable": false, + "array": false, + "union": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": true, + "array": false, + "union": false, + "idlType": "DOMString" + } + } + } + }, + "name": "bar", + "arguments": [], + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": "Promise", + "nullable": false, + "array": 1, + "nullableArray": [false], + "union": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + } + }, + "name": "baz", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "ServiceWorkerClients", + "partial": false, + "members": [ + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": "Promise", + "nullable": false, + "array": false, + "union": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": true, + "nullableArray": [false], + "array": 1, + "union": false, + "idlType": "Client" + } + }, + "name": "getServiced", + "arguments": [], + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": "Promise", + "nullable": false, + "array": false, + "union": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "any" + } + }, + "name": "reloadAll", + "arguments": [], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "FetchEvent", + "partial": false, + "members": [ + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": "ResponsePromise", + "nullable": false, + "array": false, + "union": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "any" + } + }, + "name": "default", + "arguments": [], + "extAttrs": [] + } + ], + "inheritance": "Event", + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/getter-setter.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/getter-setter.json new file mode 100644 index 000000000..94d20d594 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/getter-setter.json @@ -0,0 +1,114 @@ +[ + { + "type": "interface", + "name": "Dictionary", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "propertyCount", + "extAttrs": [] + }, + { + "type": "operation", + "getter": true, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": null, + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "propertyName" + } + ], + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": true, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": null, + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "propertyName" + }, + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "propertyValue" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/identifier-qualified-names.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/identifier-qualified-names.json new file mode 100644 index 000000000..a91f8c8eb --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/identifier-qualified-names.json @@ -0,0 +1,217 @@ +[ + { + "type": "typedef", + "typeExtAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "number", + "extAttrs": [] + }, + { + "type": "exception", + "name": "FrameworkException", + "members": [ + { + "type": "const", + "nullable": false, + "idlType": "long", + "name": "ERR_NOT_FOUND", + "value": { + "type": "number", + "value": 1 + }, + "extAttrs": [] + }, + { + "type": "field", + "name": "code", + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "long" + }, + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "System", + "partial": false, + "members": [ + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "object" + }, + "name": "createObject", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "interface" + } + ], + "extAttrs": [] + }, + { + "type": "operation", + "getter": true, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": null, + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "keyName" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "TextField", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "boolean" + }, + "name": "const", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": true, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "value", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "Foo", + "partial": false, + "members": [ + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "op", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "object" + }, + "name": "interface" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/implements.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/implements.json new file mode 100644 index 000000000..fa00e3374 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/implements.json @@ -0,0 +1,107 @@ +[ + { + "type": "interface", + "name": "Node", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned short" + }, + "name": "nodeType", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "EventTarget", + "partial": false, + "members": [ + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "addEventListener", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "type" + }, + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "EventListener" + }, + "name": "listener" + }, + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "boolean" + }, + "name": "useCapture" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "implements", + "target": "Node", + "implements": "EventTarget", + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/indexed-properties.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/indexed-properties.json new file mode 100644 index 000000000..23cc4ab10 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/indexed-properties.json @@ -0,0 +1,272 @@ +[ + { + "type": "interface", + "name": "OrderedMap", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "size", + "extAttrs": [] + }, + { + "type": "operation", + "getter": true, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "any" + }, + "name": "getByIndex", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "index" + } + ], + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": true, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "setByIndex", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "index" + }, + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "any" + }, + "name": "value" + } + ], + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": true, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "removeByIndex", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "index" + } + ], + "extAttrs": [] + }, + { + "type": "operation", + "getter": true, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "any" + }, + "name": "get", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "name" + } + ], + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": true, + "creator": true, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "set", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "name" + }, + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "any" + }, + "name": "value" + } + ], + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": true, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "remove", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "name" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/inherits-getter.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/inherits-getter.json new file mode 100644 index 000000000..468e3caef --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/inherits-getter.json @@ -0,0 +1,71 @@ +[ + { + "type": "interface", + "name": "Animal", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "name", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "Person", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned short" + }, + "name": "age", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": true, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "name", + "extAttrs": [] + } + ], + "inheritance": "Animal", + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/interface-inherits.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/interface-inherits.json new file mode 100644 index 000000000..eee07cd1d --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/interface-inherits.json @@ -0,0 +1,80 @@ +[ + { + "type": "interface", + "name": "Animal", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "name", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "Human", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Dog" + }, + "name": "pet", + "extAttrs": [] + } + ], + "inheritance": "Animal", + "extAttrs": [] + }, + { + "type": "interface", + "name": "Dog", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Human" + }, + "name": "owner", + "extAttrs": [] + } + ], + "inheritance": "Animal", + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/iterable.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/iterable.json new file mode 100644 index 000000000..3e38991dd --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/iterable.json @@ -0,0 +1,55 @@ +[ + { + "type": "interface", + "name": "IterableOne", + "partial": false, + "members": [ + { + "type": "iterable", + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "long" + }, + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "IterableTwo", + "partial": false, + "members": [ + { + "type": "iterable", + "idlType": [ + { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "short" + }, + { + "sequence": false, + "generic": null, + "nullable": true, + "array": false, + "union": false, + "idlType": "double" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] + diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/iterator.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/iterator.json new file mode 100644 index 000000000..cc3c9ec50 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/iterator.json @@ -0,0 +1,301 @@ +[ + { + "type": "interface", + "name": "SessionManager", + "partial": false, + "members": [ + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Session" + }, + "name": "getSessionForUser", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "username" + } + ], + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "sessionCount", + "extAttrs": [] + }, + { + "type": "iterator", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Session" + }, + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "Session", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "username", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "SessionManager2", + "partial": false, + "members": [ + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Session2" + }, + "name": "getSessionForUser", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "username" + } + ], + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "sessionCount", + "extAttrs": [] + }, + { + "type": "iterator", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Session2" + }, + "iteratorObject": "SessionIterator", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "Session2", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "username", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "SessionIterator", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "remainingSessions", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "NodeList", + "partial": false, + "members": [ + { + "type": "iterator", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Node" + }, + "iteratorObject": "NodeIterator", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "NodeIterator", + "partial": false, + "members": [ + { + "type": "iterator", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Node" + }, + "iteratorObject": "object", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/legacyiterable.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/legacyiterable.json new file mode 100644 index 000000000..e63f99de4 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/legacyiterable.json @@ -0,0 +1,24 @@ +[ + { + "type": "interface", + "name": "LegacyIterable", + "partial": false, + "members": [ + { + "type": "legacyiterable", + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "long" + }, + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] + diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/map.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/map.json new file mode 100644 index 000000000..03ce9412e --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/map.json @@ -0,0 +1,29 @@ +[ + { + "type": "interface", + "name": "HeaderMap", + "partial": false, + "members": [], + "inheritance": null, + "extAttrs": [{ + "name": "MapClass", + "arguments": null, + "typePair": [{ + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }] + }] + } +] diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/maplike.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/maplike.json new file mode 100644 index 000000000..017d8b3f3 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/maplike.json @@ -0,0 +1,67 @@ +[ + { + "type": "interface", + "name": "MapLike", + "partial": false, + "members": [ + { + "type": "maplike", + "idlType": [ + { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "long" + }, + { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + } + ], + "readonly": false, + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "ReadOnlyMapLike", + "partial": false, + "members": [ + { + "type": "maplike", + "idlType": [ + { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "long" + }, + { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + } + ], + "readonly": true, + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] + diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/namedconstructor.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/namedconstructor.json new file mode 100644 index 000000000..a947a64a4 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/namedconstructor.json @@ -0,0 +1,42 @@ +[ + { + "type": "interface", + "name": "HTMLAudioElement", + "partial": false, + "members": [], + "inheritance": "HTMLMediaElement", + "extAttrs": [ + { + "name": "NamedConstructor", + "arguments": null, + "rhs": { + "type": "identifier", + "value": "Audio" + } + }, + { + "name": "NamedConstructor", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "src" + } + ], + "rhs": { + "type": "identifier", + "value": "Audio" + } + } + ] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/nointerfaceobject.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/nointerfaceobject.json new file mode 100644 index 000000000..90f0d63c8 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/nointerfaceobject.json @@ -0,0 +1,52 @@ +[ + { + "type": "interface", + "name": "Query", + "partial": false, + "members": [ + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "any" + }, + "name": "lookupEntry", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "key" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [ + { + "name": "NoInterfaceObject", + "arguments": null + } + ] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/nullable.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/nullable.json new file mode 100644 index 000000000..300442f0d --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/nullable.json @@ -0,0 +1,48 @@ +[ + { + "type": "interface", + "name": "MyConstants", + "partial": false, + "members": [ + { + "type": "const", + "nullable": true, + "idlType": "boolean", + "name": "ARE_WE_THERE_YET", + "value": { + "type": "boolean", + "value": false + }, + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "Node", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": true, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "namespaceURI", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/nullableobjects.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/nullableobjects.json new file mode 100644 index 000000000..40f7db0c1 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/nullableobjects.json @@ -0,0 +1,99 @@ +[ + { + "type": "interface", + "name": "A", + "partial": false, + "members": [], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "B", + "partial": false, + "members": [], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "C", + "partial": false, + "members": [ + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "f", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": true, + "array": false, + "union": false, + "idlType": "A" + }, + "name": "x" + } + ], + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "f", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": true, + "array": false, + "union": false, + "idlType": "B" + }, + "name": "x" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/operation-optional-arg.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/operation-optional-arg.json new file mode 100644 index 000000000..6ca32576b --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/operation-optional-arg.json @@ -0,0 +1,93 @@ +[ + { + "type": "interface", + "name": "ColorCreator", + "partial": false, + "members": [ + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "object" + }, + "name": "createColor", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "v1" + }, + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "v2" + }, + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "v3" + }, + { + "optional": true, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "alpha", + "default": { + "type": "number", + "value": 3.5 + } + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/overloading.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/overloading.json new file mode 100644 index 000000000..c3baa4396 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/overloading.json @@ -0,0 +1,312 @@ +[ + { + "type": "interface", + "name": "A", + "partial": false, + "members": [], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "B", + "partial": false, + "members": [], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "C", + "partial": false, + "members": [ + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "f", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "A" + }, + "name": "x" + } + ], + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "f", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "B" + }, + "name": "x" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "A", + "partial": false, + "members": [ + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "f", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "a" + } + ], + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "f", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [ + { + "name": "AllowAny", + "arguments": null + } + ], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "a" + }, + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "b" + }, + { + "optional": false, + "variadic": true, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "c" + } + ], + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "f", + "arguments": [], + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "f", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "long" + }, + "name": "a" + }, + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "b" + }, + { + "optional": true, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "c" + }, + { + "optional": false, + "variadic": true, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "d" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/overridebuiltins.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/overridebuiltins.json new file mode 100644 index 000000000..9e2f795e2 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/overridebuiltins.json @@ -0,0 +1,69 @@ +[ + { + "type": "interface", + "name": "StringMap2", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "length", + "extAttrs": [] + }, + { + "type": "operation", + "getter": true, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "lookup", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "key" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [ + { + "name": "OverrideBuiltins", + "arguments": null + } + ] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/partial-interface.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/partial-interface.json new file mode 100644 index 000000000..53c65a453 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/partial-interface.json @@ -0,0 +1,53 @@ +[ + { + "type": "interface", + "name": "Foo", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "bar", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "Foo", + "partial": true, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "quux", + "extAttrs": [] + } + ], + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/primitives.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/primitives.json new file mode 100644 index 000000000..7160c2a4c --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/primitives.json @@ -0,0 +1,300 @@ +[ + { + "type": "interface", + "name": "Primitives", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "boolean" + }, + "name": "truth", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "byte" + }, + "name": "character", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "octet" + }, + "name": "value", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "short" + }, + "name": "number", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned short" + }, + "name": "positive", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "long" + }, + "name": "big", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "bigpositive", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "long long" + }, + "name": "bigbig", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long long" + }, + "name": "bigbigpositive", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "real", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "double" + }, + "name": "bigreal", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unrestricted float" + }, + "name": "realwithinfinity", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unrestricted double" + }, + "name": "bigrealwithinfinity", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "string", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "ByteString" + }, + "name": "bytes", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Date" + }, + "name": "date", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "RegExp" + }, + "name": "regexp", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/prototyperoot.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/prototyperoot.json new file mode 100644 index 000000000..666798d94 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/prototyperoot.json @@ -0,0 +1,33 @@ +[ + { + "type": "interface", + "name": "Node", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned short" + }, + "name": "nodeType", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [ + { + "name": "PrototypeRoot", + "arguments": null + } + ] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/putforwards.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/putforwards.json new file mode 100644 index 000000000..bd5e619ca --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/putforwards.json @@ -0,0 +1,54 @@ +[ + { + "type": "interface", + "name": "Person", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Name" + }, + "name": "name", + "extAttrs": [ + { + "name": "PutForwards", + "arguments": null, + "rhs": { + "type": "identifier", + "value": "full" + } + } + ] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned short" + }, + "name": "age", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/reg-operations.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/reg-operations.json new file mode 100644 index 000000000..c827fff03 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/reg-operations.json @@ -0,0 +1,168 @@ +[ + { + "type": "interface", + "name": "Dimensions", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "width", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "height", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "exception", + "name": "NoPointerDevice", + "members": [], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "Button", + "partial": false, + "members": [ + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "boolean" + }, + "name": "isMouseOver", + "arguments": [], + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "setDimensions", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Dimensions" + }, + "name": "size" + } + ], + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "setDimensions", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "width" + }, + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "height" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/replaceable.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/replaceable.json new file mode 100644 index 000000000..4d25f3d93 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/replaceable.json @@ -0,0 +1,54 @@ +[ + { + "type": "interface", + "name": "Counter", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "value", + "extAttrs": [ + { + "name": "Replaceable", + "arguments": null + } + ] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "increment", + "arguments": [], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/sequence.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/sequence.json new file mode 100644 index 000000000..7ddd402b4 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/sequence.json @@ -0,0 +1,113 @@ +[ + { + "type": "interface", + "name": "Canvas", + "partial": false, + "members": [ + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "drawPolygon", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": true, + "generic": "sequence", + "nullable": false, + "array": false, + "union": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + } + }, + "name": "coordinates" + } + ], + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": true, + "generic": "sequence", + "nullable": false, + "array": false, + "union": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + } + }, + "name": "getInflectionPoints", + "arguments": [], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "Foo", + "partial": false, + "members": [ + + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "sequence" + }, + "name": "bar", + "arguments": [], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/serializer.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/serializer.json new file mode 100644 index 000000000..79b501fcb --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/serializer.json @@ -0,0 +1,591 @@ +[ + { + "type": "interface", + "name": "Transaction", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Account" + }, + "name": "from", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Account" + }, + "name": "to", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "amount", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "description", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "number", + "extAttrs": [] + }, + { + "type": "serializer", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "Account", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "name", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "number", + "extAttrs": [] + }, + { + "type": "serializer", + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "operation": { + "name": "serialize", + "arguments": [] + }, + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "Transaction2", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Account2" + }, + "name": "from", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Account2" + }, + "name": "to", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "amount", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "description", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "number", + "extAttrs": [] + }, + { + "type": "serializer", + "patternMap": true, + "names": [ + "from", + "to", + "amount", + "description" + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "Account2", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "name", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "number", + "extAttrs": [] + }, + { + "type": "serializer", + "name": "number", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "Account3", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "name", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "number", + "extAttrs": [] + }, + { + "type": "serializer", + "patternMap": true, + "names": [ + "attribute" + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "Account4", + "partial": false, + "members": [ + { + "type": "operation", + "getter": true, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "object" + }, + "name": "getItem", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "index" + } + ], + "extAttrs": [] + }, + { + "type": "serializer", + "patternMap": true, + "names": [ + "getter" + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "Account5", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "secondname", + "extAttrs": [] + }, + { + "type": "serializer", + "patternMap": true, + "names": [ + "inherit", + "secondname" + ], + "extAttrs": [] + } + ], + "inheritance": "Account", + "extAttrs": [] + }, + { + "type": "interface", + "name": "Account6", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "secondname", + "extAttrs": [] + }, + { + "type": "serializer", + "patternMap": true, + "names": [ + "inherit", + "attribute" + ], + "extAttrs": [] + } + ], + "inheritance": "Account", + "extAttrs": [] + }, + { + "type": "interface", + "name": "Account7", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "name", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "number", + "extAttrs": [] + }, + { + "type": "serializer", + "patternList": true, + "names": [ + "name", + "number" + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "Account8", + "partial": false, + "members": [ + { + "type": "operation", + "getter": true, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "object" + }, + "name": "getItem", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "index" + } + ], + "extAttrs": [] + }, + { + "type": "serializer", + "patternList": true, + "names": [ + "getter" + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/setlike.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/setlike.json new file mode 100644 index 000000000..d44043a94 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/setlike.json @@ -0,0 +1,47 @@ +[ + { + "type": "interface", + "name": "SetLike", + "partial": false, + "members": [ + { + "type": "setlike", + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "long" + }, + "readonly": false, + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "ReadOnlySetLike", + "partial": false, + "members": [ + { + "type": "setlike", + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "long" + }, + "readonly": true, + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] + diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/static.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/static.json new file mode 100644 index 000000000..faab12b29 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/static.json @@ -0,0 +1,151 @@ +[ + { + "type": "interface", + "name": "Point", + "partial": false, + "members": [], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "Circle", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "cx", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "cy", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "radius", + "extAttrs": [] + }, + { + "type": "attribute", + "static": true, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "long" + }, + "name": "triangulationCount", + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": true, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Point" + }, + "name": "triangulate", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Circle" + }, + "name": "c1" + }, + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Circle" + }, + "name": "c2" + }, + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Circle" + }, + "name": "c3" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/stringifier-attribute.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/stringifier-attribute.json new file mode 100644 index 000000000..196ee6f1a --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/stringifier-attribute.json @@ -0,0 +1,50 @@ +[ + { + "type": "interface", + "name": "Student", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "id", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": true, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "name", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [ + { + "name": "Constructor", + "arguments": null + } + ] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/stringifier-custom.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/stringifier-custom.json new file mode 100644 index 000000000..b4ab7392e --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/stringifier-custom.json @@ -0,0 +1,88 @@ +[ + { + "type": "interface", + "name": "Student", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "id", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": true, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "familyName", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "givenName", + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": null, + "arguments": [], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [ + { + "name": "Constructor", + "arguments": null + } + ] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/stringifier.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/stringifier.json new file mode 100644 index 000000000..ad3abde85 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/stringifier.json @@ -0,0 +1,52 @@ +[ + { + "type": "interface", + "name": "A", + "partial": false, + "members": [ + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": null, + "arguments": [], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "A", + "partial": false, + "members": [ + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": true, + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/treatasnull.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/treatasnull.json new file mode 100644 index 000000000..8bacb967a --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/treatasnull.json @@ -0,0 +1,90 @@ +[ + { + "type": "interface", + "name": "Dog", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "name", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "owner", + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "boolean" + }, + "name": "isMemberOfBreed", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [ + { + "name": "TreatNullAs", + "arguments": null, + "rhs": { + "type": "identifier", + "value": "EmptyString" + } + } + ], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "breedName" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/treatasundefined.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/treatasundefined.json new file mode 100644 index 000000000..91c4d25f5 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/treatasundefined.json @@ -0,0 +1,90 @@ +[ + { + "type": "interface", + "name": "Cat", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "name", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "owner", + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "boolean" + }, + "name": "isMemberOfBreed", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [ + { + "name": "TreatUndefinedAs", + "arguments": null, + "rhs": { + "type": "identifier", + "value": "EmptyString" + } + } + ], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + }, + "name": "breedName" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/typedef-nested.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/typedef-nested.json new file mode 100644 index 000000000..76d138408 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/typedef-nested.json @@ -0,0 +1,226 @@ +[ + { + "type": "interface", + "name": "Point", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "x", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "y", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "Rect", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Point" + }, + "name": "topleft", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Point" + }, + "name": "bottomright", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "Widget", + "partial": false, + "members": [ + { + "type": "typedef", + "typeExtAttrs": [], + "idlType": { + "sequence": true, + "generic": "sequence", + "nullable": false, + "array": false, + "union": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Point" + } + }, + "name": "PointSequence", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Rect" + }, + "name": "bounds", + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "boolean" + }, + "name": "pointWithinBounds", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Point" + }, + "name": "p" + } + ], + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "boolean" + }, + "name": "allPointsWithinBounds", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "PointSequence" + }, + "name": "ps" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "typedef", + "typeExtAttrs": [ + { + "name": "Clamp", + "arguments": null + } + ], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "octet" + }, + "name": "value", + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/typedef.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/typedef.json new file mode 100644 index 000000000..ffdeea945 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/typedef.json @@ -0,0 +1,226 @@ +[ + { + "type": "interface", + "name": "Point", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "x", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + "name": "y", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "typedef", + "typeExtAttrs": [], + "idlType": { + "sequence": true, + "generic": "sequence", + "nullable": false, + "array": false, + "union": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Point" + } + }, + "name": "PointSequence", + "extAttrs": [] + }, + { + "type": "interface", + "name": "Rect", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Point" + }, + "name": "topleft", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Point" + }, + "name": "bottomright", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "interface", + "name": "Widget", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Rect" + }, + "name": "bounds", + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "boolean" + }, + "name": "pointWithinBounds", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Point" + }, + "name": "p" + } + ], + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "boolean" + }, + "name": "allPointsWithinBounds", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "PointSequence" + }, + "name": "ps" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + }, + { + "type": "typedef", + "typeExtAttrs": [ + { + "name": "Clamp", + "arguments": null + } + ], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "octet" + }, + "name": "value", + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/typesuffixes.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/typesuffixes.json new file mode 100644 index 000000000..790c444ef --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/typesuffixes.json @@ -0,0 +1,55 @@ +[ + { + "type": "interface", + "name": "Suffixes", + "partial": false, + "members": [ + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "test", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "sequence": true, + "generic": "sequence", + "nullable": true, + "array": false, + "union": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": true, + "array": 1, + "nullableArray": [false], + "union": false, + "idlType": "DOMString" + } + }, + "name": "foo" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/uniontype.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/uniontype.json new file mode 100644 index 000000000..43e25fd6b --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/uniontype.json @@ -0,0 +1,87 @@ +[ + { + "type": "interface", + "name": "Union", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": true, + "idlType": [ + { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "float" + }, + { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": true, + "idlType": [ + { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Date" + }, + { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Event" + } + ] + }, + { + "sequence": false, + "generic": null, + "nullable": true, + "array": false, + "union": true, + "idlType": [ + { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "Node" + }, + { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "DOMString" + } + ] + } + ] + }, + "name": "test", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/json/variadic-operations.json b/testing/web-platform/tests/resources/webidl2/test/syntax/json/variadic-operations.json new file mode 100644 index 000000000..431ec0cb1 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/json/variadic-operations.json @@ -0,0 +1,100 @@ +[ + { + "type": "interface", + "name": "IntegerSet", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "unsigned long" + }, + "name": "cardinality", + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "union", + "arguments": [ + { + "optional": false, + "variadic": true, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "long" + }, + "name": "ints" + } + ], + "extAttrs": [] + }, + { + "type": "operation", + "getter": false, + "setter": false, + "creator": false, + "deleter": false, + "legacycaller": false, + "static": false, + "stringifier": false, + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "void" + }, + "name": "intersection", + "arguments": [ + { + "optional": false, + "variadic": true, + "extAttrs": [], + "idlType": { + "sequence": false, + "generic": null, + "nullable": false, + "array": false, + "union": false, + "idlType": "long" + }, + "name": "ints" + } + ], + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } +] \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/syntax/opt/typedef-nested.json b/testing/web-platform/tests/resources/webidl2/test/syntax/opt/typedef-nested.json new file mode 100644 index 000000000..f0794e74e --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/syntax/opt/typedef-nested.json @@ -0,0 +1,3 @@ +{ + "allowNestedTypedefs": true +} \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/web/make-web-tests.js b/testing/web-platform/tests/resources/webidl2/test/web/make-web-tests.js new file mode 100644 index 000000000..34c5a5c2b --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/web/make-web-tests.js @@ -0,0 +1,51 @@ + +// generates tests that work in a browser + +// XXX +// have it run through valid and invalid properly + +var pth = require("path") +, fs = require("fs") +, dir = function (path) { + return pth.join(__dirname, "..", path); + } +, allFromDir = function (dir, ext, asJSON) { + return fs.readdirSync(dir) + .filter(function (it) { return ext.test(it); }) + .map(function (it) { + var cnt = fs.readFileSync(pth.join(dir, it), "utf8"); + return asJSON ? JSON.parse(cnt) : cnt; + }); + } +, data = { + valid: { + json: allFromDir(dir("syntax/json"), /\.json$/, true) + , idl: allFromDir(dir("syntax/idl"), /\.w?idl$/, false) + } + , invalid:{ + json: allFromDir(dir("invalid/json"), /\.json$/, true) + , idl: allFromDir(dir("invalid/idl"), /\.w?idl$/, false) + } + } +, html = [ + "" + , "" + , " " + , " WebIDL2 Browser Tests" + , " " + , " " + , "
" + , " " + , " " + , " " + , " " + , " " + , " " + , " " + , " " + , " " + , "" + ].join("\n") +; + +fs.writeFileSync("browser-tests.html", html, "utf8"); diff --git a/testing/web-platform/tests/resources/webidl2/test/web/run-tests.js b/testing/web-platform/tests/resources/webidl2/test/web/run-tests.js new file mode 100644 index 000000000..a72800b8b --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/web/run-tests.js @@ -0,0 +1,48 @@ + +describe("Parses all of the IDLs to produce the correct ASTs", function () { + for (var i = 0, n = data.valid.idl.length; i < n; i++) { + var idl = data.valid.idl[i], json = data.valid.json[i]; + var func = (function (idl, json) { + return function () { + try { + // the AST contains NaN and +/-Infinity that cannot be serialised to JSON + // the stored JSON ASTs use the same replacement function as is used below + // so we compare based on that + var diff = jsondiffpatch.diff(json, WebIDL2.parse(idl)); + if (diff && debug) console.log(JSON.stringify(diff, null, 4)); + expect(diff).to.be(undefined); + } + catch (e) { + console.log(e.toString()); + throw e; + } + }; + }(idl, json)); + it("should produce the same AST for " + i, func); + } +}); + +describe("Parses all of the invalid IDLs to check that they blow up correctly", function () { + for (var i = 0, n = data.invalid.idl.length; i < n; i++) { + var idl = data.invalid.idl[i], error = data.invalid.json[i]; + var func = (function (idl, err) { + return function () { + var error; + try { + var ast = WebIDL2.parse(idl); + console.log(JSON.stringify(ast, null, 4)); + } + catch (e) { + error = e; + } + finally { + expect(error).to.be.ok(); + expect(error.message).to.equal(err.message); + expect(error.line).to.equal(err.line); + } + + }; + }(idl, error)); + it("should produce the right error for " + i, func); + } +}); diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/.gitignore b/testing/web-platform/tests/resources/webidl2/test/widlproc/.gitignore new file mode 100644 index 000000000..bffeb270d --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/.gitignore @@ -0,0 +1,3 @@ +obj/ +test/valid/obj +test/invalid/obj diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/LICENSE b/testing/web-platform/tests/resources/webidl2/test/widlproc/LICENSE new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/Makefile b/testing/web-platform/tests/resources/webidl2/test/widlproc/Makefile new file mode 100644 index 000000000..d517466e4 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/Makefile @@ -0,0 +1,158 @@ +######################################################################## +# $Id$ +# Copyright 2009 Aplix Corporation. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +######################################################################## + +UNAME = $(shell uname) +INCDIRS = $(OBJDIR) +SRCDIR = src +DOCDIR = doc +EXAMPLESDIR = examples +OBJDIR = obj + +######################################################################## +# Linux configuration +# +ifneq (,$(filter Linux%, $(UNAME))) + +CFLAGS = -g -Wall -Werror -O0 $(patsubst %, -I%, $(INCDIRS)) +OBJSUFFIX = .o +EXESUFFIX = +#LIBS = -lefence +OBJOPTION = -o +EXEOPTION = -o + +else +######################################################################## +# Darwin configuration +# +ifneq (,$(filter Darwin%, $(UNAME))) + +CFLAGS = -g -Wall -Werror -O2 $(patsubst %, -I%, $(INCDIRS)) +OBJSUFFIX = .o +EXESUFFIX = +OBJOPTION = -o +# The -o in the following line has a space after it, which must not be removed. +EXEOPTION = -o + +else +######################################################################## +# Windows (cygwin but using MS compiler) configuration +# +# this is messy - should probably use vcvars.bat +ifneq (,$(filter CYGWIN%, $(UNAME))) +VISUALSTUDIODIR = $(wildcard /cygdrive/c/Program*Files/Microsoft*Visual*Studio*8) +SDKDIR = $(wildcard /cygdrive/c/Program*Files/Microsoft*SDKs/Windows/*/Lib) +ifeq (,$(VISUALSTUDIODIR)) +VISUALSTUDIODIR = $(wildcard /cygdrive/c/Program\ Files\ */Microsoft*Visual*Studio*10*) +endif +ifeq (,$(VISUALSTUDIODIR)) +VISUALSTUDIODIR = $(wildcard /cygdrive/c/Program\ Files\ */Microsoft*Visual*Studio*11*) +endif +# this is revelvant for vs2012 and windows 8 - sdk location has changed +ifeq (,$(SDKDIR)) +SDKDIR = $(wildcard /cygdrive/c/Program\ Files\ */Windows*Kits) +endif + +ifeq (,$(VISUALSTUDIODIR)) +$(error Could not find MS Visual Studio) +else +WINVISUALSTUDIODIR = $(shell cygpath -w '$(VISUALSTUDIODIR)') +WINSDKDIR = $(shell cygpath -w '$(SDKDIR)') + +#$(error $(VISUALSTUDIODIR)) + +CC = \ + Lib='$(WINVISUALSTUDIODIR)\VC\LIB;$(WINVISUALSTUDIODIR)\VC\PlatformSDK\Lib;$(WINSDKDIR)' \ + PATH='$(VISUALSTUDIODIR)/Common7/IDE:$(VISUALSTUDIODIR)/VC/BIN:$(VISUALSTUDIODIR)/Common7/Tools:$(VISUALSTUDIODIR)/SDK/v2.0/bin:$(VISUALSTUDIODIR)/8.0/Lib/win8/um/x86:'$$PATH \ + Include='$(WINVISUALSTUDIODIR)\VC\INCLUDE;$(WINVISUALSTUDIODIR)\VC\PlatformSDK\Include' \ + cl +endif + +CFLAGS = /nologo /WX /W3 /wd4996 /Zi /O2 $(patsubst %, /I%, $(INCDIRS)) +OBJSUFFIX = .obj +EXESUFFIX = .exe +OBJOPTION = /Fo +EXEOPTION = /Fe + +endif +endif +endif + +######################################################################## +# Common makefile +# +WIDLPROC = $(OBJDIR)/widlproc$(EXESUFFIX) +DTD = $(OBJDIR)/widlprocxml.dtd + +ALL = $(WIDLPROC) $(DTD) +all : $(ALL) + +SRCS = \ + comment.c \ + lex.c \ + main.c \ + misc.c \ + node.c \ + parse.c \ + process.c + +OBJS = $(patsubst %.c, $(OBJDIR)/%$(OBJSUFFIX), $(SRCS)) +$(WIDLPROC) : $(OBJS) + $(CC) $(CFLAGS) $(EXEOPTION)$@ $^ $(LIBS) + +$(OBJDIR)/%$(OBJSUFFIX) : $(SRCDIR)/%.c + mkdir -p $(dir $@) + $(CC) $(CFLAGS) $(OBJOPTION)$@ -c $< + +$(OBJDIR)/%.d : $(SRCDIR)/%.c + mkdir -p $(dir $@) + cc $(patsubst %, -I%, $(INCDIRS)) -MM -MG -MT $(patsubst %.d, %$(OBJSUFFIX), $@) $< | sed '$(patsubst %, s| \(%\)| $(OBJDIR)/\1|;, $(AUTOGENHEADERS))' >$@ + +include $(patsubst %.c, $(OBJDIR)/%.d, $(SRCS)) + + +$(DTD) : $(DOCDIR)/htmltodtd.xsl $(DOCDIR)/widlproc.html + xsltproc -html $^ >$@ + +clean : + rm -f $(ALL) $(OBJS) + +veryclean : + rm -rf $(OBJDIR) + +SVNFILES = $(shell test -d .svn && svn info -R . | sed -n 's/^Path: \(.*\)$$/\1/p') +SVNBRANCH = $(shell test -d .svn && svn info . | sed -n 's|^URL:.*/\([^/]*\)$$|\1|p') +SVNREV = $(shell test -d .svn && svn info -R . | sed -n 's/^Last Changed Rev: \([0-9][0-9]*\)$$/\1/p' | sort -g | tail -1) + +SVNLOG = history +$(SVNLOG) : $(SVNFILES) + svn log -vrHEAD:311 >$@ + +zip : $(OBJDIR)/widlproc-$(SVNBRANCH)$(SVNREV).zip +$(OBJDIR)/widlproc-$(SVNBRANCH)$(SVNREV).zip : $(WIDLPROC) $(DTD) $(DOCDIR)/widlproc.html $(SRCDIR)/widlprocxmltohtml.xsl Makefile $(SVNLOG) + rm -f $@ + zip -j $@ $^ -x Makefile + zip $@ examples/*.widl examples/*.css examples/Makefile examples/README examples/*.xsl examples/*.html + +srczip : widlproc-src-$(SVNBRANCH)$(SVNREV).zip + +widlproc-src-%.zip : $(SVNFILES) $(SVNLOG) + zip $@ $^ + +examples : + $(MAKE) -C examples SRCDIR=../src OBJDIR=../obj EXAMPLESOBJDIR=../obj/examples + +test : $(OBJS) + $(MAKE) -C test SRCDIR=../src OBJDIR=../obj + +.DELETE_ON_ERROR: diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/README.md b/testing/web-platform/tests/resources/webidl2/test/widlproc/README.md new file mode 100644 index 000000000..8ed824e7d --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/README.md @@ -0,0 +1,40 @@ +# Uses + +widlproc can be used to validate WebIDL in W3C specifications. It serves as the basis for the [W3C Web IDL on-line checker](http://www.w3.org/2009/07/webidl-check). + +widlproc's generated XML is used to generate [webinos JavaScript APIs specifications](http://dev.webinos.org/specifications/draft/). + +# License + +widlproc is licensed under the Apache 2 License. + +# Others + +See also [webidl.js](https://github.com/darobin/webidl.js), a JavaScript-based Web IDL parser used by various tools in W3C. + +# Credits + +Most of the work on widlproc was done by Tim Renouf and Paddy Byers. Aplix corporation owns the copyright of the code up to June 2011. + +The tool is kept up to date with the changes in the spec by Dominique Hazael-Massieux, through funding from the [webinos project](http://webinos.org/) since June 2011. + +# Documentation + +See doc/widlproc.html in the tree. + +# Build Instructions + +## Windows + +Install requirements +* Cygwin - must install must install libs/libxslt +* Visual Studio express 2012 or 2010 (see difference below) + +makefile uses cygwin make. References are coded in the make file to detect teh current version of visual studio + +# Future work +windows build could be improved to handle multipe versions with vcvars.bat +http://stackoverflow.com/questions/62029/vs2008-command-prompt-cygwin + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/doc/htmltodtd.xsl b/testing/web-platform/tests/resources/webidl2/test/widlproc/doc/htmltodtd.xsl new file mode 100644 index 000000000..d8b7f5973 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/doc/htmltodtd.xsl @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/doc/widlproc.html b/testing/web-platform/tests/resources/webidl2/test/widlproc/doc/widlproc.html new file mode 100644 index 000000000..4eb42c39b --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/doc/widlproc.html @@ -0,0 +1,1124 @@ + + + + + +widlproc + + + +

widlproc

+ +

Tim Renouf, Aplix Corp

+

$Id$ +

+ +

Introduction

+ +

+widlproc is a processor that accepts as input +Web IDL (the 30 September 2009 editor's draft), +with comments in a subset of the format used by +Doxygen. +The format it accepts is proposed by Aplix for authoring +BONDI interface definitions. +

+ +

+The output of widlproc is an XML representation of the +Web IDL input, +with added XML elements representing the +Doxygen-like comments. +

+ +

Usage

+ +

+widlproc filename +

+ +

+widlproc reads the file named filename, and +sends its XML output format to stdout. +

+ +

Input format

+ +

+The input format accepted by widlproc is +Web IDL +(with an extension used in the +W3C Geolocation API), +with comments in a format reminiscent of that used by +Doxygen. +

+ +

Web IDL extension from W3C geolocation API

+ +

double

+ +

+double is allowed as a DeclarationType or a BoxedType. +

+ +

Doxygen-like comment introduction

+ +

+Only a small subset of Doxygen functionality is supported by +widlproc, plus additions to handle the BONDI concepts of API features +and device capabilities. +

+ +

+In particular, no links are added automatically. (This could be added +in the future.) +

+ +

Doxygen comment block

+ +

Comment referral point

+ +

+Each Doxygen comment block refers to a comment referral +point in the Web IDL, one of +module, interface, exception, const, attribute, operation or argument. +

+ +

Block comment

+ +

+A block comment (delimited by /* */) whose first character +after the /* is ! or a second * +is a Doxygen comment block. +

+ +

+Normally the comment block refers to the next comment referral point in +the Web IDL. +If the first character is <, so the comment block is introduced +with /**< or /*!< , then the comment block +refers back to the previous comment referral point. +

+ +

+The text of the comment block +excludes the initial ! or * (and the < +for a referring back block), +and excludes an initial (after whitespace) * +on each line, +and, when not in a \code block, +excludes any line consisting entirely of whitespace, then * +characters, then whitespace. +

+ +

+widlproc does not support Doxygen commands to force a comment +block to refer to a different referral point. +

+ +

Inline comments

+ +

+The maximal sequence of inline comments (delimited by //) +on adjacent lines, where all of the following conditions hold: +

+
    +
  • +each has a first character after the / of ! or +a third /; +
  • +no comment referral point intervenes; +
  • +either each comment in the sequence starts with a < +(see below), or none does; +
  • +the sequence contains at least two inline comments, or, if only one, +then it starts with < (see below); +
+

+forms a Doxygen comment block. +

+ +

+Normally the comment block refers to the next comment referral point in +the Web IDL. +If the first character of each comment is <, so each +comment in the block is introduced +with ///< or //!< , then the comment block +refers back to the previous comment referral point. +

+ +

+The text of the comment block +excludes the initial ! or / (and the < +for a referring back block) of each inline comment, +and, when not in a \code block, +excludes any line consisting entirely of whitespace, then / +characters, then whitespace. +

+ +

+widlproc does not support Doxygen commands to force a comment +block to refer to a different referral point. +

+ +

Paragraph

+ +

+A comment block is broken into zero or more paragraphs. +One or more blank lines break the paragraphs (unless in a +\code block). +

+ +

+Certain commands (below) also start a new paragraph. +

+ +

+An +HTML block element +is a paragraph. +A blank line (other than in a +\code block) +implicitly closes any open HTML elements, thus ending the paragraph. +

+ +

Doxygen-like commands

+ +

+widlproc supports a small subset of Doxygen commands, plus some additions +to handle BONDI API features and device capabilities. +

+ +

+A command is always introduced with a \ character. +The Doxygen alternative (from JavaDoc) of @ is not +supported. +

+ +

\api-feature

+ +

+Starts a new paragraph. The following word is the name of an API feature +used by the method being documented. The remainder of the paragraph is +any description required of how (eg in what circumstance) the API feature +is used. +

+ +

\name

+ +

+Declares a name for the document node associated with the current referral +point. This is useful for the root document node that otherwise does not have +a WebIDL identifier. +

+ +

\author

+ +

+Starts a new paragraph. The remainder of the paragraph contains +information about a single author of the specification. Multiple +\author commands should be used for multiple authors. +

+ +

+(Here widlproc differs from Doxygen; Doxygen also allows +multiple authors on separate lines to appear in one \author +paragraph.) +

+ +

\b

+ +

+This renders the next word as bold. It is equivalent to enclosing the +next word with <b> </b>. +

+ +

\brief

+ +

+Starts a new paragraph. The remainder of the paragraph contains a brief +description of the entity being documented. +

+ +

\code, \endcode

+ +

+\code +starts a new paragraph which is a code block. The code block +ends at the next \endcode command. +

+ +

+Within the code block, whitespace and newlines are passed verbatim into +the output. +

+ +

\def-api-feature

+ +

+Starts a new paragraph. The following word is the name of the API feature +which is defined here. The description is an def-api-feature block, +consisting of the +remainder of the paragraph, together with +further paragraphs in the same block comment each of which is a plain +paragraph, a paragraph started due to HTML markup, a \brief +paragraph, or a +\device-cap +paragraph. +

+ +

\def-api-feature-set

+ +

+Starts a new paragraph. The following word is the name of the API feature +set which is defined here. The description is an def-api-feature-set block, +consisting of the +remainder of the paragraph, together with +further paragraphs in the same block comment each of which is a plain +paragraph, a paragraph started due to HTML markup, a \brief +paragraph, or a +\api-feature +paragraph. +

+ +

\def-device-cap

+ +

+Starts a new paragraph. The following word is the name of the device capability +which is defined here. The description consists of the +remainder of the paragraph, together with +further paragraphs in the same block comment each of which is a plain +paragraph, a paragraph started due to HTML markup, a \brief +paragraph, or a +\param +paragraph. +

+ +

\def-instantiated

+ +

+Starts a new paragraph. The description is an def-instantiated block, +consisting of the +remainder of the paragraph, together with +further paragraphs in the same block comment each of which is a plain +paragraph, a paragraph started due to HTML markup, a \brief +paragraph, or a +\api-feature +paragraph. +

+ +

\device-cap

+ +

+Starts a new paragraph. +This command can appear only inside an +def-api-feature block. +The following word is the name of a device capability +used by the API feature being documented. +The remainder of the paragraph is +any description required of how (eg in what circumstance) the device capability +is used. +

+ +

\n

+ +

+Creates a line break in the output. +

+ +

\param

+ +

+Starts a new paragraph. This takes the following word as the name of +a parameter (argument) of the entity being documented, then makes the +remainder of the paragraph refer to that parameter. +

+ +

\return

+ +

+Starts a new paragraph. The remainder of the paragraph is made to refer to +the return type of the entity being documented. +

+ +

\throw

+ +

+Starts a new paragraph. The next word is taken to be the name of an +exception thrown by the entity being documented, and the remainder of +the paragraph documents that exception (in the raises list of +an operation, or the setraises +clause of an attribute). +

+ +

\version

+ +

+Starts a new paragraph. The remainder of the paragraph contains +version number information. +

+ +

Escape sequences

+ +

+The following escape sequences are recognized in a comment block: +

+ + + + + + + + + + +
escape sequence +result +
\\ +\ +
\& +& (escaped to &amp; in output XML) +
\$ +$ +
\# +# +
\< +< (escaped to &lt; in output XML) +
\> +> +
\% +% +
+ +

+Some of these escape sequences are used to avoid Doxygen features that +widlproc does not currently implement. In particular, +widlproc insists on a $ being escaped, to +allow for possible future functionality. +

+ +

HTML in comments

+ +

+widlproc accepts a small subset of HTML elements. +

+ +

+An HTML block element is a paragraph. +A blank line (other than in a +\code block) +implicitly closes any open HTML elements, thus ending the paragraph. +

+ +

+The following HTML block elements are accepted: +dl +ol +p +table +ul +

+ +

+The following HTML inline elements are accepted: +a +img +b +br +em +

+ +

+The following HTML elements are accepted where valid inside one of the +other elements: +dd +dt +li +td +th +tr +

+ + +

Output format

+ +

+The output of widlproc is an XML representation of the +Web IDL, +with added XML elements representing the +Doxygen-like comments. +

+ +

Annotated document type declaration

+ +
+<!-- Autogenerated from widlproc.html : do not edit. -->
+
+ +

Entities used elsewhere

+ +
+<!ENTITY % block 'dl | p | table | ul' >
+<!ENTITY % Block '(%block;)*' >
+<!ENTITY % inline 'a | b | br | em | img' >
+<!ENTITY % Inline '(#PCDATA | %inline;)*' >
+<!ENTITY % Flow '(#PCDATA | %inline; | %block;)*' >
+
+<!ELEMENT webidl (#PCDATA | ref)* >
+
+ +

+The <webidl> element contains the literal text of the +original Web IDL that the parent +element was parsed from, minus the comments, with each reference to +an interface name +enclosed in a <ref>..</ref>. +

+ +

Definitions

+ +

+Definitions is the root element of the XML document. +

+ +

+The ExtendedAttributeList specifies any extended attributes +for the Interface, Dictionary, Exception, +Typedef, Valuetype or Const in the +Definition. +

+ +
+<!ELEMENT Definitions ( webidl, descriptive?, (Interface | Dictionary | Callback
+    | Enum | Exception | Typedef | Implements)*) >
+
+ +

Interface

+ +

+An Interface represents an interface. The name +attribute specifies the name of the interface. The descriptive element +provides its documentation if any. +The id attribute specifies the absolute scoped name of the interface. +

+ +

The partial attribute indicates that the definition of the interface complements an existing definition. The callback attribute specificies that a given interface is a callback interface.

+ +

+The InterfaceInheritance element indicates that the interface +inherits from other interface(s). Each Name in the +InterfaceInheritance has a name attribute giving the +scoped name of the interface being inherited from. +

+ +
+<!ELEMENT Interface (webidl, descriptive?, ExtendedAttributeList?,
+        InterfaceInheritance?, (Const | Attribute | Operation | Stringifier* | Serializer* | Iterator | IteratorObject)* ) >
+<!ATTLIST Interface name CDATA #REQUIRED
+                    partial (partial) #IMPLIED
+                    callback (callback) #IMPLIED
+                    id CDATA #REQUIRED >
+
+<!ELEMENT InterfaceInheritance (Name+) >
+
+<!ELEMENT Name EMPTY >
+<!ATTLIST Name name CDATA #REQUIRED >
+
+ +

Dictionary

+ +

+A Dictionary represents a dictionary. The name +attribute specifies the name of the dictionary. The descriptive element +provides its documentation if any. +The id attribute specifies the absolute scoped name of the dictionary. +

+ +

The partial attribute indicates that the definition of the interface complements an existing definition.

+ +

+The DictionaryInheritance element indicates that the dictionary +inherits from other dictionary(s). Each Name in the +DictionaryInheritance has a name attribute giving the +scoped name of the dictionary being inherited from. +

+ + +
+<!ELEMENT Dictionary (webidl, descriptive?, DictionaryInheritance?, DictionaryMember* ) >
+<!ATTLIST Dictionary name CDATA #REQUIRED
+                    partial (partial) #IMPLIED
+                    id CDATA #REQUIRED >
+
+<!ELEMENT DictionaryInheritance (Name+) >
+
+ +

Callback

+ +

+A Callback represents a callback type. The name +attribute specifies the name of the dictionary. The descriptive element +provides its documentation if any.

+ +

The Type element specifies its return type.

+ +

+An Argument is an argument to an operation. +The Type element specifies its type. The name +attribute specifies its name if it has one. +

+ +
+<!ELEMENT Callback (webidl, descriptive?, Type, ArgumentList? ) >
+<!ATTLIST Callback name CDATA #REQUIRED
+                      id CDATA #REQUIRED>
+
+ + +

Enum

+ +

+An Enum represents an enumeration. The name +attribute specifies the name of the enumeration. The descriptive element +provides its documentation if any. +

+ +

+The EnumValue element indicates the values defined for that enumeration in its stringvalue attribute. +

+ + +
+<!ELEMENT Enum (webidl, descriptive?, EnumValue* ) >
+<!ATTLIST Enum name CDATA #REQUIRED 
+                    id CDATA #REQUIRED >
+
+<!ELEMENT EnumValue (webidl, descriptive?) >
+<!ATTLIST EnumValue stringvalue CDATA #REQUIRED >
+
+ + + +

Exception

+ +

+An Exception represents an exception. +The name +attribute specifies the name of the exception. +The descriptive element +provides its documentation if any. +The id attribute specifies the absolute scoped name of the exception. +

+ +

+An ExceptionField represents a field in an exception. +The name +attribute specifies the name of the field. +The Type element specifies its type. +The descriptive> element +provides its documentation if any. +The id attribute specifies the absolute scoped name of the field. +

+ +

+The ExceptionInheritance element indicates that the exception +inherits from another exception. The Name in the +ExceptionInheritance has a name attribute giving the +scoped name of the exception being inherited from. +

+ + +
+<!ELEMENT Exception (webidl, descriptive?, ExtendedAttributeList?, ExceptionInheritance?,
+        (Const | ExceptionField)* ) >
+<!ATTLIST Exception name CDATA #REQUIRED 
+                    id CDATA #REQUIRED >
+
+<!ELEMENT ExceptionInheritance (Name) >
+<!ELEMENT ExceptionField (webidl, descriptive?, ExtendedAttributeList?, (Type)) >
+<!ATTLIST ExceptionField name CDATA #REQUIRED
+                         id CDATA #REQUIRED >
+
+ +

Typedef

+ +

+A Typedef represents a type definition. +The name +attribute specifies the name of the new type. +The Type element specifies it in terms of other types. +The descriptive> element +provides its documentation if any. +The id attribute specifies the absolute scoped name of the typedef. +

+ +
+<!ELEMENT Typedef (webidl, descriptive?, ExtendedAttributeList?, (Type)) >
+<!ATTLIST Typedef name CDATA #REQUIRED
+                  id CDATA #REQUIRED >
+
+ +

Implements

+ +

+An Implements represents Web IDL's +ScopedName implements ScopedName; +syntax. The name1 and name2 attributes give the +first and second scoped names respectively. +The descriptive> element +provides the Implements's documentation if any. +

+ +
+<!ELEMENT Implements (webidl, descriptive?, ExtendedAttributeList?) >
+<!ATTLIST Implements name1 CDATA #REQUIRED
+                     name2 CDATA #REQUIRED >
+
+ +

Const

+ +

+Const represents Web IDL's +const Type identifier = ConstExpr; +syntax. +The Type specifies the constant's type, the +name attribute specifies the constant's name, and the +value attribute specifies its value. +The descriptive> element +provides the Const's documentation if any. +The id attribute specifies the absolute scoped name of the const. +

+ +
+<!ELEMENT Const (webidl, descriptive?, ExtendedAttributeList?, Type) >
+<!ATTLIST Const name CDATA #REQUIRED
+                value CDATA #IMPLIED
+                id CDATA #REQUIRED >
+
+ +

Stringifier

+ +

+A Stringifier represents the Web IDL stringifier; +syntax as an interface member. +The descriptive> element +provides the Stringifier's documentation if any. +

+ +
+<!ELEMENT Stringifier (webidl, descriptive?, ExtendedAttributeList?) >
+
+ +

Attribute

+ +

+An Attribute represents an attribute as an interface member. +The Type element specifies its type. The name +attribute specifies its name. Each of the stringifier, static and +readonly attributes is set to a value the same as the attribute +name when the corresponding keyword appears in the Web IDL input. The inherit attribute is set to inherit when the attribute inherits its getter. +

+ + +

+The descriptive> element provides the attribute's documentation +if any. +The id attribute specifies the absolute scoped name of the attribute. +

+ +
+<!ELEMENT Attribute (webidl, descriptive?, ExtendedAttributeList?, (Type)) >
+<!ATTLIST Attribute stringifier (stringifier) #IMPLIED
+                    readonly (readonly) #IMPLIED
+                    inherit (inherit) #IMPLIED
+                    static (static) #IMPLIED
+                    name CDATA #REQUIRED
+                    id CDATA #REQUIRED >
+
+
+ + +

Operation

+ +

+An Operation represents a method on interface. +The Type element specifies its return type. The name +attribute specifies its name. +

+ +

+Each of the stringifier, static, getter, +setter, creator, deleter and legacycaller, serializer +attributes is set to a value the same as the attribute +name when the corresponding keyword appears in the Web IDL input. +

+ + +

+The descriptive> element provides the attribute's documentation +if any. +The id attribute specifies the absolute scoped name of the operation if it has one. +

+ +

+An Argument is an argument to an operation. +The Type element specifies its type. The name +attribute specifies its name if it has one. +

+ +

+Each of the optional and ellipsis +attributes is set to a value the same as the attribute +name when the corresponding syntax appears in the Web IDL input. +

+ +

The +value attribute used on optional arguments specifies default value for non-string values, and stringvalue for string values.

+ + +
+<!ELEMENT Operation (webidl, descriptive?, ExtendedAttributeList?,
+        (Type), ArgumentList) >
+<!ATTLIST Operation stringifier (stringifier) #IMPLIED
+                    static (static) #IMPLIED
+                    getter (getter) #IMPLIED
+                    setter (setter) #IMPLIED
+                    creator (creator) #IMPLIED
+                    deleter (deleter) #IMPLIED
+                    serializer (serializer) #IMPLIED
+                    legacycaller (legacycaller) #IMPLIED
+                    name NMTOKEN #IMPLIED
+                    id NMTOKEN #IMPLIED >
+
+
+<!ELEMENT ArgumentList (Argument*) >
+
+<!ELEMENT Argument (descriptive?, ExtendedAttributeList?, (Type)) >
+<!ATTLIST Argument
+                   optional (optional) #IMPLIED
+                   ellipsis (ellipsis) #IMPLIED
+                value CDATA #IMPLIED
+                stringvalue CDATA #IMPLIED
+                   name NMTOKEN #REQUIRED >
+
+ +

Serializer

+

A Serializer represents a serializer for an interface, either defined in the prose or via a pattern.

+ +

The descriptive element provides the serializer's documentation if any.

+ + +

The attribute attribute defines the attribute that is used for serialization if any.

+ +

The optional Map and List elements describe the pattern (if any) for the serializer. They take PatternAttribute elements with a name attribute that describes the attributes used for serialization.

+ +

Map elements take a pattern attribute that can be set to either "getter" (if the getter is used for serialization), "all" if all serializable attributes are to be used, or "selection" if the attributes named as children elements are to be used. Optionally, they take a inherit attribute set to "inherit" if the serialization takes also into account inherited attributes.

+ +

List elements take a pattern attribute that can be set to either "getter" (if the getter is used for serialization), or "selection" if the attributes named as children elements are to be used.

+ +
+<!ELEMENT Serializer (webidl, descriptive?, ExtendedAttributeList?, (Map | List)?) >
+<!ATTLIST Serializer attribute CDATA #IMPLIED >
+
+<!ELEMENT Map  ((PatternAttribute*)) >
+
+<!ATTLIST Map inherit (inherit) #IMPLIED
+                 pattern (getter|all|selection) #REQUIRED>
+
+<!ELEMENT List  ((PatternAttribute*)) >
+
+<!ATTLIST List pattern (getter|selection) #REQUIRED>
+
+<!ELEMENT PatternAttribute EMPTY>
+<!ATTLIST PatternAttribute name CDATA #REQUIRED>
+
+
+ +

Iterator

+

An Iterator element defines whether the interface has a custom iterator; the type of the iterated objects is defined in the Type child. If that interator implements a particular interface, the name of that interface is set in the interface attribute.

+
+<!ELEMENT Iterator (webidl, descriptive?, ExtendedAttributeList?, Type) >
+<!ATTLIST Iterator interface CDATA #IMPLIED>
+
+ +

IteratorObject

+

An IteratorObject element denotes that the interface serves as an iterator object interface; the type of the iterated objects is defined in the Type child.

+ +
+<!ELEMENT IteratorObject (webidl, descriptive?, ExtendedAttributeList?, Type) >
+
+ + +

DictionaryMember

+ +

+A DictionaryMember represents a member of a dictionary. +The Type element specifies its type. The name +attribute specifies its name. +

+ +

+The descriptive> element provides the dictionary member's documentation +if any. +The id attribute specifies the absolute scoped name of the attribute. +

+ +

The +value attribute specifies its value for non-string values, and stringvalue for string values.

+ +
+<!ELEMENT DictionaryMember (webidl, descriptive?, ExtendedAttributeList?, Type) >
+<!ATTLIST DictionaryMember name CDATA #REQUIRED
+                    id CDATA #REQUIRED
+                value CDATA #IMPLIED
+                stringvalue CDATA #IMPLIED >
+
+
+ + +

Extended attributes

+ +

+An ExtendedAttributeList contains one or more +ExtendedAttribute element. Each ExtendedAttribute +has: +

+
    +
  • +a name attribute giving the name of the extended attribute; +
  • +if the extended attribute contains an = sign followed by a +value, a value attribute giving the value, which is a scoped +name or an identifier; +
  • +if the extended attribute contains parentheses (either with or without +an = sign), an ArgumentList element giving the +contents of the parentheses. +
+

+If the value attribute and the ArgumentList element are +both present, then value must give an identifier rather than +a scoped name. +

+ +
+<!ELEMENT ExtendedAttributeList (ExtendedAttribute+) >
+
+<!ELEMENT ExtendedAttribute (webidl, ArgumentList?) >
+<!ATTLIST ExtendedAttribute name NMTOKEN #REQUIRED
+                            value CDATA #IMPLIED >
+
+ +

Type

+ +

+Type represents a type. It has one of these forms: +

+
    +
  • +The any, object and void +types have the attribute +type set to the type, and no other attributes or elements. +Note that the void type appears only when the Type +element is a child of Operation. +
  • +A type that is an interface has the attribute name set to the +name of that interface, and no other attributes or elements. +
  • +For the primitive types short, unsigned short, +long, unsigned long, long long, +unsigned long long, float, double, +boolean, octet, byte and DOMString, +there is an attribute type +whose value is one of those strings, and no other attributes or elements. +However, if the type was specified in the Web IDL with a trailing ? +sign, then there is an attribute nullable with the value +nullable. +
+

+The restrictions on which combinations of elements and attributes are +permitted are not encoded by the DTD. +

+

+The descriptive element provides the documentation +if any, when the Type is a child of Operation, and thus +representing an operation's return type. +

+ +

The ExtendedAttributeList element provides the optional extended attributes that can be defined for a type through typedef, à la typedef [Clamp] octet Value;.

+ + +
+<!ELEMENT Type (descriptive?, ExtendedAttributeList?, Type*) >
+<!ATTLIST Type type CDATA #IMPLIED
+               name NMTOKEN #IMPLIED
+               nullable (nullable) #IMPLIED >
+
+ +

Sequence

+ +

For a sequence type, the Type element with an attribute type set to sequence contains an element Type giving the sequence element type, and no other attributes or elements. If the sequence is specified in the Web IDL with a trailing ? +sign, then there is an attribute nullable with the value +nullable. + + +

Array

+ +

For an array type, the Type element with an attribute type set to array contains an element Type giving the array element type. If the array is specified in the Web IDL with a trailing ? +sign, then there is an attribute nullable with the value +nullable. + +

Union

+ +

For a union type, the Type element with an attribute type set to union contains at least two element Type giving the union members type. If the union is specified in the Web IDL with a trailing ? +sign, then there is an attribute nullable with the value +nullable. + + + +

Descriptive elements

+ +

+The following elements contain documentation, extracted from the +Doxygen-like comments in the input. <param> +derives only from a \param command used inside a +\def-device-cap block; any other \param command +is linked to a parameter (argument) of the method being documented. +

+ +
+<!ELEMENT descriptive (description | brief | throw | author
+    | version | Code | api-feature | device-cap | def-api-feature
+    | def-api-feature-set | def-device-cap | def-instantiated | param)* >
+
+<!ELEMENT description %Block; >
+
+<!ELEMENT brief %Inline; >
+
+<!ELEMENT throw %Inline; >
+
+<!ELEMENT author %Inline; >
+
+<!ELEMENT version %Inline; >
+
+<!ELEMENT Code %Inline; >
+
+<!ELEMENT api-feature %Inline; >
+<!ATTLIST api-feature identifier CDATA #REQUIRED >
+
+<!ELEMENT device-cap %Inline; >
+<!ATTLIST device-cap identifier CDATA #REQUIRED >
+
+<!ELEMENT param %Inline; >
+<!ATTLIST param identifier CDATA #REQUIRED >
+
+<!ELEMENT def-api-feature (descriptive?) >
+<!ATTLIST def-api-feature identifier CDATA #REQUIRED >
+
+<!ELEMENT def-api-feature-set (descriptive?) >
+<!ATTLIST def-api-feature-set identifier CDATA #REQUIRED >
+
+<!ELEMENT def-instantiated (descriptive?) >
+
+<!ELEMENT def-device-cap (descriptive?) >
+<!ATTLIST def-device-cap identifier CDATA #REQUIRED >
+
+<!ELEMENT ref (#PCDATA) >
+
+ +

XHTML elements

+ +

+The following XHTML elements are part of widlprocxml: +

+ +
+<!ELEMENT a %Inline; >
+<!ATTLIST a href CDATA #REQUIRED >
+
+<!ELEMENT b %Inline; >
+
+<!ELEMENT br EMPTY >
+
+<!ELEMENT dd %Flow; >
+
+<!ELEMENT dl ((dt | dd)*) >
+
+<!ELEMENT dt %Inline; >
+
+<!ELEMENT em %Inline; >
+
+<!ELEMENT img %Inline; >
+<!ATTLIST img src CDATA #REQUIRED 
+                 alt CDATA #IMPLIED>
+
+
+<!ELEMENT li %Flow; >
+
+<!ELEMENT p %Inline; >
+
+<!ELEMENT table (tr*) >
+
+<!ELEMENT td %Flow; >
+
+<!ELEMENT th %Flow; >
+
+<!ELEMENT tr ((th | td)*) >
+
+<!ELEMENT ul (li*) >
+
+ + +

Bibliography

+ +

+BONDI - an open source industry collaboration for widget and web technologies, +http://bondi.omtp.org/ +

+ +

+Doxygen Source code documentation generator tool, + +http://www.stack.nl/~dimitri/doxygen/index.html +

+ +

+W3C Geolocation API Specification Editor's Draft 3 April 2009, + +http://dev.w3.org/geo/api/spec-source.html +

+ +

+Web IDL W3C Editor's Draft 3 May 2011, +http://dev.w3.org/2006/webapi/WebIDL +

+ diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/examples/Makefile b/testing/web-platform/tests/resources/webidl2/test/widlproc/examples/Makefile new file mode 100644 index 000000000..614453d23 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/examples/Makefile @@ -0,0 +1,79 @@ +######################################################################## +# $Id$ +# Copyright 2009 Aplix Corporation. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +######################################################################## + +UNAME = $(shell uname) +EXAMPLESDIR = . +# The settings of SRCDIR (where to find the xsl style sheets), OBJDIR (where to +# find widlproc and widlprocxml.dtd) and EXAMPLESOBJDIR (where to put the +# resulting html files and any intermediate files) reflect the directory +# structure of the released widlproc.zip file when unzipped. ../Makefile calls +# this Makefile with these settings overridden to reflect the directory +# structure in svn. +SRCDIR = .. +OBJDIR = .. +EXAMPLESOBJDIR = obj + +######################################################################## +# Linux configuration +# +ifneq (,$(filter Linux%, $(UNAME))) + +EXESUFFIX = + +else +######################################################################## +# Darwin configuration +# +ifneq (,$(filter Darwin%, $(UNAME))) + +EXESUFFIX = + +else +######################################################################## +# Windows (cygwin but using MS compiler) configuration +# +ifneq (,$(filter CYGWIN%, $(UNAME))) + +EXESUFFIX = .exe + +endif +endif +endif + +######################################################################## +# Common makefile +# +WIDLPROC = $(OBJDIR)/widlproc$(EXESUFFIX) +DTD = $(OBJDIR)/widlprocxml.dtd + +WIDLS = $(patsubst $(EXAMPLESDIR)/%, %, $(wildcard $(EXAMPLESDIR)/*.widl)) + +test : $(patsubst %.widl, $(EXAMPLESOBJDIR)/%.html, $(WIDLS)) $(EXAMPLESOBJDIR)/widlhtml.css + @echo "$@ pass" + +$(EXAMPLESOBJDIR)/%.html : $(EXAMPLESOBJDIR)/%.widlprocxml $(SRCDIR)/widlprocxmltohtml.xsl Makefile + cp $(SRCDIR)/widlprocxmltohtml.xsl $(dir $@)/ + xsltproc $(dir $@)/widlprocxmltohtml.xsl $< >$@ + +$(EXAMPLESOBJDIR)/%.widlprocxml : $(EXAMPLESDIR)/%.widl $(WIDLPROC) $(DTD) Makefile + mkdir -p $(dir $@) + $(WIDLPROC) $< >$@ + cp $(OBJDIR)/widlprocxml.dtd $(dir $@)/ + xmllint --noout --dtdvalid $(DTD) $@ + +$(EXAMPLESOBJDIR)/widlhtml.css : $(EXAMPLESDIR)/widlhtml.css + cp $< $@ + +.DELETE_ON_ERROR: + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/examples/README b/testing/web-platform/tests/resources/webidl2/test/widlproc/examples/README new file mode 100644 index 000000000..efbb72dda --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/examples/README @@ -0,0 +1,41 @@ +######################################################################## +# $Id$ +# Copyright 2009 Aplix Corporation. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +######################################################################## + +This examples directory contains two of the BONDI .widl files, a Makefile +that processes them to generate html, and a .css file that the resulting +html uses. + +The Makefile processes the .widl files as follows: + + 1. For each .widl, generate the .widlprocxml file (an XML representation + of the information in the .widl) using widlproc. + + 2. Validate (using xmllint) each .widlprocxml against the DTD. + + 3. We want any reference in the resulting html to a type elsewhere in the + API to be a link. This is where we achieve this. First generate a + list of fqids (fully qualified identifiers) from fqid attributes in + the XML by running all .widlprocxml files through the style sheet + widlprocxmlfqids.xsl. + + 4. Turn that list of fqids into a sed script that turns a to an + fqid into a to the fqid in the right .html file. + + 5. For each .widlprocxml file, generate a .widlprocxml2 file by running + it through the sed script generated above. + + 6. For each .widlprocxml2 file, generate a .html file by running it through + the widlprocxmltohtml.xsl style sheet. + +See the Makefile for details. diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/examples/bondi.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/examples/bondi.widl new file mode 100644 index 000000000..200b95fe9 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/examples/bondi.widl @@ -0,0 +1,227 @@ +/* + * Licensed to OMTP Ltd. (OMTP) under one or more contributor license agreements. + * See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. + * + * The Reference Implementation (save for such parts of the reference implementation made + * available under separate terms and conditions) is made available under the terms of the + * Apache License, version 2.0, subject to the condition that any "Works" and "Derivative + * Works" used or distributed for commercial purposes must be and remain compliant with the + * BONDI specification as promulgated by OMTP in each release. Your implementation of the + * Reference Implementation (whether object or source) must maintain these conditions, and + * you must notify any recipient of this condition in a conspicuous way. + * + * You may not use this BONDI Reference Implementation except in compliance with the License. + * + * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 or at + * http://bondi.omtp.org/BONDI-LICENSE-2.0 + */ + +/** + * \brief Common BONDI functionality. + * + * These definitions can be used in all other BONDI modules as dependencies. + * \version 1.1 + */ +module bondi { + + /** + * \brief Array of DOMStrings. + */ + typedef sequence StringArray; + + /** + * \brief Array of 8-bit unsigned integer values. + */ + typedef sequence ByteArray; + + /** + * \brief Array of 16-bit signed integer values. + */ + typedef sequence ShortArray; + + /** + * \brief Array of 32-bit signed integer values. + */ + typedef sequence LongArray; + + /** + * \brief Array of floating point values. + */ + typedef sequence FloatArray; + + /** + * \brief Generic Map object. + */ + typedef Object Map; + + /** + * \brief Generic success callback interface. + */ + [Callback=FunctionOnly, NoInterfaceObject] interface SuccessCallback { + /** + * \brief Method invoked when the asynchronous call completes successfully + */ + void onSuccess(); + }; + + + /** + * \brief Success callback interface for requestFeature invocations + */ + [Callback=FunctionOnly, NoInterfaceObject] interface RequestFeatureSuccessCallback { + /** + * \brief Method invoked upon a succesful requestFeature invocation + * + * \param ob Object implementing the JavaScript API associated with the requested Feature. + */ + void onSuccess(in Object ob); + }; + + + /** + * \brief Generic error callback interface. + */ + [Callback=FunctionOnly, NoInterfaceObject] interface ErrorCallback { + /** + * \brief Method invoked when an error occurs + * + * \param error The error that is raised. + */ + void onError(in GenericError error); + }; + + /** + * \brief Generic error interface. + * + * + */ + + + interface GenericError { + + /** + * \brief 16-bit error code. + */ + readonly attribute unsigned short code; + }; + + /** + * \brief DeviceApiError error interface. + * + * The error codes must be in the range 10000-19999. + */ + + interface DeviceAPIError : GenericError { + + /** + * \brief Unknown error. + */ + const unsigned short UNKNOWN_ERROR = 10000; + + /** + * \brief Invalid value was specified as input parameter. + */ + const unsigned short INVALID_ARGUMENT_ERROR = 10001; + + /** + * \brief The searched value or object was not found. + */ + const unsigned short NOT_FOUND_ERROR = 10002; + + /** + * \brief Operation is pending. + */ + const unsigned short PENDING_OPERATION_ERROR = 10003; + + /** + * \brief Input/Output error. + */ + const unsigned short IO_ERROR = 10004; + + /** + * \brief Not supported error. + */ + const unsigned short NOT_SUPPORTED_ERROR = 10005; + }; + + /** + * \brief Security error interface. + * + * The error codes must be in the range 20000-29999 + */ + interface SecurityError : GenericError { + const unsigned short PERMISSION_DENIED_ERROR = 20000; + }; + + /** + * \brief PendingOperation. + * + * Interface that is returned by asynchronous operations in order to + * provide a cancellation operation. + */ + interface PendingOperation { + /** + * \brief Call to cancel the underlying asynchronous operation. + * + * This call is always successful, i.e. the pending operation i.e. + * either cancelled or one of the callback is called. + * + * \return false if the cancellation did not succeed + * either because the pending operation finished already or because + * the cancellation cannot succeed due to technical limitations in + * the underlying implementation. Consquently the pending operation + * completes and depending on the success or failure the appropriate + * callbacks will be called. + * true if the cancellation did succeed. No callbacks will + * be called by the cancelled pending operation. + */ + boolean cancel(); + }; + + /** + * \brief BONDI root API. + * bondi root property exists in the global object + * \def-api-feature http://bondi.omtp.org/api/bondi.requestfeature + */ + interface Bondi { + /** + * \brief Requests a feature. + * + * This function requests a named feature + * asynchronously and returns a pending operation object. + * If it succeeds it calls the successCallback and passes in + * the object of the requested feature. If it fails it calls + * the errorCallback passing in a DeviceAPIError which provides + * an error message and error code indicating the nature of the error. + * + * If the requested feature binds itself to a root namespace + * ( for example, "bondi.pim.contact") this will happen prior to the + * successCallback being invoked. + * + * \param successCallback the success callback function + * \param errorCallback the error callback function + * \param name the feature name IRI + * + * \return PendingOperation enabling the requester to cancel this request. + * + * The errorCallback will receive one of the following errors: + * \throw DeviceAPIError INVALID_ARGUMENT_ERROR if a malformed + * argument has been supplied or a required argument has been omitted. + * \throw DeviceAPIError NOT_FOUND_ERROR if the requested feature could not be found. + * \throw SecurityError PERMISSION_DENIED_ERROR if the + * requested feature is not permitted to load/bind or that + * access to a required device capability has been denied. + * \throw DeviceAPIError UNKNOWN_ERROR if an error occurred and a pending + * operation object can't be returned. + */ + PendingOperation requestFeature(in RequestFeatureSuccessCallback successCallback, + in ErrorCallback errorCallback, + in DOMString name) + raises(DeviceAPIError, SecurityError); + }; + interface BondiObject { + readonly attribute Bondi bondi; + }; + Window implements bondiObject; +}; diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/examples/filesystem.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/examples/filesystem.widl new file mode 100644 index 000000000..35f602b85 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/examples/filesystem.widl @@ -0,0 +1,1038 @@ +/* + * Licensed to OMTP Ltd. (OMTP) under one or more contributor license agreements. + * See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. + * + * The Reference Implementation (save for such parts of the reference implementation made + * available under separate terms and conditions) is made available under the terms of the + * Apache License, version 2.0, subject to the condition that any "Works" and "Derivative + * Works" used or distributed for commercial purposes must be and remain compliant with the + * BONDI specification as promulgated by OMTP in each release. Your implementation of the + * Reference Implementation (whether object or source) must maintain these conditions, and + * you must notify any recipient of this condition in a conspicuous way. + * + * You may not use this BONDI Reference Implementation except in compliance with the License. + * + * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 or at + * http://bondi.omtp.org/BONDI-LICENSE-2.0 + */ + +/** + * \brief BONDI filesystem API. + * + * The BONDI filesystem API provides access to the filesystem of a device. The + * filesystem is abstractly represented as a collection of disjoint filesystem + * root locations each corresponding to some specific location in the device + * filesystem. The filesystem API exposes the hierarchies below these root + * locations as a single virtual filesystem but provides no access to other + * parts of the device filesystem. + * + * The roots that are exposed are determined by the platform also by the + * context in which the filesystem API is invoked. + * + * Each root has a string name. Each file or directory within the virtual + * filesystem is addressed using a fully-qualified path of the form: + * <root name>/<path> where <rootname> is + * the name of the root and <path> is the path to the file or + * directory relative to that root. + * + * The list of the supported root locations can be retrieved by calling + * filesystem.getRootLocations(). + * + * The default location for a specific type of file, if one exists, can be + * obtained by calling the filesystem.getDefaultLocation(...) method. A set of + * platform-independent symbolic names for media types is defined. The default + * location for a given file type may itself be a root, or some subdirectory of + * a root. Although the set of roots available on a device is + * platform-dependent, the getDefaultLocation(...) functionality can be used to + * ensure that web applications can be written in a platform-independent way. + * + * In order to access specific locations which are prefixed with a value + * retrieved by filesystem.getDefaultLocation or some root location returned by + * filesystem.getRootLocations a File handle must be retrieved using the + * filesystem.resolve call. + * + * A File handle represents either a file or a directory. If it is a file the + * isFile attribute will be true, otherwise the isDirectory attribute + * will be true. A file can be opened for reading and writing, using a + * FileStream handle. A directory can be used to list its contents which is a + * list of files and sub-directories. There is a resolve method on directories + * as well in order to resolve files or sub-directories more conveniently than + * processing directory listings. + * + * The "/" character is used as the (path) component separator. + * The use of "." or ".." in location components is not required to be + * supported. + * + * All path characters need to be UTF-8 encoded. + * + * \code + * function errorCB(err) { + * alert("BONDI filesystem API couldn't be requested: " + err.message); + * } + * + * function successCB() { + * var docLocation = bondi.filesystem.getDefaultLocation("documents"); + * var docDir = bondi.filesystem.resolve(docLocation); + * var docFiles = docDir.listFiles(); + * for(var i = 0; i < docFiles.length; i++) { + * // displays name of each image file in image directory + * alert(docFiles[i].name); + * } + * var testFile = docDir.createFile("test.txt"); + * var out = testFile.open("w", "UTF-8"); + * // writes Hello World to test.txt + * out.write("Hello World"); + * out.close(); + * } + * + * bondi.requestFeature(successCB, errorCB, "filesystem"); + * \endcode + * + * \def-api-feature http://bondi.omtp.org/api/filesystem.read + * \brief Filesystem read operations, including reading directory listings, + * file contents and resolving root locations. + * \device-cap io.file.read + * + * \def-api-feature http://bondi.omtp.org/api/filesystem.write + * \brief Filesystem write operations, including creating files/directories, + * writing to files, deleting files/directories, moving and copying + * files. + * \device-cap io.file.write + * + * \def-api-feature-set http://bondi.omtp.org/api/filesystem + * \brief All the FileSystem features + * \api-feature http://bondi.omtp.org/api/filesystem.read + * \api-feature http://bondi.omtp.org/api/filesystem.write + * + * \def-device-cap io.file.read + * \brief Read directory or file + * \param name Name of directory or file, in virtual filesystem, + * e.g. rootlocation/filename + * + * \def-device-cap io.file.write + * \brief Write directory or file + * \param name Name of directory or file, in virtual filesystem, + * e.g. rootlocation/filename + * + * \author Paddy Byers <paddy@aplixcorp.com> + * \author Anselm R Garbe <anselm@aplixcorp.com> + * \version 1.1 + */ +module filesystem { + + /** + * \brief Array of File handles. + * + * This array type is returned when directory listings are requested. + */ + typedef sequence FileArray; + + /** + * \brief File system specific success callback. + * + * This callback interface specifies a success callback with a function + * taking a File object as input argument. It is used in asynchronous + * operations such as copying, moving and deleting files. + */ + [Callback=FunctionOnly, NoInterfaceObject] interface FileSystemSuccessCallback { + /** + * \brief Method invoked when the asynchronous call completes succesfully + * + * \param file The file resulting from the asynchronous call + */ + void onSuccess(in File file); + }; + + /** + * \brief Manager class exposed as the filesystem modules API. + * + * This manager class exposes the filesystem base API, such as + * determining root and default locations, resolving a given location + * into a File Handle and registering filesystem listeners for + * filesystem events. + * + * \code + * function errorCB(err) { + * alert("BONDI filesystem API couldn't be requested: " + err.message); + * } + * + * function successCB() { + * var docLocation = bondi.filesystem.getDefaultLocation("documents"); + * var docDir = bondi.filesystem.resolve(docLocation); + * var docFiles = docDir.listFiles(); + * for(var i = 0; i < docFiles.length; i++) { + * // displays name of each image file in image directory + * alert(docFiles[i].name); + * } + * var testFile = docDir.createFile("test.txt"); + * var out = testFile.open("w", "UTF-8"); + * // writes Hello World to test.txt + * out.write("Hello World"); + * out.close(); + * } + * + * bondi.requestFeature(successCB, errorCB, "filesystem"); + * \endcode + */ + interface FileSystemManager { + + /** + * \brief Contains the platform-dependent maximum path length. + * + * Read-only. + * + * \code + * alert(bondi.filesystem.maxPathLength); + * \endcode + */ + readonly attribute unsigned long maxPathLength; + + /** + * \brief Returns a default location path for the given arguments, + * including the root location prefix. + * + * Optionally this method can be called with the space argument + * specifying the minimum free disk space required. + * + * This function resolves location specifiers to location paths. + * The following location specifiers are supported: + * \n "wgt:package" the widget package location + * \n "wgt:private" the widgets private storage + * \n "wgt:public" the widgets public storage + * \n "wgt:temp" the widgets temporary storage + * \n "documents" the documents location, + * e.g. the "My Documents" directory on some systems + * \n "images" the images location, + * e.g. the "My Pictures" directory on some systems + * \n "videos" the videos location, + * e.g. the "My Videos" directory on some systems + * \n "temp" the temporary storage, + * e.g resolving to "Temp" + * \n "sdcard" the sdcard storage, if any + * + * \code + * var wgtLocation = bondi.filesystem.getDefaultLocation('wgt:package'); + * \endcode + * + * \param specifier the location specifier, see above for supported specifiers. + * \param minFreeSpace optional, minimum required free disk space in bytes for + * this location, 0 (default) means no limitation + * \return the location as a string or null if there + * is no location for the given specifier or if there is not + * enough space left for the requested space in bytes. + * \throw DeviceAPIError INVALID_ARGUMENT_ERROR if the + * specifier or space arguments are invalid + */ + DOMString getDefaultLocation(in DOMString specifier, in unsigned long minFreeSpace) + raises(DeviceAPIError); + + /** + * \brief Returns all root locations. + * + * The root locations are symbolic names for filesystem + * locations which are accessible and supported by the + * underlying platform. + * + * Usually the following root locations will be supported: + * \n "documents" represents "My Documents" on some platforms + * \n "images" represents "My Pictures" on some platforms + * \n "videos" represents "My Videos" on some platforms + * \n "temp" represents "tmp" on some platforms + * \n "sdcard" represents the sdcard on some platforms + * + * See also the getDefaultLocation method. + * + * \code + * var locations = bondi.filesystem.getRootLocations(); + * for(var i = 0; i < locations.length; i++) { + * // locations[i] is a resolvable root location + * } + * \endcode + * + * \return string array of root locations. + */ + StringArray getRootLocations(); + + /** + * \brief Resolves a location to a File handle. + * + * Validates and resolves the given location to a File handle + * and returns a handle. A valid location is prefixed with a + * valid root or default location and must address an existing + * and accessible file. + * + * \api-feature http://bondi.omtp.org/api/filesystem.read + * + * \code + * var location = bondi.filesystem.getDefaultLocation("temp"); + * var temp = bondi.filesystem.resolve(location); + * var documents = bondi.filesystem.getDefaultLocation("documents"); + * var mydoc = bondi.filesystem.resolve(documents + "/data/2009/mydoc.txt"); + * \endcode + * + * \param location the location to resolve. Must be absolute + * prefixed by a valid root or default location. + * \return the resolved file object. + * \throw SecurityError PERMISSION_DENIED_ERROR when + * access is denied by the security policy. + * \throw DeviceAPIError INVALID_ARGUMENT_ERROR if invalid location was given. + */ + File resolve(in DOMString location) + raises(SecurityError, DeviceAPIError); + + /** + * \brief Registers a filesystem event listener. + * + * Filesystem event listeners are used in order to retrieve + * notifications if root or default locations such as storage + * cards are mounted/unmounted into/from the device filesystem. + * + * \api-feature http://bondi.omtp.org/api/filesystem.read + * + * \code + * var listener = { mountEvent: function(location) { alert('mounted ' + location); }, + * unmountEvent: function(location) { alert('unmounted ' + location); }; + * bondi.filesystem.registerEventListener(listener); + * \endcode + * + * \param listener the listener interface implementation + * \throw DeviceAPIError INVALID_ARGUMENT_ERROR if the given listener + * is invalid or not a listener. + */ + void registerEventListener(in FileSystemListener listener) + raises(DeviceAPIError); + + /** + * \brief Unregisters a filesystem event listener. + * + * \code + * bondi.filesystem.unregisterEventListener(listener); + * \endcode + * + * \param listener the listener interface implementation + * \throw DeviceAPIError INVALID_ARGUMENT_ERROR if the given listener + * is invalid or not a listener. + */ + void unregisterEventListener(in FileSystemListener listener) + raises(DeviceAPIError); + }; + + /** + * \brief Filesystem event listener class. + * + * This listener implements two methods to retrieve mount and unmount + * notifications if root or default locations on a storage card get + * available or unavailable. + * + * \code + * var fsEventImpl = { + * mountEvent: function(location) { + * // location has been mounted + * }, + * unmountEvent: function(location) { + * // location has been unmounted + * } + * }; + * \endcode + */ + interface FileSystemListener { + + /** + * \brief Called when a new root location gets available. + * + * A new location could be a storage card for example. + * + * \param location the newly available location + */ + void mountEvent(in DOMString location); + + /** + * \brief Called when a location gets unavailable. + * + * Such a location could be a storage card for example. + * + * \param location the location which is becoming unavailable + */ + void unmountEvent(in DOMString location); + }; + + /** + * \brief File class. + * + * This interface represents the file abstraction in use. A file handle + * can address files or directories. A file handle represents a file + * if the isFile property is true, otherwise it represents a + * directory. + * + * A file handle representing a file can be opened for I/O operations + * such as reading and writing. + * + * A file handle representing a directory can list all files in the + * current directory. + * + * \code + * + * // list directory contents + * var files = dir.listFiles(); + * for(var i = 0; i < files.length; i++) { + * // alerts each name of dir's contents + * alert(files[i].name); + * } + * + * // opens a file for writing + * var file = dir.createFile("test.txt"); + * var out = file.open("w", "UTF-8"); + * // writes Hello World to test.txt + * out.write("Hello World"); + * out.close(); + * \endcode + */ + interface File { + + /** + * \brief Parent directory handle. + * + * Read-only. + * + * null if there is no parent directory. + * + * If there is no parent directory, this represents a root location. + * + * \code + * var parent = file.parent; + * if(parent != null) { + * // parent directory handle + * } + * \endcode + */ + readonly attribute File parent; + + /** + * \brief File/directory access state in the filesystem. + * + * Read-only. + * + * false if there is write access. + * + * This attribute represents the actual state of a + * file/directory in the filesystem. It does not check if the + * accessor has io.file.write permission. + * + * \code + * if(file.readOnly) { + * // file cannot be written + * } + * \endcode + */ + readonly attribute boolean readOnly; + + /** + * \brief File type. + * + * Read-only. + * + * true if this handle is a file. + * false if this handle is a directory. + * + * \code + * if(file.isFile) { + * // is a file + * } + * \endcode + */ + readonly attribute boolean isFile; + + /** + * \brief File type. + * + * Read-only. + * + * true if this handle is a directory. + * false if this handle is a file. + * + * \code + * if(file.isDirectory) { + * // is a directory + * } + * \endcode + */ + readonly attribute boolean isDirectory; + + /** + * \brief Creation timestamp. + * + * Read-only. + * + * The creation timestamp of this file. This is the timestamp + * when the file was first created in the filesystem. This is + * equivalent to the timestamp when a call to createFile() + * succeeds. + * + * It is unspecified and platform-dependent if the creation + * timestamp changes when a file is moved. + * + * \code + * alert(file.created); // displays the creation timestamp + * \endcode + * + */ + readonly attribute Date created; + + /** + * \brief Modification timestamp. + * + * Read-only. + * + * The modification timestamp of this file. This is the timestamp + * of the most recent modification to the file, usually when the last + * write operation succeeded. Opening a file for reading does not change + * the modification timestamp. + * + * \code + * alert(file.modified); // displays the modification timestamp + * \endcode + * + */ + readonly attribute Date modified; + + /** + * \brief Path of this file, excluding the file name. + * + * Read-only. + * + * If the file path is /baz/foo.bar, then + * the path is /baz/. + * + * The encoding of file paths is UTF-8. + * + * \code + * alert(file.path); // should be /baz/ if the file is /baz/foo.bar + * \endcode + */ + readonly attribute DOMString path; + + /** + * \brief File name, excluding any path components. + * + * Read-only. + * + * Assumed the file path is /baz/foo.bar, then + * the file name is foo.bar. + * + * The encoding of file names is UTF-8. + * + * \code + * alert(file.name); // should be foo.bar if the file path is /baz/foo.bar + * \endcode + */ + readonly attribute DOMString name; + + /** + * \brief Absolute path of this file. + * + * Read-only. + * + * Assumed the file path is /baz/foo.bar, then this is the absolute path. + * + * The encoding of file paths is UTF-8. + * + * \code + * alert(file.absolutePath); // should be /baz/foo.bar if the file is /baz/foo.bar + * \endcode + */ + readonly attribute DOMString absolutePath; + + /** + * \brief Size in bytes of this file. + * + * Read-only. + * + * If it is attempted to read this attribute on a directory, + * undefined is returned. + * + * \code + * alert(file.fileSize); // displays the file size + * \endcode + */ + readonly attribute unsigned long fileSize; + + /** + * \brief Files metadata. + * + * The actual map contents are implementation dependent. + * + * \code + * // should display the file author, if supported by the + * // platform, undefined otherwise + * alert(file.metadata.author); + * \endcode + */ + readonly attribute Map metadata; + + /** + * \brief Returns list of all files of this directory. + * + * The list of files contains directories and files, it does + * not contain the directories "." and "..". + * + * \api-feature http://bondi.omtp.org/api/filesystem.read + * + * \code + * var files = dir.listFiles(); + * for(var i = 0; i < files.length; i++) { + * // files[i] iterate over all files of this directory + * } + * \endcode + * + * \return array of contents of this directory. + * \throw SecurityError PERMISSION_DENIED_ERROR when + * access is denied by the security policy. + * \throw DeviceAPIError IO_ERROR if this is not a directory. + */ + FileArray listFiles() + raises(SecurityError, DeviceAPIError); + + /** + * \brief Opens the file in the given mode supporting the given + * encoding. + * + * \api-feature http://bondi.omtp.org/api/filesystem.read + * \api-feature http://bondi.omtp.org/api/filesystem.write + * + * \code + * // opens file for reading + * var in = file.open("r", "UTF-8"); + * \endcode + * + * \param mode the mode for opening a file + * \n "r" for reading + * \n "a" for appending + * \n "w" for [over]writing + * \param encoding the encoding for read/write operations on the file, + * supported encodings are: + * \n "UTF-8" default encoding + * \n "ISO8859-1" latin1 encoding + * \return file stream handle to read/write from/to. + * \throw SecurityError PERMISSION_DENIED_ERROR when + * access is denied by the security policy. + * \throw DeviceAPIError INVALID_ARGUMENT_ERROR if invalid mode + * or unsupported encoding is supplied. + * \throw DeviceAPIError IO_ERROR if this is not a file. + */ + FileStream open(in DOMString mode, in DOMString encoding) + raises(SecurityError, DeviceAPIError); + + /** + * \brief Copies this file. + * + * The copy will be created in the given path. If this function + * fails and the error callback is called, it will pass an + * DeviceAPIError IO_ERROR to the callback. + * + * The encoding of file paths is UTF-8. + * + * \api-feature http://bondi.omtp.org/api/filesystem.write + * + * \code + * // copies this file to /temp/file.copy + * var op = file.copyTo(function(copiedFile) { alert("file copied"); }, null, "/temp/file.copy", false); + * \endcode + * + * \param successCallback called when the file has been copied. + * \param errorCallback called if an error occured. + * \param filePath the new file path, [a-Z0-9_- /]+ are allowed + * \param overwrite true enforces overwriting an existing file. + * \return PendingOperation enabling the requester to cancel this request. + * \throw SecurityError PERMISSION_DENIED_ERROR when + * access is denied by the security policy. + * \throw DeviceAPIError IO_ERROR if it is attempted to move to a directory. + * \throw DeviceAPIError IO_ERROR if overwrite is false and target file exists. + * \throw DeviceAPIError IO_ERROR if any characters in the path are not supported. + * \throw DeviceAPIError IO_ERROR if the file cannot be copied. + */ + PendingOperation copyTo(in FileSystemSuccessCallback successCallback, + in ErrorCallback errorCallback, + in DOMString filePath, + in boolean overwrite) + raises(SecurityError, DeviceAPIError); + + /** + * \brief Moves this file. + * + * The file will be moved atomically to the given path. This is + * different to copyTo and deleting the old file, because this + * operation does not need extra disk space on certain platforms. + * If this function fails and the error callback is called, it + * will pass an DeviceAPIError IO_ERROR to the callback. + * + * The encoding of file paths is UTF-8. + * + * \api-feature http://bondi.omtp.org/api/filesystem.write + * + * \code + * // moves this file to /temp/file.move + * var op = file.moveTo(function(movedFile) { file = movedFile; }, null, "/temp/file.move"); + * \endcode + * + * \param successCallback called when the file has been copied. + * \param errorCallback called if an error occured. + * \param filePath the new file name, [a-Z0-9_- /]+ are allowed + * \param overwrite true enforces overwriting an existing file. + * \return PendingOperation enabling the requester to cancel this request. + * \throw SecurityError PERMISSION_DENIED_ERROR when + * access is denied by the security policy. + * \throw DeviceAPIError IO_ERROR if it is attempted to move to a directory. + * \throw DeviceAPIError IO_ERROR if overwrite is false and target file exists. + * \throw DeviceAPIError IO_ERROR if any characters in the path are not supported. + * \throw DeviceAPIError IO_ERROR if the file cannot be moved. + */ + PendingOperation moveTo(in FileSystemSuccessCallback successCallback, + in ErrorCallback errorCallback, + in DOMString filePath, + in boolean overwrite) + raises(SecurityError, DeviceAPIError); + + /** + * \brief Creates a directory. + * + * The new directory will be created relatively to the current + * directory this operation is performed on. It will attempt to + * create all necessary sub-directories as well. The use of "." + * or ".." in path components is not supported. If the + * bottom-most directory being created already exists this + * method will throw an IO_ERROR. + * + * The encoding of file paths is UTF-8. + * + * \api-feature http://bondi.omtp.org/api/filesystem.write + * + * \code + * var newDir = dir.createDirectory("newDir"); + * var anotherNewDir = dir.createDirectory("newDir1/subNewDir1"); + * \endcode + * + * \param dirPath the new directory path, it should only contain + * characters supported by the underlying filesystem. + * \return file handle of the new directory + * \throw SecurityError PERMISSION_DENIED_ERROR when + * access is denied by the security policy. + * \throw DeviceAPIError IO_ERROR if this is not a directory. + * \throw DeviceAPIError IO_ERROR if any path component does not exist. + * \throw DeviceAPIError IO_ERROR if a file with the same name exists. + * \throw DeviceAPIError IO_ERROR if any characters in the path are not supported. + * \throw DeviceAPIError IO_ERROR if the directory cannot be created. + */ + File createDirectory(in DOMString dirPath) + raises(SecurityError, DeviceAPIError); + + /** + * \brief Creates a new empty file. + * + * The new empty file is created in the given path relatively + * to the current directory the operation is performed on. The + * use of "." or ".." in path components is not supported. If + * the bottom-most file being created already exists this + * method will throw an IO_ERROR. If any path component does + * not exist this method will throw an IO_ERROR. + * + * The encoding of file paths is UTF-8. + * + * \api-feature http://bondi.omtp.org/api/filesystem.write + * + * \code + * var newFile = dir.createFile("newFile"); + * \endcode + * + * \param filePath the new file path, it should only contain + * characters supported by the underlying filesystem. + * \return file handle of the new empty file + * \throw SecurityError PERMISSION_DENIED_ERROR when + * access is denied by the security policy. + * \throw DeviceAPIError IO_ERROR if this is not a directory. + * \throw DeviceAPIError IO_ERROR if any path component does not exist. + * \throw DeviceAPIError IO_ERROR if the file already exists. + * \throw DeviceAPIError IO_ERROR if any characters in the path are not supported. + * \throw DeviceAPIError IO_ERROR if the file cannot be created. + */ + File createFile(in DOMString filePath) + raises(SecurityError, DeviceAPIError); + + /** + * \brief Resolves an existing file or directory relatively to + * the current directory this operation is performed on; and + * returns a file handle for it. + * + * The filePath is not allowed to contain the "." or ".." directories. + * + * The encoding of file paths is UTF-8. + * + * \api-feature http://bondi.omtp.org/api/filesystem.read + * + * \code + * var hellofile = dir.resolve("foo/hello.txt"); + * \endcode + * + * \param filePath the relative file/directory path to resolve. + * \return file handle of the file or null if it cannot be resolved. + * \throw SecurityError PERMISSION_DENIED_ERROR when + * access is denied by the security policy. + * \throw DeviceAPIError IO_ERROR if this is not a directory. + * \throw DeviceAPIError IO_ERROR if any characters in the path are not supported. + * \throw DeviceAPIError IO_ERROR if the file or directory cannot be resolved. + */ + File resolve(in DOMString filePath) + raises(SecurityError, DeviceAPIError); + + /** + * \brief Deletes this directory. + * + * This function attempts to delete a directory or directory + * tree synchronously and returns true on success, + * false otherwise. It may throw an IO_ERROR if a + * recursive deletion partially fails and any deleted data so + * far cannot be recovered. This might happen due the lack of + * filesystem permissions or if any directories or files are + * openened by other processes. + * + * \api-feature http://bondi.omtp.org/api/filesystem.write + * + * \code + * var fullPath = dir.fullPath; + * if(dir.deleteDirectory(true)) { + * // subsequent accesses to dir will throw an error + * alert(fullPath + ' deleted'); + * } + * \endcode + * + * \param recursive true means a recursive deletion, this + * will destroy all data recursively, use with caution. + * \return true on success + * \throw SecurityError PERMISSION_DENIED_ERROR when + * access is denied by the security policy. + * \throw DeviceAPIError IO_ERROR if this is a file. + * \throw DeviceAPIError IO_ERROR if the directory is not empty and + * this operation is not performed recursively. + * \throw DeviceAPIError IO_ERROR if the directory or any file or sub-directory cannot be deleted. + */ + boolean deleteDirectory(in boolean recursive) + raises(SecurityError, DeviceAPIError); + + /** + * \brief Deletes this file. + * + * Returns true on success, false otherwise. + * + * \api-feature http://bondi.omtp.org/api/filesystem.write + * + * \code + * var fullPath = dir.fullPath; + * if(dir.deleteFile()) { + * // subsequent accesses to dir will throw an error + * alert(fullPath + ' deleted'); + * } + * \endcode + * + * \return true on success + * \throw SecurityError PERMISSION_DENIED_ERROR when + * access is denied by the security policy. + * \throw DeviceAPIError IO_ERROR if this is a directory. + * \throw DeviceAPIError IO_ERROR if the file cannot be deleted due + * the lack of filesystem permissions or if it is locked or + * opened by another process. + */ + boolean deleteFile() + raises(SecurityError, DeviceAPIError); + }; + + /** + * \brief FileStream API. + * + * A FileStream represents a handle to a File opened for read and/or + * write operations. Read and write operations are performed relative + * to a file pointer which represents the current position in the file. + * + * A series of read/write methods are available that permit both binary and + * text to be processed. + * + * Once a file stream is closed, any operation attempted on this stream + * will result in a normal JavaScript error. + */ + interface FileStream { + + /** + * \brief Indicates whether or not the current file pointer is at the end + * of the file. + * + * true if the position is at the end of the current file stream. + * + * \code + * if(stream.eof) { + * // file has been read completely + * } + * \endcode + */ + readonly attribute boolean eof; + + /** + * \brief Get/set stream position for reads/writes. + * + * The stream position is an offset of bytes from the start of + * the file stream. When invoking an operation that reads or + * writes from the stream, the operation will take place from + * the position in the position attribute. + * + * \code + * alert(stream.position); // displays current stream position + * // alters current stream position to the begin of the file, + * // like seek() in C + * stream.position = 0; + * \endcode + * \throw DeviceAPIError IO_ERROR if a position was given that is out of the stream range. + */ + attribute unsigned long position + setraises(DeviceAPIError); + + /** + * \brief Returns the number of bytes that are available for + * reading from the stream. + * + * The number of bytes available for reading is the maximum + * amount of bytes that can be read in the next read operation. + * + * -1 if eof is true. + * + * \code + * alert(stream.bytesAvailable); // displays the available bytes to be read + * \endcode + */ + readonly attribute unsigned long bytesAvailable; + + /** + * \brief Closes this FileStream. + * + * Flushes any pending buffered writes and closes the File. Always succeeds. + * Note that pending writes might not succeed. + * + * \code + * stream.close(); // closes this stream, no subsequent access to stream allowed + * \endcode + */ + void close(); + + /** + * \brief Reads the specified number of characters. + * + * Reads specified number of characters and returns them as string. + * The resulting string length might be shorter than charCount if eof + * is true. + * + * \code + * var text = stream.read(0); + * stream.close(); + * \endcode + * + * \param charCount number of characters being read, if + * 0 it will read as long as bytes are available. + * \return the result of read characters as a string. + * \throw DeviceAPIError IO_ERROR if an error occurs during read. + */ + DOMString read(in unsigned long charCount) + raises(DeviceAPIError); + + /** + * \brief Reads the specified number of bytes from this FileStream. + * + * If 0 is supplied it will read all available bytes in a + * single read operation. + * + * \code + * // reads up to 256 bytes from the stream + * var raw = stream.readBytes(256); + * for(var i = 0; i < raw.length; i++) { + * // raw[i] contains the i-th byte of the current data chunk + * } + * \endcode + * + * \param byteCount number of bytes being read. Must not be 0. + * \return the result of read bytes as a byte (or number) array. + * \throw DeviceAPIError IO_ERROR if an error occurs during readBytes. + */ + ByteArray readBytes(in unsigned long byteCount) + raises(DeviceAPIError); + + /** + * \brief Reads the specified number of bytes from this FileStream, encoding + * the result in base64. + * + * If 0 is supplied it will read all available bytes in a + * single read operation. + * + * \code + * // reads up to 256 bytes from the stream + * var base64 = stream.readBase64(256); + * \endcode + * + * \param byteCount number of bytes being read. Must not be 0. + * \return the result of read bytes as base64 encoding string. + * \throw DeviceAPIError IO_ERROR if an error occurs during readBase64. + */ + DOMString readBase64(in unsigned long byteCount) + raises(DeviceAPIError); + + /** + * \brief Writes the specified DOMString to this FileStream. + * + * \code + * var text = "Hello world"; + * stream.write(text); + * \endcode + * + * \param stringData the actual string to be written. + * \throw DeviceAPIError IO_ERROR if an error occurs during write. + */ + void write(in DOMString stringData) + raises(DeviceAPIError); + + /** + * \brief Writes the specified bytes to this FileStream. + * + * \code + * var bytes = in.readBytes(256); + * out.writeBytes(bytes); // writes the bytes read from in to out + * \endcode + * + * \param byteData the byte data array being written. + * \throw DeviceAPIError IO_ERROR if an error occurs during writeBytes. + */ + void writeBytes(in ByteArray byteData) + raises(DeviceAPIError); + + /** + * \brief Converts the specified base64 DOMString to bytes and writes the + * result to this FileStream. + * + * \code + * var base64 = in.readBase64(256); + * out.writeBase64(base64); // writes the base64 data read from in to out + * \endcode + * + * \param base64Data the base64 data being written. + * \throw DeviceAPIError IO_ERROR if an error occurs during writeBase64. + */ + void writeBase64(in DOMString base64Data) + raises(DeviceAPIError); + }; + + /** + * \brief Specifies what is instantiated at feature request + * \def-instantiated + * \api-feature http://bondi.omtp.org/api/filesystem.read + * \api-feature http://bondi.omtp.org/api/filesystem.write + */ + interface FileSystemManagerObject { + readonly attribute FileSystemManager fileSystemManager; + }; + bondi implements FileSystemManagerObject; + +}; diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/examples/spectowidl.xsl b/testing/web-platform/tests/resources/webidl2/test/widlproc/examples/spectowidl.xsl new file mode 100644 index 000000000..442527709 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/examples/spectowidl.xsl @@ -0,0 +1,27 @@ + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/examples/widlhtml.css b/testing/web-platform/tests/resources/webidl2/test/widlproc/examples/widlhtml.css new file mode 100644 index 000000000..8543097a3 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/examples/widlhtml.css @@ -0,0 +1,100 @@ +body { + padding: 2em; + margin: 0; + font-family: sans-serif; + color: black; + background: white; + background-position: top left; + background-attachment: fixed; + background-repeat: no-repeat; +} +:link { color: #00C; background: transparent } +:visited { color: #609; background: transparent } +a:active { color: #C00; background: transparent } +a:link img, a:visited img { border-style: none } /* no border on img links */ + +h1, h2, h3, h4, h5, h6 { text-align: left } +/* background should be transparent, but WebTV has a bug */ +h1, h2, h3 { color: #009393; background: white } +h1 { font: 170% sans-serif } +h2 { font: 140% sans-serif } +h3 { font: 120% sans-serif } +h4 { font: bold 100% sans-serif } +h5 { font: italic 100% sans-serif } +h6 { font: small-caps 100% sans-serif; margin-bottom: 0 } + +.hide { display: none } + +code { font-size: 120% } + +ul.toc, ol.toc, ul.authors { + list-style: none; +} + +.hide { display: none } + +div.head { margin-bottom: 1em } +div.head h1 { margin-top: 2em; clear: both } +div.head table { margin-left: 2em; margin-top: 2em } +div.constraint, div.issue, div.note, div.notice { margin-left: 2em; } +div.exampleInner pre { margin-left: 1em; margin-top: 0em; margin-bottom: 0em} +div.exampleOuter {border: 4px double gray; margin: 0em; padding: 0em} +div.exampleInner { background-color: #d5dee3; + border-top-width: 4px; + border-top-style: double; + border-top-color: #d3d3d3; + border-bottom-width: 4px; + border-bottom-style: double; + border-bottom-color: #d3d3d3; + padding: 4px; margin: 0em } +div.exampleWrapper { margin: 4px } +div.exampleHeader { font-weight: bold; margin: 4px} +div.term { font: 100% sans-serif; color:#000000; font-weight: bold; line-height: 60%} +div.list { font: 100% sans-serif; color:#000000; font-weight: normal; line-height: 60%} + +.optional {text-decoration: line-through; display: none;} + +.copyright,.legalnotice { font-size: small } +.copyright small { font-size: small } + +@media screen { /* hide from IE3 */ +a[href]:hover { background: #ffa } +} + +ol.enumar { list-style-type: decimal; } +ol.enumla { list-style-type: lower-alpha; } +ol.enumlr { list-style-type: lower-roman; } +ol.enumua { list-style-type: upper-alpha; } +ol.enumur { list-style-type: upper-roman; } + +/* BONDI additions */ + +.toc { + list-style-type: none; +} + +pre { + background-color:#D5DEE3; + overflow: auto; + padding: 1em; +} + +.examplecode { + background-color: #EEE; +} + +.def-api-feature-set dt, .def-api-feature dt, dt .def-device-cap, dt.const code { font: bold 100% sans-serif; } +dt.attribute code, dt.method code { font: italic 100% sans-serif; } + +.def-device-caps dd { margin-bottom: 2em } + +dt.method { margin-top: 2em } + +.summary td { + text-align: left; + background-color: #BBDDDD; + color: inherit; + font-family: monospace; + white-space:pre; + padding: .3em 1em .3em 1em; +} diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/src/comment.c b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/comment.c new file mode 100644 index 000000000..622a7bea7 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/comment.c @@ -0,0 +1,1827 @@ +/*********************************************************************** + * $Id$ + * Copyright 2009 Aplix Corporation. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***********************************************************************/ +#include +#include +#include + +#include "comment.h" +#include "entities.h" +#include "lex.h" +#include "misc.h" +#include "node.h" +#include "os.h" +#include "process.h" + +/* struct cnode : a node in the comment parse tree */ +struct cnode { + struct cnode *next; + struct cnode *children; + struct cnode *parent; + const struct cnodefuncs *funcs; + const char *attrtext; + const char *filename; + unsigned int linenum; +}; + +struct cnodefuncs { + int indesc; /* non-zero if it outputs its own xml element that does + not want to be inside */ + int needpara; /* non-zero if text must be in a para node that is a child + of this one */ + int (*askend)(struct cnode *cnode, const struct cnodefuncs *type); + void (*end)(struct cnode *cnode); + void (*output)(struct cnode *cnode, unsigned int indent); +}; + +struct paramcnode { + struct cnode cn; + int inout; + char name[1]; +}; + +/* struct comment : a doxygen comment */ +struct comment { + struct comment *next; + struct node *node; + unsigned int type; + const char *filename; + unsigned int linenum; + struct cnode root; + int back; /* Whether the comment refers back rather than forward. */ + char *text; +}; + + +static struct node *lastidentifier; +static struct comment *comments; +static int incode, inhtmlblock; +static struct comment *curcomment; + +/*********************************************************************** + * htmleldescs : table of recnogized HTML elements + */ +#define HTMLEL_EMPTY 1 +#define HTMLEL_INLINE 2 +#define HTMLEL_BLOCK 4 +#define HTMLEL_AUTOCLOSE 8 +#define HTMLEL_LI 0x10 +#define HTMLEL_DLCONTENTS 0x20 +#define HTMLEL_TABLECONTENTS 0x40 +#define HTMLEL_TRCONTENTS 0x80 + +#define HTMLEL_FLOW (HTMLEL_BLOCK | HTMLEL_INLINE) + +struct htmleldesc { + unsigned int namelen; + const char *name; + unsigned int flags; + unsigned int content; +}; + +static const struct htmleldesc htmleldescs[] = { + { 1, "a", HTMLEL_INLINE, 0 }, + { 1, "b", HTMLEL_INLINE, 0 }, + { 2, "br", HTMLEL_INLINE, HTMLEL_EMPTY }, + { 3, "img", HTMLEL_INLINE, HTMLEL_EMPTY }, + { 2, "dd", HTMLEL_DLCONTENTS, HTMLEL_FLOW }, + { 2, "dl", HTMLEL_BLOCK, HTMLEL_DLCONTENTS }, + { 2, "dt", HTMLEL_DLCONTENTS, HTMLEL_INLINE }, + { 2, "em", HTMLEL_INLINE, 0 }, + { 2, "li", HTMLEL_LI, HTMLEL_FLOW }, + { 2, "ol", HTMLEL_BLOCK, HTMLEL_LI }, + { 1, "p", HTMLEL_BLOCK, HTMLEL_INLINE }, + { 2, "td", HTMLEL_TRCONTENTS | HTMLEL_AUTOCLOSE, HTMLEL_FLOW }, + { 2, "th", HTMLEL_TRCONTENTS | HTMLEL_AUTOCLOSE, HTMLEL_FLOW }, + { 2, "tr", HTMLEL_TABLECONTENTS | HTMLEL_AUTOCLOSE, HTMLEL_TRCONTENTS }, + { 5, "table", HTMLEL_BLOCK, HTMLEL_TABLECONTENTS }, + { 2, "ul", HTMLEL_BLOCK, HTMLEL_LI }, + { 0, 0, 0, 0 } +}; +#define HTMLELDESC_B (htmleldescs + 1) +#define HTMLELDESC_BR (htmleldescs + 2) + +/*********************************************************************** + * addcomment : add a comment to the list of comments if it has doxygen syntax + * + * Enter: tok struct + */ +void +addcomment(struct tok *tok) +{ + if (tok->len >= 1 && (tok->start[0] == '!' + || (tok->type == TOK_BLOCKCOMMENT && tok->start[0] == '*') + || (tok->type == TOK_INLINECOMMENT && tok->start[0] == '/'))) + { + struct comment *comment; + comment = memalloc(sizeof(struct comment)); + comment->text = memalloc(tok->len + 1); + memcpy(comment->text, tok->start, tok->len); + comment->text[tok->len] = 0; + comment->type = tok->type; + comment->filename = tok->filename; + comment->linenum = tok->linenum; + comment->node = 0; + comment->back = 0; + if (comment->text[1] == '<') { + comment->back = 1; + if (!lastidentifier) { + locerrorexit(comment->filename, comment->linenum, + "no identifier to attach doxygen comment to"); + } + comment->node = lastidentifier; + } + comment->next = comments; + comments = comment; + } +} + +/*********************************************************************** + * setcommentnode : set parse node to attach comments to + * + * Enter: node2 = parse node for identifier + */ +void +setcommentnode(struct node *node2) +{ + struct comment *comment = comments; + while (comment && !comment->node) { + comment->node = node2; + comment = comment->next; + } + lastidentifier = node2; +} + +/*********************************************************************** + * joininlinecomments : join adjacent inline comments + * + * Enter: comment = list of comment structs + * + * Return: new list of comment structs + * + * This function also discards any single inline comment that does not + * refer back. + */ +static struct comment * +joininlinecomments(struct comment *comments) +{ + struct comment **pcomment; + pcomment = &comments; + for (;;) { + struct comment *comment; + comment = *pcomment; + if (!comment) + break; + if (comment->type != TOK_INLINECOMMENT) { + /* Keep block comment as is. */ + pcomment = &comment->next; + } else if (!comment->back && (!comment->next + || comment->next->type != TOK_INLINECOMMENT + || comment->next->filename != comment->filename + || comment->next->linenum != comment->linenum + 1)) + { + /* Discard single // comment that does not refer back. */ + *pcomment = comment->next; + + } else { + /* Find sequence of adjacent // comments (adjacent lines, + * referring to same node) and join them. We do this in two + * passes, one to count the length of the comment and one + * to join. Note that the list is still in reverse order, + * so we expect the line number to decrease by 1 each time. */ + struct comment *newcomment = 0, *comment2; + const char *filename = comment->filename; + unsigned int linenum = comment->linenum; + for (;;) { + char *wp = newcomment->text; + comment2 = comment; + do { + unsigned int len = strlen(comment2->text); + if (newcomment) + memcpy(wp, comment2->text, len); + wp += len; + linenum--; + comment2 = comment2->next; + } while (comment2 && comment2->filename == filename + && comment2->linenum == linenum + && comment2->node == comment->node); + /* Finished a pass. */ + if (newcomment) { + *wp = 0; + break; + } + newcomment = memalloc(sizeof(struct comment) + + wp - newcomment->text); + newcomment->node = comment->node; + newcomment->type = comment->type; + newcomment->filename = filename; + newcomment->linenum = linenum + 1; + } + /* Replace the scanned comment struct with newcomment in the + * list. */ + newcomment->next = comment2; + *pcomment = newcomment; + pcomment = &newcomment->next; + } + } + return comments; +} + +/*********************************************************************** + * outputchildren : call output recursively on children of cnode + * + * Enter: cnode + * indent = indent (nesting) level of parent + * indesc = whether already in or other top-level + * descriptive element + */ +static void +outputchildren(struct cnode *cnode, unsigned int indent, int indesc) +{ + int curindesc = indesc; + cnode = cnode->children; + while (cnode) { + if (curindesc != cnode->funcs->indesc) { + assert(!indesc); + printf("%*s<%sdescription>\n", indent + 1, "", curindesc ? "/" : ""); + curindesc = !curindesc; + } + (*cnode->funcs->output)(cnode, indent + 2); + cnode = cnode->next; + } + if (curindesc != indesc) + printf("%*s<%sdescription>\n", indent + 1, "", curindesc ? "/" : ""); +} + +/*********************************************************************** + * default_askend : ask node if it wants to end at a para start (default + * implementation) + * + * Enter: cnode + * type = 0 else cnodefuncs for newly starting para + * + * Return: non-zero if this node wants to end + */ +static int +default_askend(struct cnode *cnode, const struct cnodefuncs *type) +{ + return 1; +} + +/*********************************************************************** + * root_askend : ask root node if it wants to end at a para start + * + * Enter: cnode for root + * type = 0 else cnodefuncs for newly starting para + * + * Return: non-zero if this node wants to end + */ +static int +root_askend(struct cnode *cnode, const struct cnodefuncs *type) +{ + return 0; +} + +/*********************************************************************** + * root_output : output root cnode + * + * Enter: cnode for root + * indent = indent (nesting) level + */ +static void +root_output(struct cnode *cnode, unsigned int indent) +{ + outputchildren(cnode, indent, 0); +} + +/*********************************************************************** + * cnode type root + */ +static const struct cnodefuncs root_funcs = { + 0, /* !indesc */ + 1, /* needpara */ + &root_askend, + 0, /* end */ + &root_output, +}; + +/*********************************************************************** + * endcnode : end current cnode + * + * Enter: cnode = current cnode + * + * Return: cnode = new current code (parent of old one) + */ +static struct cnode * +endcnode(struct cnode *cnode) +{ + if (cnode->funcs->end) + (*cnode->funcs->end)(cnode); + /* Reverse the children list. */ + { + struct cnode *child = cnode->children; + cnode->children = 0; + while (child) { + struct cnode *next = child->next; + child->next = cnode->children; + cnode->children = child; + child = next; + } + } + return cnode->parent; +} + +/*********************************************************************** + * endspecificcnode : end a specific type of cnode + * + * Enter: cnode = current cnode + * type = type of node to end + * filename, linenum = filename and line number (for error reporting) + * + * Return: new current cnode + */ +static struct cnode * +endspecificcnode(struct cnode *cnode, const struct cnodefuncs *type, + const char *filename, unsigned int linenum) +{ + while (cnode->funcs != type) { + if (cnode->funcs == &root_funcs) + locerrorexit(filename, linenum, "unmatched \\endcode"); + cnode = endcnode(cnode); + } + return cnode; +} + +/*********************************************************************** + * startcnode : start a newly created cnode + * + * Enter: cnode = current cnode + * newcnode = new cnode to start + * + * Return: new current cnode (which is the same as newcnode) + */ +static struct cnode * +startcnode(struct cnode *cnode, struct cnode *newcnode) +{ + newcnode->parent = cnode; + newcnode->next = cnode->children; + cnode->children = newcnode; + return newcnode; +} + +/*********************************************************************** + * para_output : output para cnode + * + * Enter: cnode for root + * indent = indent (nesting) level + */ +static void +para_output(struct cnode *cnode, unsigned int indent) +{ + printf("%*s

\n", indent, ""); + outputchildren(cnode, indent, 1); + printf("%*s

\n", indent, ""); +} + +/*********************************************************************** + * para_end : end a para cnode + * + * Enter: cnode struct + */ +static void +para_end(struct cnode *cnode) +{ + /* If the para cnode is empty, remove it. */ + if (!cnode->children) + cnode->parent->children = cnode->next; +} + +/*********************************************************************** + * cnode type para + */ +static const struct cnodefuncs para_funcs = { + 1, /* indesc */ + 0, /* !needpara */ + &default_askend, + ¶_end, /* end */ + ¶_output, +}; + +/*********************************************************************** + * brief_output : output brief cnode + * + * Enter: cnode for root + * indent = indent (nesting) level + */ +static void +brief_output(struct cnode *cnode, unsigned int indent) +{ + printf("%*s\n", indent, ""); + outputchildren(cnode, indent, 1); + printf("%*s\n", indent, ""); +} + +/*********************************************************************** + * cnode type brief + */ +static const struct cnodefuncs brief_funcs = { + 0, /* !indesc */ + 0, /* !needpara */ + &default_askend, + 0, /* end */ + &brief_output, +}; + +/*********************************************************************** + * return_output : output return cnode + * + * Enter: cnode for root + * indent = indent (nesting) level + */ +static void +return_output(struct cnode *cnode, unsigned int indent) +{ + printf("%*s

\n", indent, ""); + outputchildren(cnode, indent, 1); + printf("%*s

\n", indent, ""); +} + +/*********************************************************************** + * cnode type return + */ +static const struct cnodefuncs return_funcs = { + 0, /* !indesc */ + 0, /* !needpara */ + &default_askend, + 0, /* end */ + &return_output, +}; + +/*********************************************************************** + * author_output : output name cnode + * + * Enter: cnode for root + * indent = indent (nesting) level + */ +static void +name_output(struct cnode *cnode, unsigned int indent) +{ + printf("%*s\n", indent, ""); + outputchildren(cnode, indent, 1); + printf("%*s\n", indent, ""); +} + +/*********************************************************************** + * cnode type name + */ +static const struct cnodefuncs name_funcs = { + 0, /* !indesc */ + 0, /* !needpara */ + &default_askend, + 0, /* end */ + &name_output, +}; + +/*********************************************************************** + * author_output : output author cnode + * + * Enter: cnode for root + * indent = indent (nesting) level + */ +static void +author_output(struct cnode *cnode, unsigned int indent) +{ + printf("%*s\n", indent, ""); + outputchildren(cnode, indent, 1); + printf("%*s\n", indent, ""); +} + +/*********************************************************************** + * cnode type author + */ +static const struct cnodefuncs author_funcs = { + 0, /* !indesc */ + 0, /* !needpara */ + &default_askend, + 0, /* end */ + &author_output, +}; + +/*********************************************************************** + * version_output : output version cnode + * + * Enter: cnode for root + * indent = indent (nesting) level + */ +static void +version_output(struct cnode *cnode, unsigned int indent) +{ + printf("%*s\n", indent, ""); + outputchildren(cnode, indent, 1); + printf("%*s\n", indent, ""); +} + +/*********************************************************************** + * cnode type version + */ +static const struct cnodefuncs version_funcs = { + 0, /* !indesc */ + 0, /* !needpara */ + &default_askend, + 0, /* end */ + &version_output, +}; + +/*********************************************************************** + * cnode type code + */ +/*********************************************************************** + * code_end : end a code cnode + * + * Enter: cnode struct + */ +static void +code_end(struct cnode *cnode) +{ + if (incode) { + /* The incode flag has not been cleared, so this code cnode is + * being ended implicitly. We complain about that. */ + locerrorexit(cnode->filename, cnode->linenum, "mismatched \\code"); + } +} + +/*********************************************************************** + * code_output : output code cnode + * + * Enter: cnode for root + * indent = indent (nesting) level + */ +static void +code_output(struct cnode *cnode, unsigned int indent) +{ + /* Note capitalization to differentiate it from HTML code element. */ + if(cnode->attrtext) + printf("%*s", indent, "", cnode->attrtext); + else + printf("%*s", indent, ""); + outputchildren(cnode, indent, 1); + printf("\n"); +} + +static const struct cnodefuncs code_funcs = { + 0, /* indesc */ + 0, /* !needpara */ + &default_askend, + &code_end, /* end */ + &code_output, +}; + +/*********************************************************************** + * startpara : start a new para cnode in the parse tree + * + * Enter: cnode = current cnode + * type = vtable for particular type of cnode + * + * Return: new current cnode + */ +static struct cnode * +startpara(struct cnode *cnode, const struct cnodefuncs *type) +{ + struct cnode *newcnode; + while ((*cnode->funcs->askend)(cnode, type)) + cnode = endcnode(cnode); + newcnode = memalloc(sizeof(struct cnode)); + newcnode->funcs = type; + return startcnode(cnode, newcnode); +} + +/*********************************************************************** + * cnode type text + */ +struct textcnode { + struct cnode cn; + unsigned char *data; + unsigned int len; + unsigned int max; +}; + +/*********************************************************************** + * text_end : end a text cnode + * + * Enter: cnode struct + */ +static void +text_end(struct cnode *cnode) +{ + struct textcnode *textcnode = (void *)cnode; + textcnode->data[textcnode->len] = 0; + textcnode->max = textcnode->len + 1; + textcnode->data = memrealloc(textcnode->data, textcnode->max); +} + +/*********************************************************************** + * text_output : output text cnode + * + * Enter: cnode for root + * indent = indent (nesting) level + */ +static void +text_output(struct cnode *cnode, unsigned int indent) +{ + /* We do not indent, in case this is inside a code cnode. */ + struct textcnode *textcnode = (void *)cnode; + unsigned int len = textcnode->len; + unsigned const char *p = textcnode->data; + while (len) { + unsigned int thislen; + const char *thisptr; + thislen = p[0]; + /* (void *) cast is to avoid a warning from the MS compiler. + * I think the warning is wrong, but I could be wrong. */ + memcpy((void *)&thisptr, p + 1, sizeof(void *)); + p += 1 + sizeof(void *); + len -= 1 + sizeof(void *); + printtext(thisptr, thislen, 0); + } +} + +static const struct cnodefuncs text_funcs = { + 1, /* !indesc */ + 0, /* !needpara */ + &default_askend, + &text_end, /* end */ + &text_output, +}; + +/*********************************************************************** + * cnode type html (HTML element) + */ +struct htmlcnode { + struct cnode cn; + const struct htmleldesc *desc; + char attrs[1]; +}; + +/*********************************************************************** + * html_end : end an html cnode + * + * Enter: cnode struct + */ +static void +html_end(struct cnode *cnode) +{ + if (((struct htmlcnode *)cnode)->desc->flags & HTMLEL_BLOCK) + inhtmlblock--; +} + +/*********************************************************************** + * html_output : output html cnode + * + * Enter: cnode for root + * indent = indent (nesting) level + */ +static void +html_output(struct cnode *cnode, unsigned int indent) +{ + struct htmlcnode *htmlcnode = (void *)cnode; + if (!(htmlcnode->desc->flags & HTMLEL_INLINE)) + printf("%*s", indent, ""); + if (htmlcnode->cn.children) { + printf("<%s%s>", htmlcnode->desc->name, htmlcnode->attrs); + if (!(htmlcnode->desc->flags & HTMLEL_INLINE)) + putchar('\n'); + outputchildren(&htmlcnode->cn, indent, 1); + if (!(htmlcnode->desc->flags & HTMLEL_INLINE)) + printf("%*s", indent, ""); + printf("", htmlcnode->desc->name); + } else + printf("<%s%s/>", htmlcnode->desc->name, htmlcnode->attrs); + if (!(htmlcnode->desc->flags & HTMLEL_INLINE)) + putchar('\n'); +} + +static const struct cnodefuncs html_funcs = { + 1, /* indesc */ + 0, /* !needpara */ + &default_askend, + &html_end, /* end */ + &html_output, +}; + +/*********************************************************************** + * starthtmlcnode : start a new html cnode + * + * Enter: cnode = current cnode + * htmleldesc = html element descriptor + * attrs = attributes text + * attrslen = length of attributes text + * filename + * linenum = line number + * + * Return: new current cnode + */ +static struct cnode * +starthtmlcnode(struct cnode *cnode, const struct htmleldesc *htmleldesc, + const char *attrs, unsigned int attrslen, + const char *filename, unsigned int linenum) +{ + struct htmlcnode *htmlcnode; + /* First close enough elements to get to a content + * model that will accept this new element. */ + for (;;) { + if (cnode->funcs != &html_funcs) { + /* Not in any html element. We can accept any block element + * (in which case we need to close the current paragraph + * first) or any inline element (in which case we need to + * close the current text cnode first). */ + if (!(htmleldesc->flags & HTMLEL_INLINE)) { + if (!(htmleldesc->flags & HTMLEL_BLOCK)) + locerrorexit(filename, linenum, "<%s> not valid here", htmleldesc->name); + while ((*cnode->funcs->askend)(cnode, 0)) + cnode = endcnode(cnode); + } else { + while (cnode->funcs == &text_funcs) + cnode = endcnode(cnode); + } + break; + } + htmlcnode = (struct htmlcnode *)cnode; + if (!(htmleldesc->flags & htmlcnode->desc->content)) + locerrorexit(filename, linenum, "<%s> not valid here", htmleldesc->name); + break; + } + if (htmleldesc->flags & HTMLEL_BLOCK) + inhtmlblock++; + /* Create the new html cnode. */ + htmlcnode = memalloc(sizeof(struct htmlcnode) + attrslen); + htmlcnode->desc = htmleldesc; + htmlcnode->cn.funcs = &html_funcs; + htmlcnode->cn.filename = filename; + htmlcnode->cn.linenum = linenum; + memcpy(htmlcnode->attrs, attrs, attrslen); + htmlcnode->attrs[attrslen] = 0; + /* Start the html cnode. */ + cnode = startcnode(cnode, &htmlcnode->cn); + return cnode; +} + +/*********************************************************************** + * param_output : output param cnode + * + * Enter: cnode for param + * indent = indent (nesting) level + * + * This is only used for a \param inside a \def-device-cap. A normal + * \param that gets attached to a function argument gets changed to + * a \return so it does not use this output function. + */ +static void +param_output(struct cnode *cnode, unsigned int indent) +{ + struct paramcnode *paramcnode = (void *)cnode; + printf("%*s\n", indent, "", paramcnode->name); + outputchildren(¶mcnode->cn, indent, 1); + printf("%*s\n", indent, ""); +} + +/*********************************************************************** + * cnode type param + */ +static const struct cnodefuncs param_funcs = { + 0, /* !indesc */ + 0, /* !needpara */ + &default_askend, + 0, /* end */ + ¶m_output, +}; + +/*********************************************************************** + * cnode type throw + */ +static const struct cnodefuncs throw_funcs = { + 0, /* !indesc */ + 0, /* !needpara */ + &default_askend, + 0, /* end */ + &return_output, +}; + +/*********************************************************************** + * startparamcnode : start param (or throw) cnode + * + * Enter: cnode = current cnode + * word = name of param + * wordlen = length of name + * inout = bit 0 = in, bit 1 = out + * type = ¶m_funcs or &throw_funcs + * + * Return: new current cnode + */ +static struct cnode * +startparamcnode(struct cnode *cnode, const char *word, unsigned int wordlen, + int inout, const struct cnodefuncs *funcs) +{ + struct paramcnode *paramcnode; + paramcnode = memalloc(sizeof(struct paramcnode) + wordlen); + paramcnode->cn.funcs = funcs; + memcpy(paramcnode->name, word, wordlen); + paramcnode->name[wordlen] = 0; + paramcnode->inout = inout; + return startcnode(cnode, ¶mcnode->cn); +} + +/*********************************************************************** + * api_feature_output : output api-feature cnode + * + * Enter: cnode for root + * indent = indent (nesting) level + */ +static void +api_feature_output(struct cnode *cnode, unsigned int indent) +{ + struct paramcnode *paramcnode = (void *)cnode; + printf("%*s\n", indent, "", paramcnode->name); + outputchildren(cnode, indent, 1); + printf("%*s\n", indent, ""); +} + +/*********************************************************************** + * cnode type api_feature + */ +static const struct cnodefuncs api_feature_funcs = { + 0, /* !indesc */ + 0, /* needpara */ + &default_askend, + 0, /* end */ + &api_feature_output, +}; + +/*********************************************************************** + * device_cap_output : output device-cap cnode + * + * Enter: cnode for root + * indent = indent (nesting) level + */ +static void +device_cap_output(struct cnode *cnode, unsigned int indent) +{ + struct paramcnode *paramcnode = (void *)cnode; + printf("%*s\n", indent, "", paramcnode->name); + outputchildren(cnode, indent, 1); + printf("%*s\n", indent, ""); +} + +/*********************************************************************** + * cnode type device_cap + */ +static const struct cnodefuncs device_cap_funcs = { + 0, /* !indesc */ + 0, /* needpara */ + &default_askend, + 0, /* end */ + &device_cap_output, +}; + +/*********************************************************************** + * def_api_feature_askend : ask if def-api-feature cnode wants to end at new para + * + * Enter: cnode for def-api-feature + * type = cnodefuncs for new para (0 if html block element) + * + * Return: non-zero to end the def-api-feature + */ +static int +def_api_feature_askend(struct cnode *cnode, const struct cnodefuncs *type) +{ + /* A def-api-feature does not end at a plain para, an html block element, + * a brief para, or a device-cap. */ + if (!type || type == ¶_funcs || type == &device_cap_funcs || type == &brief_funcs) + return 0; + return 1; +} + +/*********************************************************************** + * def_api_feature_output : output def-api-feature cnode + * + * Enter: cnode for root + * indent = indent (nesting) level + */ +static void +def_api_feature_output(struct cnode *cnode, unsigned int indent) +{ + struct paramcnode *paramcnode = (void *)cnode; + printf("%*s\n", indent, "", paramcnode->name); + printf("%*s\n", indent + 2, ""); + outputchildren(cnode, indent + 2, 0); + printf("%*s\n", indent + 2, ""); + printf("%*s\n", indent, ""); +} + +/*********************************************************************** + * cnode type def_api_feature + */ +static const struct cnodefuncs def_api_feature_funcs = { + 0, /* !indesc */ + 1, /* needpara */ + &def_api_feature_askend, + 0, /* end */ + &def_api_feature_output, +}; + +/*********************************************************************** + * def_api_feature_set_askend : ask if def-api-feature-set cnode wants to end at new para + * + * Enter: cnode for def-api-feature-set + * type = cnodefuncs for new para (0 if html block element) + * + * Return: non-zero to end the def-api-feature-set + */ +static int +def_api_feature_set_askend(struct cnode *cnode, const struct cnodefuncs *type) +{ + /* A def-api-feature-set does not end at a plain para, an html block element, + * a brief para, or an api-feature. */ + if (!type || type == ¶_funcs || type == &api_feature_funcs || type == &brief_funcs) + return 0; + return 1; +} + +/*********************************************************************** + * def_api_feature_set_output : output def-api-feature-set cnode + * + * Enter: cnode for root + * indent = indent (nesting) level + */ +static void +def_api_feature_set_output(struct cnode *cnode, unsigned int indent) +{ + struct paramcnode *paramcnode = (void *)cnode; + printf("%*s\n", indent, "", paramcnode->name); + printf("%*s\n", indent + 2, ""); + outputchildren(cnode, indent + 2, 0); + printf("%*s\n", indent + 2, ""); + printf("%*s\n", indent, ""); +} + +/*********************************************************************** + * cnode type def_api_feature_set + */ +static const struct cnodefuncs def_api_feature_set_funcs = { + 0, /* !indesc */ + 1, /* needpara */ + &def_api_feature_set_askend, + 0, /* end */ + &def_api_feature_set_output, +}; + +/*********************************************************************** + * def_instantiated_askend : ask if def-instantiated cnode wants to end at new para + * + * Enter: cnode for def-instantiated + * type = cnodefuncs for new para (0 if html block element) + * + * Return: non-zero to end the def-instantiated + */ +static int +def_instantiated_askend(struct cnode *cnode, const struct cnodefuncs *type) +{ + /* A def-instantiated does not end at a plain para, an html block element, + * a brief para, or an api-feature. */ + if (!type || type == ¶_funcs || type == &api_feature_funcs || type == &brief_funcs) + return 0; + return 1; +} + +/*********************************************************************** + * def_instantiated_output : output def-instantiated cnode + * + * Enter: cnode for root + * indent = indent (nesting) level + */ +static void +def_instantiated_output(struct cnode *cnode, unsigned int indent) +{ + printf("%*s\n", indent, ""); + printf("%*s\n", indent + 2, ""); + outputchildren(cnode, indent + 2, 0); + printf("%*s\n", indent + 2, ""); + printf("%*s\n", indent, ""); +} + +/*********************************************************************** + * cnode type def_instantiated + */ +static const struct cnodefuncs def_instantiated_funcs = { + 0, /* !indesc */ + 1, /* needpara */ + &def_instantiated_askend, + 0, /* end */ + &def_instantiated_output, +}; + +/*********************************************************************** + * def_device_cap_askend : ask if def-device-cap cnode wants to end at new para + * + * Enter: cnode for def-device-cap + * type = cnodefuncs for new para (0 if html block element) + * + * Return: non-zero to end the def-device-cap + */ +static int +def_device_cap_askend(struct cnode *cnode, const struct cnodefuncs *type) +{ + /* A def-device-cap does not end at a plain para, an html block element, + * a \brief para, or a param. */ + if (!type || type == ¶_funcs || type == ¶m_funcs || type == &brief_funcs) + return 0; + return 1; +} + +/*********************************************************************** + * def_device_cap_output : output def_device-cap cnode + * + * Enter: cnode for root + * indent = indent (nesting) level + */ +static void +def_device_cap_output(struct cnode *cnode, unsigned int indent) +{ + struct paramcnode *paramcnode = (void *)cnode; + printf("%*s\n", indent, "", paramcnode->name); + printf("%*s\n", indent + 2, ""); + outputchildren(cnode, indent + 2, 0); + printf("%*s\n", indent + 2, ""); + printf("%*s\n", indent, ""); +} + +/*********************************************************************** + * cnode type def_device_cap + */ +static const struct cnodefuncs def_device_cap_funcs = { + 0, /* !indesc */ + 1, /* needpara */ + &def_device_cap_askend, + 0, /* end */ + &def_device_cap_output, +}; + +/*********************************************************************** + * addtext : add text to current text node, starting one if necessary + * + * Enter: cnode = current cnode + * text + * len = length of text + * + * Return: new current cnode + */ +static struct cnode * +addtext(struct cnode *cnode, const char *text, unsigned int len) +{ + struct textcnode *textcnode; + if (!len) + return cnode; + if (cnode->funcs != &text_funcs) { + /* Start new text cnode. */ + textcnode = memalloc(sizeof(struct textcnode)); + textcnode->cn.funcs = &text_funcs; + cnode = startcnode(cnode, &textcnode->cn); + } + textcnode = (void *)cnode; + do { + unsigned char buf[1 + sizeof(void *)]; + unsigned int thislen = len; + if (thislen > 255) + thislen = 255; + /* Encode a record as a single byte length followed by a pointer. */ + buf[0] = thislen; + memcpy(buf + 1, &text, sizeof(void *)); + /* Add to the text cnode's data. */ + if (textcnode->len + sizeof(buf) >= textcnode->max) { + /* Need to reallocate (or allocate) data buffer. */ + textcnode->max = textcnode->max ? 2 * textcnode->max : 1024; + textcnode->data = memrealloc(textcnode->data, textcnode->max); + } + memcpy(textcnode->data + textcnode->len, buf, sizeof(buf)); + textcnode->len += sizeof(buf); + text += thislen; + len -= thislen; + } while (len); + return &textcnode->cn; +} + +/*********************************************************************** + * iswhitespace : determine if character is whitespace + * + * Enter: ch = character + * + * Return: 1 if whitespace + */ +static inline int +iswhitespace(int ch) +{ + unsigned int i = ch - 1; + if (i >= 32) + return 0; + return 0x80001100 >> i & 1; +} + +/*********************************************************************** + * parseword : parse the next word, ignoring leading whitespace + * + * Enter: *pp = text pointer + * + * Return: 0 else start of word (*pp updated to just beyond end) + */ +static const char * +parseword(const char **pp) +{ + const char *p = *pp, *word = 0; + int ch = *p; + while (iswhitespace(ch)) + ch = *++p; + word = p; + while ((unsigned)((ch & ~0x20) - 'A') <= 'Z' - 'A' + || (unsigned)(ch - '0') < 10 || ch == '_' || ch == '.' + || ch == ':' || ch == '/' || ch == '-') + { + ch = *++p; + } + if (p == word) + return 0; + *pp = p; + return word; +} + +/*********************************************************************** + * Doxygen command handlers + * + * Enter: p = text just after command + * *pcnode = pointer to current cnode struct + * type = 0 else cnodefuncs pointer for type of node to start + * filename, linenum = current filename and line number (for error reporting) + * + * Return: p = updated if extra text was eaten + * + * On return, *pnode is updated if any node was closed or opened. + */ + +/*********************************************************************** + * Doxygen command handler : \b + */ +static const char * +dox_b(const char *p, struct cnode **pcnode, const struct cnodefuncs *type, + const char *filename, unsigned int linenum, const char *cmdname) +{ + struct cnode *cnode = *pcnode; + const char *word = parseword(&p); + /* Silently ignore \b with no following word. */ + if (word) { + struct cnode *mycnode; + mycnode = cnode = starthtmlcnode(cnode, HTMLELDESC_B, 0, 0, filename, linenum); + cnode = addtext(cnode, word, p - word); + while (cnode != mycnode) + cnode = endcnode(cnode); + cnode = endcnode(cnode); + } + *pcnode = cnode; + return p; +} + +/*********************************************************************** + * Doxygen command handler : \n + */ +static const char * +dox_n(const char *p, struct cnode **pcnode, const struct cnodefuncs *type, + const char *filename, unsigned int linenum, const char *cmdname) +{ + struct cnode *cnode = *pcnode; + cnode = starthtmlcnode(cnode, HTMLELDESC_BR, 0, 0, filename, linenum); + cnode = endcnode(cnode); + *pcnode = cnode; + return p; +} + +/*********************************************************************** + * Doxygen command handler : \code + */ +static const char * +dox_code(const char *p, struct cnode **pcnode, const struct cnodefuncs *type, + const char *filename, unsigned int linenum, const char *cmdname) +{ + *pcnode = startpara(*pcnode, &code_funcs); + (*pcnode)->filename = filename; + (*pcnode)->linenum = linenum; /* for reporting mismatched \code error */ + incode = 1; + return p; +} + +/*********************************************************************** + * Doxygen command handler : \endcode + */ +static const char * +dox_endcode(const char *p, struct cnode **pcnode, const struct cnodefuncs *type, + const char *filename, unsigned int linenum, const char *cmdname) +{ + incode = 0; + *pcnode = endspecificcnode(*pcnode, &code_funcs, filename, linenum); + return p; +} + +/*********************************************************************** + * Doxygen command handler : \param + */ +static const char * +dox_param(const char *p, struct cnode **pcnode, const struct cnodefuncs *type, + const char *filename, unsigned int linenum, const char *cmdname) +{ + struct cnode *cnode = *pcnode; + unsigned int inout = 0; + const char *word; + /* Check for "in", "out" or both as attributes. */ + if (*p == '[') { + for (;;) { + p++; + if (!memcmp(p, "in", 2)) { + inout |= 1; + p += 2; + } else if (!memcmp(p, "out", 3)) { + inout |= 2; + p += 3; + } else + break; + if (*p != ',') + break; + } + if (*p != ']') + locerrorexit(filename, linenum, "bad attributes on \\param"); + p++; + } + /* Get the next word as the parameter name. */ + word = parseword(&p); + if (!word) + locerrorexit(filename, linenum, "expected word after \\param"); + /* Close any open nodes. */ + while ((*cnode->funcs->askend)(cnode, type)) + cnode = endcnode(cnode); + /* Create a new param cnode. */ + cnode = startparamcnode(cnode, word, p - word, inout, type); + cnode->filename = filename; + cnode->linenum = linenum; + *pcnode = cnode; + return p; +} + +/*********************************************************************** + * Doxygen command handler : \brief, \return + */ +static const char * +dox_para(const char *p, struct cnode **pcnode, const struct cnodefuncs *type, + const char *filename, unsigned int linenum, const char *cmdname) +{ + *pcnode = startpara(*pcnode, type); + return p; +} + +/*********************************************************************** + * Doxygen command handler : \throw + */ +static const char * +dox_throw(const char *p, struct cnode **pcnode, const struct cnodefuncs *type, + const char *filename, unsigned int linenum, const char *cmdname) +{ + struct cnode *cnode = *pcnode; + const char *word; + /* Get the next word as the exception name. */ + word = parseword(&p); + if (!word) + locerrorexit(filename, linenum, "expected word after \\throw"); + /* Close any open nodes. */ + while ((*cnode->funcs->askend)(cnode, type)) + cnode = endcnode(cnode); + /* Create a new throw cnode. */ + cnode = startparamcnode(cnode, word, p - word, 0, type); + cnode->filename = filename; + cnode->linenum = linenum; + *pcnode = cnode; + return p; +} + +/*********************************************************************** + * Doxygen command handler : \lang + */ +static const char * +dox_attr(const char *p, struct cnode **pcnode, const struct cnodefuncs *type, + const char *filename, unsigned int linenum, const char *cmdname) +{ + struct cnode *cnode = *pcnode; + const char *word; + int len, wordlen, offset = 0; + char *attrtext; + /* Get the next word as the attribute value. */ + word = parseword(&p); + if (!word) + locerrorexit(filename, linenum, "expected word after \\%s", cmdname); + + len = strlen(cmdname) + (wordlen = p-word) + 4; /* p="word"\0 */ + if(cnode->attrtext) + len += (offset = strlen(cnode->attrtext)) + 1; /* add space for space */ + attrtext = memalloc(len); + if(offset) { + memcpy(attrtext, cnode->attrtext, offset); + attrtext[offset++] = ' '; + memfree(((void*)cnode->attrtext)); + } + offset += sprintf(&attrtext[offset], "%s=\"", cmdname); + memcpy(&attrtext[offset], word, wordlen); + strcpy(&attrtext[offset + wordlen], "\""); + cnode->attrtext = attrtext; + /* skip delimiter because it won't be done otherwise */ + if(incode && iswhitespace(*p)) ++p; + return p; +} + +/*********************************************************************** + * commands : table of Doxygen commands + */ +struct command { + const char *(*func)(const char *p, struct cnode **pcnode, const struct cnodefuncs *type, const char *filename, unsigned int linenum, const char *cmdname); + const struct cnodefuncs *type; + unsigned int namelen; + const char *name; +}; +static const struct command commands[] = { + { &dox_throw, &def_api_feature_funcs, 15, "def-api-feature" }, + { &dox_throw, &def_api_feature_set_funcs, 19, "def-api-feature-set" }, + { &dox_para, &def_instantiated_funcs, 16, "def-instantiated" }, + { &dox_para, &name_funcs, 4, "name" }, + { &dox_para, &author_funcs, 6, "author" }, + { &dox_b, 0, 1, "b" }, + { &dox_para, &brief_funcs, 5, "brief" }, + { &dox_code, 0, 4, "code" }, + { &dox_throw, &def_device_cap_funcs, 14, "def-device-cap" }, + { &dox_attr, 0, 4, "lang" }, + { &dox_endcode, 0, 7, "endcode" }, + { &dox_n, 0, 1, "n" }, + { &dox_param, ¶m_funcs, 5, "param" }, + { &dox_para, &return_funcs, 6, "return" }, + { &dox_throw, &throw_funcs, 5, "throw" }, + { &dox_throw, &api_feature_funcs, 11, "api-feature" }, + { &dox_throw, &device_cap_funcs, 10, "device-cap" }, + { &dox_para, &version_funcs, 7, "version" }, + { 0, 0, 0 } +}; + +/*********************************************************************** + * parsehtmltag : parse html tag + * + * Enter: start = start of tag, the '<' char + * *pcnode = current cnode + * filename = filename + * *plinenum = current line number + * + * Return: just after the tag + * *pcnode and *plinenum updated if applicable + */ +static const char * +parsehtmltag(const char *start, struct cnode **pcnode, + const char *filename, unsigned int *plinenum) +{ + struct cnode *cnode = *pcnode; + const char *end = start + 1, *endname = 0, *name = end; + int ch = *end; + int quote = 0; + int close = 0; + unsigned int linenum = *plinenum; + const struct htmleldesc *htmleldesc; + if (ch == '/') { + close = 1; + ch = *++end; + name = end; + } + /* Find the end of the tag. */ + for (;;) { + if (!ch) + locerrorexit(filename, *plinenum, "unterminated HTML tag"); + if (ch == '\n') + linenum++; + else if (iswhitespace(ch) || ch == '/') { + if (!endname) + endname = end; + } else if (!quote) { + if (ch == '"' || ch == '\'') + quote = ch; + else if (ch == '>') + break; + } else { + if (ch == quote) + quote = 0; + } + ch = *++end; + } + if (!endname) + endname = end; + end++; + /* See if it's an xml open-close tag. */ + if (!close && endname != name && end[-2] == '/') + close = 2; + /* Find the tag from our list. */ + htmleldesc = htmleldescs; + for (;;) { + if (!htmleldesc->namelen) { + locerrorexit(filename, *plinenum, "unrecognized HTML tag %.*s", + end - start, start); + } + if (htmleldesc->namelen == endname - name + && !strncasecmp(htmleldesc->name, name, endname - name)) + { + break; + } + htmleldesc++; + } + if (close == 1) { + /* Closing tag. Find open element to close. */ + for (;;) { + struct htmlcnode *htmlcnode; + if (cnode->funcs != &text_funcs) { + if (cnode->funcs != &html_funcs) { + locerrorexit(filename, *plinenum, "mismatched %.*s", + end - start, start); + } + htmlcnode = (struct htmlcnode *)cnode; + if (htmlcnode->desc == htmleldesc) + break; + if (!(htmlcnode->desc->flags & HTMLEL_AUTOCLOSE)) { + locerrorexit(filename, htmlcnode->cn.linenum, + "mismatched <%.*s>", + htmlcnode->desc->namelen, htmlcnode->desc->name); + } + } + cnode = endcnode(cnode); + } + cnode = endcnode(cnode); + } else { + /* Opening tag. */ + if (close !=2) + cnode = starthtmlcnode(cnode, htmleldesc, endname, end - 1 - endname, filename, *plinenum); + else // don't include the closing "/" in the attributes list + cnode = starthtmlcnode(cnode, htmleldesc, endname, end - 2 - endname, filename, *plinenum); + if (close == 2 || (htmleldesc->content & HTMLEL_EMPTY)) { + /* Empty element -- close it again. */ + cnode = endcnode(cnode); + } + } + *pcnode = cnode; + *plinenum = linenum; + return end; +} + +/*********************************************************************** + * parsecomment : parse one comment + * + * Enter: comment struct + */ +static void +parsecomment(struct comment *comment) +{ + struct cnode *cnode = &comment->root; + const char *p = comment->text + comment->back; + unsigned int linenum = comment->linenum - 1; + int ch; + curcomment = comment; + incode = 0; + inhtmlblock = 0; + cnode->funcs = &root_funcs; + for (;;) { + /* Start of new line. */ + const char *starttext; + ch = *p; + linenum++; + { + /* Find first non-whitespace character. */ + const char *p2 = p; + int ch2 = ch; + while (iswhitespace(ch2)) + ch2 = *++p2; + if (comment->type == TOK_BLOCKCOMMENT && ch2 == '*') { + /* Ignore initial * in block comment (even in \code block). */ + ch2 = *++p2; + ch = ch2; + p = p2; + if (ch == '*') + goto checkforlineofstars; + while (iswhitespace(ch2)) + ch2 = *++p2; + } + if (comment->type == TOK_INLINECOMMENT && ch2 == '/') { +checkforlineofstars: + if (!incode) { + /* Ignore whole line of * for block comment or / for inline + * comment if that is the only thing on the line. */ + const char *p3 = p2; + int ch3; + do ch3 = *++p3; while (ch3 == ch2); + while (iswhitespace(ch3)) ch3 = *++p3; + if (!ch3 || ch3 == '\n') { + /* Reached end of line (or whole comment) -- treat as + * empty line. */ + ch2 = ch3; + p2 = p3; + } + } + } + if (!incode) { + /* Only allow whitespace omission above to take effect if + * not in \code block. */ + ch = ch2; + p = p2; + } + } + if (!ch) { + /* End of comments -- finish. */ + break; + } + if (!incode && !inhtmlblock && ch == '\n') { + /* Blank line -- finish any para, but only if not in code and + * not in any HTML block element. */ + while ((*cnode->funcs->askend)(cnode, 0)) + cnode = endcnode(cnode); + p++; + continue; + } + /* Start new para if there isn't already one going. */ + if (cnode->funcs->needpara) + cnode = startpara(cnode, ¶_funcs); + /* Process text on the line. */ + starttext = p; + while (ch && ch != '\n') { + if (ch != '\\' && ch != '<' /* && ch != '@' */ && ch != '$' + && ch != '&' && ch != '\r') + { + ch = *++p; + continue; + } + /* Output any pending text. */ + if (p - starttext) + cnode = addtext(cnode, starttext, p - starttext); + /* Ignore \r in DOS line returns */ + if (ch == '\r') { + ch = *++p; + starttext = p; + continue; + } + if (ch == '$') + locerrorexit(comment->filename, linenum, "use \\$ instead of $"); + /* See if it is an html named entity. */ + if (ch == '&' && p[1] != '#') { + const char *entity = ENTITIES; + /* This search could be faster if the entity names were put + * in a hash table or something. */ + const char *semicolon = strchr(p, ';'); + unsigned int len; + if (!semicolon) + locerrorexit(comment->filename, linenum, "unterminated HTML entity"); + p++; + for (;;) { + len = strlen(entity); + if (!len) + locerrorexit(comment->filename, linenum, "unrecognised HTML entity &%.*s;", semicolon - p, p); + if (len == semicolon - p && !memcmp(p, entity, len)) + break; + entity += len + 1; + entity += strlen(entity) + 1; + } + entity += len + 1; + cnode = addtext(cnode, entity, strlen(entity)); + p = semicolon + 1; + ch = *p; + starttext = p; + continue; + } + /* See if it is a backslash escape sequence. */ + else if (ch == '\\') { + const char *match = "\\@&$#<>%"; + const char *pos; + ch = p[1]; + pos = strchr(match, ch); + if (pos) { + /* Got a \ escape sequence. */ + const char *text = + "\\\0 @\0 &\0$\0 #\0 <\0 >\0 %" + + 6 * (pos - match); + cnode = addtext(cnode, text, strlen(text)); + p += 2; + ch = *p; + starttext = p; + continue; + } + } else if (ch == '<') { + if (incode) { + ch = *++p; + starttext = p; + continue; + } + /* It's an html tag. */ + p = parsehtmltag(p, &cnode, comment->filename, &linenum); + ch = *p; + starttext = p; + continue; + } + { + /* Got a doxygen command. First work out its length. */ + const char *start = ++p; + unsigned int cmdlen; + const struct command *command; + ch = *p; + while ((unsigned)((ch & ~0x20) - 'A') <= 'Z' - 'A' + || (unsigned)(ch - '0') < 10 || ch == '_' || ch == '-') + { + ch = *++p; + } + cmdlen = p - start; + if (!cmdlen) + locerrorexit(comment->filename, linenum, "\\ or @ without Doxygen command"); + /* Look it up in the table. */ + command = commands; + for (;;) { + if (!command->namelen) { + locerrorexit(comment->filename, linenum, "unrecognized Doxygen command '%.*s'", + cmdlen + 1, start - 1); + } + if (command->namelen == cmdlen + && !memcmp(command->name, start, cmdlen)) + { + break; + } + command++; + } + p = (*command->func)(p, &cnode, command->type, + comment->filename, linenum, command->name); + ch = *p; + starttext = p; + } + } + if (p - starttext) { + /* Start new para if there isn't already one going. */ + if (cnode->funcs->needpara) + cnode = startpara(cnode, ¶_funcs); + cnode = addtext(cnode, starttext, p - starttext); + } + if (!ch) + break; + if (cnode->funcs == &text_funcs) + addtext(cnode, "\n", 1); + p++; + } + /* Finish the root cnode. */ + do + cnode = endcnode(cnode); + while (cnode); + assert(!incode); + assert(!inhtmlblock); +} + +/*********************************************************************** + * parsecomments : parse comments + * + * Enter: comment = first comment in list + */ +static void +parsecomments(struct comment *comment) +{ + while (comment) { + parsecomment(comment); + comment = comment->next; + } +} + +/*********************************************************************** + * attachcommenttonode : attach comment struct to node + * + * Enter: node = parse node for identifier + * comment = comment struct + */ +static void +attachcommenttonode(struct node *node, struct comment *comment) +{ + comment->next = node->comments; + node->comments = comment; +} + +/*********************************************************************** + * attachcomments : attach comments to applicable parse nodes + * + * Enter: comment = first in (reversed) list of comment structs + * root = root parse node (for attaching \file comment blocks to) + */ +static void +attachcomments(struct comment *comment, struct node *root) +{ + while (comment) { + struct comment *next = comment->next; + /* See if there are any \param, \return, \throw, \def-api-feature or + * \def-device-cap cnodes to detach and attach + * elsewhere. (This only looks at top-level nodes, direct children + * of the root, so does not detach a \param inside a + * \def-device-cap.) */ + struct cnode **pcnode = &comment->root.children; + for (;;) { + struct cnode *cnode = *pcnode; + if (!cnode) + break; + if (cnode->funcs == ¶m_funcs || cnode->funcs == &return_funcs + || cnode->funcs == &throw_funcs) + { + /* Found a \param or \return or \throw to detach. Find the + * parameter/exception of the same name, or the return type. */ + struct node *node; + struct comment *newcomment; + if (cnode->funcs == ¶m_funcs) { + node = findparamidentifier(comment->node, + ((struct paramcnode *)cnode)->name); + if (!node) + locerrorexit(comment->filename, cnode->linenum, "no parameter '%s' found", ((struct paramcnode *)cnode)->name); + } else if (cnode->funcs == &return_funcs) { + node = findreturntype(comment->node); + if (!node) + locerrorexit(comment->filename, cnode->linenum, "no return type found"); + } else { + node = findthrowidentifier(comment->node, + ((struct paramcnode *)cnode)->name); + if (!node) + locerrorexit(comment->filename, cnode->linenum, "no exception '%s' found", ((struct paramcnode *)cnode)->name); + } + /* Detach the cnode from its old comment. */ + *pcnode = cnode->next; + /* Create a new comment struct to contain this cnode. */ + newcomment = memalloc(sizeof(struct comment)); + newcomment->root.funcs = &root_funcs; + newcomment->linenum = cnode->linenum; + /* Attach the cnode. */ + newcomment->root.children = cnode; + cnode->parent = &newcomment->root; + cnode->next = 0; + /* Make the cnode a \return one, just so even a \param + * uses return_output. */ + cnode->funcs = &return_funcs; + /* Attach the new comment struct to the parse node. */ + attachcommenttonode(node, newcomment); + } else { + pcnode = &cnode->next; + } + } + /* Now attach the comment to its identifier parse node. */ + { + struct node *node = comment->node; + if (!node) + node = root; + attachcommenttonode(node, comment); + } + comment = next; + } +} + +/*********************************************************************** + * processcomments : join, parse and attach comments + * + * Enter: root = root parse node + */ +void +processcomments(struct node *root) +{ + comments = joininlinecomments(comments); + parsecomments(comments); + attachcomments(comments, root); +} + +/*********************************************************************** + * outputdescriptive : output descriptive elements for a node + * + * Enter: node = identifier node that might have some comments + * indent = indent (nesting) level + */ +void +outputdescriptive(struct node *node, unsigned int indent) +{ + struct comment *comment = node->comments; + int indescriptive = 0; + while (comment) { + struct cnode *root = &comment->root; + if (!indescriptive) + printf("%*s\n", indent, ""); + indescriptive = 1; + (*root->funcs->output)(root, indent + 2); + comment = comment->next; + } + if (indescriptive) + printf("%*s\n", indent, ""); +} diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/src/comment.h b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/comment.h new file mode 100644 index 000000000..96d18e2cc --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/comment.h @@ -0,0 +1,25 @@ +/*********************************************************************** + * $Id$ + * Copyright 2009 Aplix Corporation. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***********************************************************************/ +#ifndef comment_h +#define comment_h + +struct tok; +struct node; + +void addcomment(struct tok *tok); +void setcommentnode(struct node *node2); +void processcomments(struct node *root); +void outputdescriptive(struct node *node, unsigned int indent); + +#endif /* ndef comment_h */ diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/src/entities.h b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/entities.h new file mode 100644 index 000000000..ff74c1cb3 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/entities.h @@ -0,0 +1,271 @@ +/*********************************************************************** + * $Id$ + * Copyright 2009 Aplix Corporation. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***********************************************************************/ +#ifndef entities_h +#define entities_h + +#define ENTITIES \ +"nbsp\0 \0" \ +"iexcl\0¡\0" \ +"cent\0¢\0" \ +"pound\0£\0" \ +"curren\0¤\0" \ +"yen\0¥\0" \ +"brvbar\0¦\0" \ +"sect\0§\0" \ +"uml\0¨\0" \ +"copy\0©\0" \ +"ordf\0ª\0" \ +"laquo\0«\0" \ +"not\0¬\0" \ +"shy\0­\0" \ +"reg\0®\0" \ +"macr\0¯\0" \ +"deg\0°\0" \ +"plusmn\0±\0" \ +"sup2\0²\0" \ +"sup3\0³\0" \ +"acute\0´\0" \ +"micro\0µ\0" \ +"para\0¶\0" \ +"middot\0·\0" \ +"cedil\0¸\0" \ +"sup1\0¹\0" \ +"ordm\0º\0" \ +"raquo\0»\0" \ +"frac14\0¼\0" \ +"frac12\0½\0" \ +"frac34\0¾\0" \ +"iquest\0¿\0" \ +"Agrave\0À\0" \ +"Aacute\0Á\0" \ +"Acirc\0Â\0" \ +"Atilde\0Ã\0" \ +"Auml\0Ä\0" \ +"Aring\0Å\0" \ +"AElig\0Æ\0" \ +"Ccedil\0Ç\0" \ +"Egrave\0È\0" \ +"Eacute\0É\0" \ +"Ecirc\0Ê\0" \ +"Euml\0Ë\0" \ +"Igrave\0Ì\0" \ +"Iacute\0Í\0" \ +"Icirc\0Î\0" \ +"Iuml\0Ï\0" \ +"ETH\0Ð\0" \ +"Ntilde\0Ñ\0" \ +"Ograve\0Ò\0" \ +"Oacute\0Ó\0" \ +"Ocirc\0Ô\0" \ +"Otilde\0Õ\0" \ +"Ouml\0Ö\0" \ +"times\0×\0" \ +"Oslash\0Ø\0" \ +"Ugrave\0Ù\0" \ +"Uacute\0Ú\0" \ +"Ucirc\0Û\0" \ +"Uuml\0Ü\0" \ +"Yacute\0Ý\0" \ +"THORN\0Þ\0" \ +"szlig\0ß\0" \ +"agrave\0à\0" \ +"aacute\0á\0" \ +"acirc\0â\0" \ +"atilde\0ã\0" \ +"auml\0ä\0" \ +"aring\0å\0" \ +"aelig\0æ\0" \ +"ccedil\0ç\0" \ +"egrave\0è\0" \ +"eacute\0é\0" \ +"ecirc\0ê\0" \ +"euml\0ë\0" \ +"igrave\0ì\0" \ +"iacute\0í\0" \ +"icirc\0î\0" \ +"iuml\0ï\0" \ +"eth\0ð\0" \ +"ntilde\0ñ\0" \ +"ograve\0ò\0" \ +"oacute\0ó\0" \ +"ocirc\0ô\0" \ +"otilde\0õ\0" \ +"ouml\0ö\0" \ +"divide\0÷\0" \ +"oslash\0ø\0" \ +"ugrave\0ù\0" \ +"uacute\0ú\0" \ +"ucirc\0û\0" \ +"uuml\0ü\0" \ +"yacute\0ý\0" \ +"thorn\0þ\0" \ +"yuml\0ÿ\0" \ +"fnof\0ƒ\0" \ +"Alpha\0Α\0" \ +"Beta\0Β\0" \ +"Gamma\0Γ\0" \ +"Delta\0Δ\0" \ +"Epsilon\0Ε\0" \ +"Zeta\0Ζ\0" \ +"Eta\0Η\0" \ +"Theta\0Θ\0" \ +"Iota\0Ι\0" \ +"Kappa\0Κ\0" \ +"Lambda\0Λ\0" \ +"Mu\0Μ\0" \ +"Nu\0Ν\0" \ +"Xi\0Ξ\0" \ +"Omicron\0Ο\0" \ +"Pi\0Π\0" \ +"Rho\0Ρ\0" \ +"Sigma\0Σ\0" \ +"Tau\0Τ\0" \ +"Upsilon\0Υ\0" \ +"Phi\0Φ\0" \ +"Chi\0Χ\0" \ +"Psi\0Ψ\0" \ +"Omega\0Ω\0" \ +"alpha\0α\0" \ +"beta\0β\0" \ +"gamma\0γ\0" \ +"delta\0δ\0" \ +"epsilon\0ε\0" \ +"zeta\0ζ\0" \ +"eta\0η\0" \ +"theta\0θ\0" \ +"iota\0ι\0" \ +"kappa\0κ\0" \ +"lambda\0λ\0" \ +"mu\0μ\0" \ +"nu\0ν\0" \ +"xi\0ξ\0" \ +"omicron\0ο\0" \ +"pi\0π\0" \ +"rho\0ρ\0" \ +"sigmaf\0ς\0" \ +"sigma\0σ\0" \ +"tau\0τ\0" \ +"upsilon\0υ\0" \ +"phi\0φ\0" \ +"chi\0χ\0" \ +"psi\0ψ\0" \ +"omega\0ω\0" \ +"thetasym\0ϑ\0" \ +"upsih\0ϒ\0" \ +"piv\0ϖ\0" \ +"bull\0•\0" \ +"hellip\0…\0" \ +"prime\0′\0" \ +"Prime\0″\0" \ +"oline\0‾\0" \ +"frasl\0⁄\0" \ +"weierp\0℘\0" \ +"image\0ℑ\0" \ +"real\0ℜ\0" \ +"trade\0™\0" \ +"alefsym\0ℵ\0" \ +"larr\0←\0" \ +"uarr\0↑\0" \ +"rarr\0→\0" \ +"darr\0↓\0" \ +"harr\0↔\0" \ +"crarr\0↵\0" \ +"lArr\0⇐\0" \ +"uArr\0⇑\0" \ +"rArr\0⇒\0" \ +"dArr\0⇓\0" \ +"hArr\0⇔\0" \ +"forall\0∀\0" \ +"part\0∂\0" \ +"exist\0∃\0" \ +"empty\0∅\0" \ +"nabla\0∇\0" \ +"isin\0∈\0" \ +"notin\0∉\0" \ +"ni\0∋\0" \ +"prod\0∏\0" \ +"sum\0∑\0" \ +"minus\0−\0" \ +"lowast\0∗\0" \ +"radic\0√\0" \ +"prop\0∝\0" \ +"infin\0∞\0" \ +"ang\0∠\0" \ +"and\0∧\0" \ +"or\0∨\0" \ +"cap\0∩\0" \ +"cup\0∪\0" \ +"int\0∫\0" \ +"there4\0∴\0" \ +"sim\0∼\0" \ +"cong\0≅\0" \ +"asymp\0≈\0" \ +"ne\0≠\0" \ +"equiv\0≡\0" \ +"le\0≤\0" \ +"ge\0≥\0" \ +"sub\0⊂\0" \ +"sup\0⊃\0" \ +"nsub\0⊄\0" \ +"sube\0⊆\0" \ +"supe\0⊇\0" \ +"oplus\0⊕\0" \ +"otimes\0⊗\0" \ +"perp\0⊥\0" \ +"sdot\0⋅\0" \ +"lceil\0⌈\0" \ +"rceil\0⌉\0" \ +"lfloor\0⌊\0" \ +"rfloor\0⌋\0" \ +"lang\0〈\0" \ +"rang\0〉\0" \ +"loz\0◊\0" \ +"spades\0♠\0" \ +"clubs\0♣\0" \ +"hearts\0♥\0" \ +"diams\0♦\0" \ +"quot\0"\0" \ +"amp\0&\0" \ +"lt\0<\0" \ +"gt\0>\0" \ +"OElig\0Œ\0" \ +"oelig\0œ\0" \ +"Scaron\0Š\0" \ +"scaron\0š\0" \ +"Yuml\0Ÿ\0" \ +"circ\0ˆ\0" \ +"tilde\0˜\0" \ +"ensp\0 \0" \ +"emsp\0 \0" \ +"thinsp\0 \0" \ +"zwnj\0‌\0" \ +"zwj\0‍\0" \ +"lrm\0‎\0" \ +"rlm\0‏\0" \ +"ndash\0–\0" \ +"mdash\0—\0" \ +"lsquo\0‘\0" \ +"rsquo\0’\0" \ +"sbquo\0‚\0" \ +"ldquo\0“\0" \ +"rdquo\0”\0" \ +"bdquo\0„\0" \ +"dagger\0†\0" \ +"Dagger\0‡\0" \ +"permil\0‰\0" \ +"lsaquo\0‹\0" \ +"rsaquo\0›\0" \ +"euro\0€\0" + +#endif /* ndef entities_h */ diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/src/lex.c b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/lex.c new file mode 100644 index 000000000..9f9103386 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/lex.c @@ -0,0 +1,560 @@ +/*********************************************************************** + * $Id$ + * Copyright 2009 Aplix Corporation. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***********************************************************************/ +#include +#include +#include +#include +#include "lex.h" +#include "misc.h" +#include "node.h" +#include "process.h" + +struct file { + struct file *next; + const char *filename; + char *buf; + const char *pos, *end; + unsigned int linenum; +}; + +const char keywords[] = KEYWORDS; + +static struct file *file, *firstfile; +static struct tok tok; + +/*********************************************************************** + * readinput : read all input files into memory + * + * Enter: argv = 0-terminated array of filenames + */ +void +readinput(const char *const *argv) +{ + struct file **pfile = &file; + for (;;) { + struct file *file; + const char *filename = *argv++; + char *buf = 0; + int len = 0, thislen, isstdin; + FILE *handle; + if (!filename) + break; + /* Read the file. */ + isstdin = !strcmp(filename, "-"); + if (isstdin) { + handle = stdin; + filename = ""; + } else { + handle = fopen(filename, "rb"); + if (!handle) + errorexit("%s: %s", filename, strerror(errno)); + } + for (;;) { + thislen = len ? len * 2 : 4096; + buf = memrealloc(buf, len + thislen + 1); + thislen = fread(buf + len, 1, thislen, handle); + if (!thislen) + break; + len += thislen; + } + if (ferror(handle)) + errorexit("%s: I/O error", filename); + if (!isstdin) + fclose(handle); + buf[len] = 0; + buf = memrealloc(buf, len + 1); + /* Create the file struct for it. */ + file = memalloc(sizeof(struct file)); + *pfile = file; + pfile = &file->next; + file->filename = filename; + file->pos = file->buf = buf; + file->end = buf + len; + file->linenum = 1; + } + *pfile = 0; + firstfile = file; +} + +/*********************************************************************** + * lexerrorexit : error and exit with line number + */ +static void +lexerrorexit(const char *format, ...) +{ + va_list ap; + va_start(ap, format); + vlocerrorexit(file->filename, file->linenum, format, ap); + va_end(ap); +} + +/*********************************************************************** + * lexblockcomment : lex a block comment + * + * Enter: start = start of comment + * + * Return: tok struct, lifetime until next call to lex + */ +static struct tok * +lexblockcomment(const char *start) +{ + const char *p = start + 1; + tok.filename = file->filename; + tok.linenum = file->linenum; + for (;;) { + int ch = *++p; + if (!ch) + lexerrorexit("unterminated block comment"); + if (ch != '*') { + if (ch == '\n') + file->linenum++; + continue; + } + ch = p[1]; + if (!ch) + lexerrorexit("unterminated block comment"); + if (ch == '/') + break; + } + p += 2; + file->pos = p; + tok.type = TOK_BLOCKCOMMENT; + tok.start = start + 2; + tok.len = p - start - 4; + return &tok; +} + +/*********************************************************************** + * lexinlinecomment : lex an inline comment + * + * Enter: start = start of comment, starts with "//" + * + * Return: tok struct, lifetime until next call to lex + */ +static struct tok * +lexinlinecomment(const char *start) +{ + const char *p = start + 2; + p = start + 1; + for (;;) { + int ch = *++p; + if (!ch || ch == '\n') + break; + } + p++; + file->pos = p; + tok.type = TOK_INLINECOMMENT; + tok.start = start + 2; + tok.len = p - start - 2; + tok.filename = file->filename; + tok.linenum = file->linenum++; + return &tok; +} + +/*********************************************************************** + * lexnumber : lex a number (or just a '-' symbol) + * + * Enter: start = start of token + * + * Return: tok struct, lifetime until next call to lex + * + * The IDL grammar seems to say that a float can't start with a + * decimal point, so that's what we have implemented here. + */ +static struct tok * +lexnumber(const char *start) +{ + for (;;) { + const char *p = start; + const char *octalend = start; + int ch = *p; + enum { STATE_START, STATE_INT, STATE_HEX, STATE_OCTAL, STATE_BADOCTAL, + STATE_DP, STATE_EXPSTART, STATE_EXPSIGN, STATE_EXP + } state = STATE_START; + if (ch == '-') { + ch = *++p; + if (ch == 'I') { // starts of Infinity + char * infinity = "-Infinity"; + unsigned int len = strlen(infinity); + if (!memcmp(start, infinity, len)) { + tok.type = TOK_minusinfinity; + tok.start = start; + tok.len = len; + tok.filename = file->filename; + tok.linenum = file->linenum; + file->pos = start + len; + return &tok; + } + } + } + if (ch == '0') { + state = STATE_OCTAL; + ch = *++p; + if ((ch & ~0x20) == 'X') { + state = STATE_HEX; + ch = *++p; + } + } + + for (;;) { + if ((unsigned)(ch - '0') >= 8) { + if ((ch & -2) == '8') { + if (state == STATE_OCTAL) { + state = STATE_BADOCTAL; + octalend = p; + } + } else if ((unsigned)((ch & ~0x20) - 'A') <= 'F' - 'A') { + if (state != STATE_HEX) { + if ((ch & ~0x20) != 'E') + break; + if (state == STATE_HEX || state >= STATE_EXPSTART || state == STATE_START) + break; + state = STATE_EXPSTART; + } + } else if (ch == '.') { + if (state == STATE_HEX || state >= STATE_DP) + break; + state = STATE_DP; + } else if (ch == '-') { + if (state != STATE_EXPSTART) + break; + state = STATE_EXPSIGN; + } else + break; + } + ch = *++p; + if (state == STATE_START) + state = STATE_INT; + else if (state == STATE_EXPSTART || state == STATE_EXPSIGN) + state = STATE_EXP; + } + switch (state) { + case STATE_START: + /* Must have just been a - character by itself. */ + tok.type = '-'; + p = start + 1; + break; + case STATE_BADOCTAL: + p = octalend; + /* fall through... */ + case STATE_INT: + case STATE_OCTAL: + tok.type = TOK_INTEGER; + break; + case STATE_HEX: + if (p - start == 2 || (p - start == 3 && *start == '-')) + p = start + 1; + tok.type = TOK_INTEGER; + break; + case STATE_EXP: + case STATE_DP: + tok.type = TOK_FLOAT; + break; + case STATE_EXPSIGN: + p--; + /* fall through... */ + case STATE_EXPSTART: + p--; + tok.type = TOK_FLOAT; + break; + } + tok.start = start; + tok.len = p - start; + tok.filename = file->filename; + tok.linenum = file->linenum; + file->pos = p; + return &tok; + } +} + +/*********************************************************************** + * lexstring : lex a quoted string + * + * Enter: start = start of token + * + * Return: tok struct, lifetime until next call to lex + */ +static struct tok * +lexstring(const char *start) +{ + for (;;) { + const char *p = start + 1; + int ch = *p; + for (;;) { + if (!ch || ch == '\n') + lexerrorexit("unterminated string"); + if (ch == '"') { + tok.type = TOK_STRING; + tok.start = start + 1; + tok.len = p - start - 1; + tok.filename = file->filename; + tok.linenum = file->linenum; + file->pos = p + 1; + return &tok; + } + /* Note the IDL spec doesn't seem to allow for escape sequences + * in strings. */ + ch = *++p; + } + } +} + +/*********************************************************************** + * lexidentifier : lex an identifier + * + * Enter: start = start of token + * + * Return: tok struct, lifetime until next call to lex + */ +static struct tok * +lexidentifier(const char *start) +{ + const char *p = start + 1; + for (;;) { + int ch = *p; + if (ch != '_' && (unsigned)(ch - '0') >= 10 + && (unsigned)((ch & ~0x20) - 'A') > 'Z' - 'A') + { + break; + } + p++; + } + tok.type = TOK_IDENTIFIER; + tok.start = start; + tok.len = p - start; + tok.filename = file->filename; + tok.linenum = file->linenum; + file->pos = p; + /* See if this is a keyword. (This search is a bit n-squared.) */ + { + unsigned int type = TOK_DOMString; + p = keywords; + for (;;) { + unsigned int len = strlen(p); + if (!len) + break; + if (len == tok.len && !memcmp(start, p, len)) { + tok.type = type; + break; + } + p += len + 1; + type++; + } + } + return &tok; +} + +/*********************************************************************** + * lex : retrieve next token + * + * Return: tok struct, lifetime until next call to lex + */ +struct tok * +lex(void) +{ + const char *p; + int ch; + for (;;) { + if (!file) { + tok.type = TOK_EOF; + tok.start = "end of file"; + tok.len = strlen(tok.start); + return &tok; + } + tok.prestart = p = file->pos; + /* Flush whitespace. */ + for (;;) { + ch = *p++; + switch (ch) { + case ' ': + case '\t': + case '\r': + continue; + case '\n': + ++file->linenum; + tok.prestart = p; + continue; + } + break; + } + p--; + if (ch) + break; + if (p != file->end) + lexerrorexit("\\0 byte not allowed"); + file = file->next; + } + /* See if we have a comment. */ + tok.start = p; + if (ch == '/') { + switch (*++p) { + case '*': + return lexblockcomment(p - 1); + case '/': + return lexinlinecomment(p - 1); + } + tok.type = '/'; + } else { + /* Handle things that start with '-', which is either '-' as a token, + * or a number. Handle numbers. */ + if (ch == '-' || (unsigned)(ch - '0') < 10) + return lexnumber(p); + /* Handle string. */ + if (ch == '"') + return lexstring(p); + /* Handle identifier. */ + if (ch == '_' || (unsigned)((ch & ~0x20) - 'A') <= 'Z' - 'A') + return lexidentifier(p); + /* The only multi-symbol token are ... and [] */ + if (ch == '.') { + tok.type = '.'; + if (*++p == '.' && p[1] == '.') { + tok.type = TOK_ELLIPSIS; + p += 2; + } + goto done; + } + if (ch == '[') { + tok.type = '['; + if (*++p == ']') { + tok.type = TOK_DOUBLEBRACKET; + p++; + } + goto done; + } + } + /* Single symbol token. */ + tok.type = ch; + p++; +done: + tok.filename = file->filename; + tok.linenum = file->linenum; + tok.len = p - tok.start; + file->pos = p; + return &tok; +} + +/*********************************************************************** + * outputwidl : output literal Web IDL input that node was parsed from + * + * Enter: node = parse node to output literal Web IDL for + */ +void +outputwidl(struct node *node) +{ + const char *start = node->wsstart, *end = node->end; + /* Find the file that start is in. */ + struct file *file = firstfile; + while (start < file->buf || start >= file->end) { + file = file->next; + assert(file); + } + /* Find the (current or) next node that has node->start set. Any such + * node needs to be put inside a element. */ + while (node && !node->start) + node = nodewalk(node); + /* Output until we get to the end. This has to cope with the text + * spanning multiple input files. */ + for (;;) { + int final = end >= file->buf && end <= file->end; + const char *thisend = final ? end : file->end; + /* Output the Web IDL, omitting comments. */ + while (start != end) { + const char *p, *p2, *comment, *endcomment; + int ch; + if (node && start == node->start) { + /* We are on the start of the present node in the tree + * walk. Put it in a . */ + fputs("", stdout); + printtext(node->start, node->end - node->start, 1); + fputs("", stdout); + start = node->end; + /* Skip to the next node with node->start set if any. */ + do + node = nodewalk(node); + while (node && !node->start); + continue; + } + p2 = thisend; + if (node && node->start >= file->buf && node->start < p2) + p2 = node->start; + p = memchr(start, '/', p2 - start); + if (!p) { + printtext(start, p2 - start, 1); + if (p2 != thisend) { + start = p2; + continue; + } + break; + } + /* See if we're at the start of a comment. If so find the end. */ + comment = 0; + if (p + 1 != thisend) { + switch (p[1]) { + case '*': + /* Block comment. */ + comment = p; + p++; + do + p = memchr(p + 1, '*', thisend - p - 1); + while (p[1] != '/'); + endcomment = p + 2; + break; + case '/': + /* Inline comment. */ + comment = p; + p = memchr(p, '\n', thisend - p); + if (!p) + p = thisend; + endcomment = p; + break; + } + } + if (!comment) { + /* Not at start of comment. */ + p++; + printtext(start, p - start, 1); + start = p; + assert(start <= end); + continue; + } + /* If the comment has only whitespace before it on the line, + * eat that up. */ + p = comment; + while (p != start && ((ch = p[-1]) == ' ' || ch == '\t')) + p--; + if (p == start || p[-1] == '\n') { + comment = p; + /* If the comment has only whitespace after it to the end + * of the line, eat that and the newline up. This always + * happens for an inline comment on a line by itself. */ + p = endcomment; + while (p != thisend && ((ch = *p) == ' ' || ch == '\t')) + p++; + if (p != thisend && *p == '\n') + p++; + endcomment = p; + } + printtext(start, comment - start, 1); + start = endcomment; + if (start > thisend) + start = thisend; + } + if (final) + break; + file = file->next; + assert(file); + start = file->buf; + } +} diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/src/lex.h b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/lex.h new file mode 100644 index 000000000..e30b77b36 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/lex.h @@ -0,0 +1,141 @@ + +/*********************************************************************** + * $Id$ + * Copyright 2009 Aplix Corporation. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***********************************************************************/ +#ifndef lex_h +#define lex_h + +// starting from "attribute" are the list of names allowed as arguments identifier +#define KEYWORDS \ + "DOMString\0" \ + "ByteString\0" \ + "Date\0" \ + "RegExp\0" \ + "false\0" \ + "object\0" \ + "true\0" \ + "any\0" \ + "boolean\0" \ + "byte\0" \ + "double\0" \ + "float\0" \ + "Infinity\0" \ + "-Infinity\0" \ + "iterator\0" \ + "long\0" \ + "NaN\0" \ + "null\0" \ + "octet\0" \ + "optional\0" \ + "or\0" \ + "readonly\0" \ + "sequence\0" \ + "short\0" \ + "unsigned\0" \ + "void\0" \ + "attribute\0" \ + "callback\0" \ + "const\0" \ + "creator\0" \ + "deleter\0" \ + "dictionary\0" \ + "enum\0" \ + "exception\0" \ + "getter\0" \ + "implements\0" \ + "inherit\0" \ + "interface\0" \ + "legacycaller\0" \ + "partial\0" \ + "serializer\0" \ + "setter\0" \ + "static\0" \ + "stringifier\0" \ + "typedef\0" \ + "unrestricted\0" + + +enum toktype { + TOK_EOF = -1, + TOK_BLOCKCOMMENT = 0x80, + TOK_INLINECOMMENT, TOK_INTEGER, TOK_FLOAT, TOK_IDENTIFIER, + TOK_STRING, TOK_ELLIPSIS, TOK_DOUBLEBRACKET, + /* Keywords must be in the same order as above. */ + TOK_DOMString, + TOK_ByteString, + TOK_Date, + TOK_RegExp, + TOK_false, + TOK_object, + TOK_true, + TOK_any, + TOK_boolean, + TOK_byte, + TOK_double, + TOK_float, + TOK_infinity, + TOK_minusinfinity, + TOK_iterator, + TOK_long, + TOK_NaN, + TOK_null, + TOK_octet, + TOK_optional, + TOK_or, + TOK_readonly, + TOK_sequence, + TOK_short, + TOK_unsigned, + TOK_void, + /* Below that line are keywords that are allowed as arguments names */ + TOK_attribute, + TOK_callback, + TOK_const, + TOK_creator, + TOK_deleter, + TOK_dictionary, + TOK_enum, + TOK_exception, + TOK_getter, + TOK_implements, + TOK_inherit, + TOK_interface, + TOK_legacycaller, + TOK_partial, + TOK_serializer, + TOK_setter, + TOK_static, + TOK_stringifier, + TOK_typedef, + TOK_unrestricted, +}; + +struct tok { + enum toktype type; + const char *filename; + unsigned int linenum; + const char *prestart; + const char *start; + unsigned int len; +}; + +extern const char *filename; +extern const char keywords[]; + +struct node; + +void readinput(const char *const *argv); +struct tok *lex(void); +void outputwidl(struct node *node); + +#endif /* ndef lex_h */ diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/src/main.c b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/main.c new file mode 100644 index 000000000..df90e347d --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/main.c @@ -0,0 +1,63 @@ +/*********************************************************************** + * $Id$ + * Copyright 2009 Aplix Corporation. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***********************************************************************/ +#include +#include "misc.h" +#include "process.h" + +static const char nodtdopt[] = "-no-dtd-ref"; +const char *progname; + +/*********************************************************************** + * options : process command line options + * + * Enter: argv + * + * Return: argv stepped to point to first non-option argument + */ +static const char *const * +options(int argc, const char *const *argv) +{ + /* Set progname for error messages etc. */ + { + const char *base; + progname = argv[0]; + base = strrchr(progname, '/'); +#ifdef DIRSEP + { + const char *base2 = strrchr(base, '\\'); + if (base2 > base) + base = base2; + } +#endif /* def DIRSEP */ + if (base) + progname = base + 1; + } + return (argc > 1 && strncmp(argv[1], nodtdopt, sizeof nodtdopt) == 0) + ? argv + 2 : argv + 1; +} + +/*********************************************************************** + * main : main code for bondiidl command + */ +int +main(int argc, char **argv) +{ + const char *const *parg; + parg = options(argc, (const char *const *)argv); + if (!*parg) + errorexit("usage: %s [-no-dtd-ref] .widl ...", progname); + processfiles(parg, parg == (const char *const *)argv + 1); + return 0; +} + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/src/misc.c b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/misc.c new file mode 100644 index 000000000..37aff3f34 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/misc.c @@ -0,0 +1,119 @@ +/*********************************************************************** + * $Id$ + * Copyright 2009 Aplix Corporation. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***********************************************************************/ +#include +#include +#include +#include +#include "misc.h" +#include "os.h" /* to get va_copy on windows */ + +extern const char *progname; + +/*********************************************************************** + * memory allocation wrappers + */ +void * +memalloc(size_t size) +{ + void *ptr = malloc(size); + if (!ptr) + errorexit("out of memory"); + /* Zero initialise memory from memalloc. */ + memset(ptr, 0, size); + return ptr; +} + +void * +memrealloc(void *ptr, size_t size) +{ + void *newptr = realloc(ptr, size); + if (!newptr) + errorexit("out of memory"); + return newptr; +} + +void +memfree(void *ptr) +{ + *(int *)ptr = 0xfefefefe; + free(ptr); +} + +/*********************************************************************** + * vmemprintf, memprintf : allocate buffer and sprintf into it + */ +char * +memprintf(const char *format, ...) +{ + va_list ap; + char *buf; + va_start(ap, format); + buf = vmemprintf(format, ap); + va_end(ap); + return buf; +} + +char * +vmemprintf(const char *format, va_list ap) +{ + char *buf; + unsigned int max, len; + va_list ap2; + max = 16; + for (;;) { + va_copy(ap2, ap); + buf = memalloc(max); + len = vsnprintf(buf, max, format, ap2); + va_end(ap2); + if (len < max) + break; + memfree(buf); + max *= 2; + } + return buf; +} + +/*********************************************************************** + * errorexit : print error message then exit + */ +void +vlocerrorexit(const char *filename, unsigned int linenum, + const char *format, va_list ap) +{ + if (filename) + fprintf(stderr, linenum ? "%s: %i: " : "%s: ", filename, linenum); + vfprintf(stderr, format, ap); + fputc('\n', stderr); + exit(1); +} + +void +locerrorexit(const char *filename, unsigned int linenum, + const char *format, ...) +{ + va_list ap; + va_start(ap, format); + vlocerrorexit(filename, linenum, format, ap); + va_end(ap); +} + +void +errorexit(const char *format, ...) +{ + va_list ap; + va_start(ap, format); + vlocerrorexit(0, 0, format, ap); + va_end(ap); +} + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/src/misc.h b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/misc.h new file mode 100644 index 000000000..01c36d218 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/misc.h @@ -0,0 +1,31 @@ +/*********************************************************************** + * $Id$ + * Copyright 2009 Aplix Corporation. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***********************************************************************/ +#ifndef misc_h +#define misc_h +#include +#include + +void *memalloc(size_t size); +void *memrealloc(void *ptr, size_t size); +void memfree(void *ptr); + +char *vmemprintf(const char *format, va_list ap); +char *memprintf(const char *format, ...); + +void vlocerrorexit(const char *filename, unsigned int linenum, const char *format, va_list ap); +void locerrorexit(const char *filename, unsigned int linenum, const char *format, ...); +void errorexit(const char *format, ...); + +#endif /* ndef misc_h */ + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/src/node.c b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/node.c new file mode 100644 index 000000000..d8f737909 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/node.c @@ -0,0 +1,331 @@ +/*********************************************************************** + * $Id$ + * Copyright 2009 Aplix Corporation. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Node-specific functions + ***********************************************************************/ +#include +#include +#include +#include "comment.h" +#include "lex.h" +#include "misc.h" +#include "node.h" +#include "process.h" + +struct node * +newelement(const char *name) +{ + struct element *element = memalloc(sizeof(struct element)); + element->n.type = NODE_ELEMENT; + element->name = name; + return &element->n; +} + +struct node * +newattr(const char *name, const char *val) +{ + struct attr *attr = memalloc(sizeof(struct attr)); + attr->n.type = NODE_ATTR; + attr->name = name; + attr->value = val; + return &attr->n; +} + +struct node * +newattrlist(void) +{ + struct attrlist *attrlist = memalloc(sizeof(struct attrlist)); + attrlist->n.type = NODE_ATTRLIST; + return &attrlist->n; +} + +/*********************************************************************** + * addnode : add node as child of another node + * + * Enter: parent node + * child node + * + * The children list is constructed backwards. This is fixed later with + * a call to reversechildren. + * + * If child is an attrlist, its children are added to parent and the + * attrlist is freed. + */ +void +addnode(struct node *parent, struct node *child) +{ + if (!child) + return; + if (child->type == NODE_ATTRLIST) { + /* Add the attrs in the attrlist to parent. */ + struct node *child2; + reversechildren(child); + child2 = child->children; + memfree(child); + while (child2) { + struct node *next = child2->next; + addnode(parent, child2); + child2 = next; + } + } else { + child->next = parent->children; + parent->children = child; + child->parent = parent; + } +} + +/*********************************************************************** + * reversechildren : recursively reverse child lists + * + * Also sets parent field on each node. + */ +void +reversechildren(struct node *node) +{ + struct node *newlist = 0; + struct node *child = node->children; + while (child) { + struct node *next = child->next; + child->parent = node; + child->next = newlist; + newlist = child; + reversechildren(child); + child = next; + } + node->children = newlist; +} + +/*********************************************************************** + * nodeisempty : test if node is empty (has no children) + */ +int +nodeisempty(struct node *node) +{ + return !node->children; +} + +/*********************************************************************** + * nodewalk : single step of depth last traversal of node tree + * + * Return: next node in walk, 0 if finished + */ +struct node * +nodewalk(struct node *node) +{ + if (node->children) + return node->children; + if (node->next) + return node->next; + do { + node = node->parent; + if (!node) + return 0; + } while (!node->next); + return node->next; +} + +/*********************************************************************** + * findchildelement : find child element of a particular name + * + * Enter: node = element + * name = name to find + * + * Return: 0 else child element of that name + */ +static struct node * +findchildelement(struct node *node, const char *name) +{ + node = node->children; + while (node) { + if (node->type == NODE_ELEMENT) { + struct element *element = (void *)node; + if (!strcmp(element->name, name)) + break; + } + node = node->next; + } + return node; +} + +/*********************************************************************** + * getattr : get value of attribute + * + * Enter: node = element to find attribute in + * name = name of attribute + * + * Return: 0 if not found, else 0-terminated string value + */ +const char * +getattr(struct node *node, const char *name) +{ + node = node->children; + while (node) { + if (node->type == NODE_ATTR) { + struct attr *attr = (void *)node; + if (!strcmp(attr->name, name)) + return attr->value; + } + node = node->next; + } + return 0; +} + +/*********************************************************************** + * findchildelementwithnameattr : find child element with a name attribute + * of a particular value + * + * Enter: node = element + * name = name to find + * + * Return: 0 else child element with name attr of that value + */ +static struct node * +findchildelementwithnameattr(struct node *node, const char *name) +{ + node = node->children; + while (node) { + if (node->type == NODE_ELEMENT) { + const char *s = getattr(node, "name"); + if (s && !strcmp(s, name)) + break; + } + node = node->next; + } + return node; +} + +/*********************************************************************** + * findreturntype : find Type parse node for return type + * + * Enter: node = Operation element + * + * Return: 0 if not found, else Type parse node for return type + */ +struct node * +findreturntype(struct node *node) +{ + return findchildelement(node, "Type"); +} + +/*********************************************************************** + * findparamidentifier : find identifier parse node for parameter + * + * Enter: node = Operation element + * name = parameter name to find + * + * Return: 0 if not found, else node struct for parameter identifier + */ +struct node * +findparamidentifier(struct node *node, const char *name) +{ + node = findchildelement(node, "ArgumentList"); + if (node) + node = findchildelementwithnameattr(node, name); + return node; +} + +/*********************************************************************** + * findthrowidentifier : find identifier parse node for exception name + * + * Enter: node = Operation element + * name = exception name to find + * + * Return: 0 if not found, else node for Name element, child of Raises + * or SetRaises + */ +struct node * +findthrowidentifier(struct node *node, const char *name) +{ + struct node *node2 = findchildelement(node, "Raises"); + if (node2) + node2 = findchildelementwithnameattr(node2, name); + if (!node2) { + node2 = findchildelement(node, "SetRaises"); + if (node2) + node2 = findchildelementwithnameattr(node2, name); + } + return node2; +} + +/*********************************************************************** + * outputid : output the id of a node + */ +static void +outputid(struct node *node) +{ + if (node->parent) + outputid(node->parent); + if (node->id) { + fputs("::", stdout); + printtext(node->id, strlen(node->id), 1); + } +} + +/*********************************************************************** + * outputnode : output node and its children + * + * Enter: node = node to output, assumed to be an element + * indent + */ +void +outputnode(struct node *node, unsigned int indent) +{ + struct element *element = (void *)node; + struct node *child; + int empty = 1; + printf("%*s<%s", indent, "", element->name); + child = element->n.children; + while (child) { + switch(child->type) { + case NODE_ELEMENT: + empty = 0; + break; + case NODE_ATTR: + { + struct attr *attr = (void *)child; + printf(" %s=\"", attr->name); + printtext(attr->value, strlen(attr->value), 1); + printf("\""); + } + break; + } + child = child->next; + } + if (node->id) { + printf(" id=\""); + outputid(node); + printf("\""); + } + if (!empty || node->comments || node->wsstart) { + printf(">\n"); + if (node->wsstart) { + printf("%*s ", indent, ""); + outputwidl(node); + printf("\n"); + } + outputdescriptive(node, indent + 2); + child = element->n.children; + while (child) { + switch(child->type) { + case NODE_ELEMENT: + outputnode(child, indent + 2); + break; + } + child = child->next; + } + printf("%*s\n", indent, "", element->name); + } else + printf("/>\n"); +} + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/src/node.h b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/node.h new file mode 100644 index 000000000..2d6e38e53 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/node.h @@ -0,0 +1,65 @@ +/*********************************************************************** + * $Id$ + * Copyright 2009 Aplix Corporation. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***********************************************************************/ +#ifndef node_h +#define node_h + +/* struct node : a node in the parse tree (excluding comments) */ +enum { NODE_ELEMENT, NODE_ATTR, NODE_ATTRLIST }; +struct node { + int type; + struct node *next; + struct node *parent; + struct node *children; + struct comment *comments; /* list of comments attached to this node */ + /* If wsstart and end are set, they give the literal Web IDL that can + * be output in a element. */ + const char *wsstart; + /* If start and end are set, they give the text of a scoped name that + * can be enclosed in a when outputting a element for + * an ancestor element. */ + const char *start; + const char *end; + const char *id; +}; + +struct element { + struct node n; + const char *name; +}; + +struct attr { + struct node n; + const char *name; + const char *value; +}; + +struct attrlist { + struct node n; +}; + +struct node *newelement(const char *name); +struct node *newattr(const char *name, const char *val); +struct node *newattrlist(void); +void addnode(struct node *parent, struct node *child); +void reversechildren(struct node *node); +int nodeisempty(struct node *node); +const char *getattr(struct node *node, const char *name); +struct node *nodewalk(struct node *node); +struct node *findreturntype(struct node *node); +struct node *findparamidentifier(struct node *node, const char *name); +struct node *findthrowidentifier(struct node *node, const char *name); +void outputnode(struct node *node, unsigned int indent); + +#endif /* ndef node_h */ + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/src/os.h b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/os.h new file mode 100644 index 000000000..ac8f4189d --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/os.h @@ -0,0 +1,31 @@ +/*********************************************************************** + * $Id$ + * Copyright 2009 Aplix Corporation. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***********************************************************************/ +#ifndef os_h +#define os_h + +/* Linux configuration */ +#if defined(__gnu_linux__) + + +/* Windows configuration */ +#elif defined(_MSC_VER) + +#define inline __inline +#define strncasecmp strnicmp +#define snprintf _snprintf +#define va_copy(a,b) ((a)=(b)) + +#endif + +#endif /* ndef os_h */ diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/src/parse.c b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/parse.c new file mode 100644 index 000000000..c0e8454ce --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/parse.c @@ -0,0 +1,1414 @@ +/*********************************************************************** + * $Id$ + * Copyright 2009 Aplix Corporation. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Hand-crafted recursive descent parser for Web IDL grammar. + ***********************************************************************/ +#include +#include +#include +#include + +#include "comment.h" +#include "lex.h" +#include "misc.h" +#include "node.h" +#include "parse.h" + +/*********************************************************************** + * tokerrorexit : error and exit with line number from token + */ +static void +tokerrorexit(struct tok *tok, const char *format, ...) +{ + va_list ap; + char *m; + va_start(ap, format); + m = vmemprintf(format, ap); + if (tok->type == TOK_EOF) + locerrorexit(tok->filename, tok->linenum, "at end of input: %s", m); + else + locerrorexit(tok->filename, tok->linenum, "at '%.*s': %s", tok->len, tok->start, m); + va_end(ap); +} + +/*********************************************************************** + * lexnocomment : lex next token, discarding or storing comments + * + * A block comment starting with |** or |*! is a doxygen comment. + * If it starts with |**< or |*!< then it refers to the previous + * identifier, not the next one. (I am using | to represent / otherwise + * this comment would be illegal.) + * + * An inline comment starting with /// or //! is a doxygen comment. + * If it starts with ///< or //!< then it refers to the previous + * identifier, not the next one. + */ +static struct tok * +lexnocomment(void) +{ + struct tok *tok; + for (;;) { + tok = lex(); + if (tok->type != TOK_BLOCKCOMMENT && tok->type != TOK_INLINECOMMENT) + break; + addcomment(tok); + } + return tok; +} + +/*********************************************************************** + * eat : check token then read the following one + * + * Enter: tok struct + * type = type of token expected, error given if no match + * + * On return, tok is updated to the following token. + */ +static void +eat(struct tok *tok, int type) +{ + if (tok->type != type) { + const char *p; + if (type < TOK_DOMString) + tokerrorexit(tok, "expected '%c'", type); + p = keywords; + while (type != TOK_DOMString) { + p += strlen(p) + 1; + type--; + } + tokerrorexit(tok, "expected '%s'", p); + } + lexnocomment(); +} + +/*********************************************************************** + * setid : flag that an id attribute is required on node + * + * Enter: node + * + * node->id is set to the value of the name attribute. This makes + * outputnode give it an id attribute whose value is the id attribute + * of the parent if any, then "::", then node->id. + */ +static void +setid(struct node *node) +{ + node->id = getattr(node, "name"); +} + +/*********************************************************************** + * setidentifier : allocate 0-terminated string for identifier token + * + * Enter: tok = token, error given if not identifier + * + * Return: allocated 0-terminated string + */ +static char * +setidentifier(struct tok *tok) +{ + char *s; + if (tok->type != TOK_IDENTIFIER) + tokerrorexit(tok, "expected identifier"); + s = memprintf("%.*s", tok->len, tok->start); + return s; +} + +/*********************************************************************** + * setargumentname : allocate 0-terminated string for identifier token + * + * Enter: tok = token, error given if not identifier + * + * Return: allocated 0-terminated string + */ +static char * +setargumentname(struct tok *tok) +{ + char *s; + if (tok->type != TOK_IDENTIFIER && tok->type < TOK_attribute) + tokerrorexit(tok, "expected argument name"); + s = memprintf("%.*s", tok->len, tok->start); + return s; +} + + +/* Prototypes for funcs that have a forward reference. */ +static struct node *parsetype(struct tok *tok); +static struct node *parsedefaultvalue(struct tok *tok, struct node *parent); +static struct node *parseuniontype(struct tok *tok); +static struct node *parseargumentlist(struct tok *tok); +static void parsedefinitions(struct tok *tok, struct node *parent); +static struct node *parsetypesuffixstartingwitharray(struct tok *tok, struct node *node); + +/*********************************************************************** + * parsescopedname : parse [53] ScopedName + * + * Enter: tok = next token + * name = name of attribute to put scoped name in + * ref = whether to enable enclosing of the name in in + * outputwidl + * + * Return: node struct for new attribute + * tok updated + */ +static struct node * +parsescopedname(struct tok *tok, const char *name, int ref) +{ + const char *start = tok->start, *end; + struct node *node; + unsigned int len = 0; + char *s = memalloc(3); + if (tok->type != TOK_IDENTIFIER) + tokerrorexit(tok, "expected identifier"); + s = memrealloc(s, len + tok->len + 1); + memcpy(s + len, tok->start, tok->len); + len += tok->len; + end = tok->start + tok->len; + lexnocomment(); + s[len] = 0; + node = newattr(name, s); + if (ref) { + node->start = start; + node->end = end; + } + return node; +} + +/*********************************************************************** + * parsescopednamelist : parse [51] ScopedNameList + * + * Enter: tok = next token + * name = name of element for scoped name list + * name2 = name of element for entry in list + * comment = whether to attach documentation to each name + * + * Return: node for list of scoped names + * tok updated + */ +static struct node * +parsescopednamelist(struct tok *tok, const char *name, const char *name2, + int comment) +{ + struct node *node = newelement(name); + for (;;) { + struct node *attr = parsescopedname(tok, "name", 1); + struct node *n = newelement(name2); + if (comment) + setcommentnode(n); + addnode(n, attr); + addnode(node, n); + if (tok->type != ',') + break; + lexnocomment(); + } + return node; +} + +/*********************************************************************** + * parsereturntype : parse [50] ReturnType + * + * Enter: tok = next token + * + * Return: node for type + * tok updated + */ +static struct node * +parsereturntype(struct tok *tok) +{ + if (tok->type == TOK_void) { + struct node *node = newelement("Type"); + addnode(node, newattr("type", "void")); + lexnocomment(); + return node; + } + return parsetype(tok); +} + +/*********************************************************************** + * parseunsignedintegertype : parse [46] UnsignedIntegerType + * + * Enter: tok = next token (one of "unsigned", "short" or "long") + * + * Return: 0-terminated canonical string for the type + * tok updated to just past UnsignedIntegerType + */ +static const char * +parseunsignedintegertype(struct tok *tok) +{ + static const char *names[] = { + "short", "long", "long long", 0, + "unsigned short", "unsigned long", "unsigned long long" }; + enum { TYPE_SHORT, TYPE_LONG, TYPE_LONGLONG, + TYPE_UNSIGNED = 4 }; + int type = 0; + if (tok->type == TOK_unsigned) { + type = TYPE_UNSIGNED; + lexnocomment(); + } + if (tok->type == TOK_short) { + type |= TYPE_SHORT; + lexnocomment(); + } else if (tok->type != TOK_long) + tokerrorexit(tok, "expected 'short' or 'long' after 'unsigned'"); + else { + type |= TYPE_LONG; + lexnocomment(); + if (tok->type == TOK_long) { + type += TYPE_LONGLONG - TYPE_LONG; + lexnocomment(); + } + } + return names[type]; +} +/*********************************************************************** + * parsetypesuffix : parse [44] TypeSuffix + * + * Enter: tok = next token + * + * Return: node for type + * tok updated + */ +static struct node * +parsetypesuffix(struct tok *tok, struct node *node) +{ + if (tok->type == TOK_DOUBLEBRACKET) { + struct node *typenode = node; + node = newelement("Type"); + addnode(node, newattr("type", "array")); + addnode(node, typenode); + lexnocomment(); + node = parsetypesuffix(tok, node); + } else if (tok->type == '?') { + addnode(node, newattr("nullable", "nullable")); + lexnocomment(); + node = parsetypesuffixstartingwitharray(tok, node); + } + return node; +} + +/*********************************************************************** + * parsetypesuffixstartingwitharray : parse [44] TypeSuffixStartingWithArray + * + * Enter: tok = next token + * + * Return: node for type + * tok updated + */ +static struct node * +parsetypesuffixstartingwitharray(struct tok *tok, struct node *node) +{ + if (tok->type == TOK_DOUBLEBRACKET) { + struct node *typenode = node; + node = newelement("Type"); + addnode(node, newattr("type", "array")); + addnode(node, typenode); + lexnocomment(); + node = parsetypesuffix(tok, node); + } + return node; +} + +/*********************************************************************** + * parseprimitiveorstringtype : parse [45] PrimitiveOrString + * + * Enter: tok = next token + * + * Return: node for type + * tok updated + */ +static struct node * +parseprimitiveorstringtype(struct tok *tok) +{ + struct node *node; + switch (tok->type) { + case TOK_unsigned: + case TOK_short: + case TOK_long: + node = newelement("Type"); + addnode(node, newattr("type", parseunsignedintegertype(tok))); + break; + default: + node = newelement("Type"); + switch (tok->type) { + default: + tokerrorexit(tok, "expected type"); + break; + case TOK_unrestricted: + lexnocomment(); + if (tok->type == TOK_float) { + addnode(node, newattr("type", "unrestricted float")); + } else if (tok->type == TOK_double) { + addnode(node, newattr("type", "unrestricted double")); + } else { + tokerrorexit(tok, "expected float or double after unrestricted"); + } + break; + case TOK_boolean: + addnode(node, newattr("type", "boolean")); + break; + case TOK_byte: + addnode(node, newattr("type", "byte")); + break; + case TOK_octet: + addnode(node, newattr("type", "octet")); + break; + case TOK_float: + addnode(node, newattr("type", "float")); + break; + case TOK_double: + addnode(node, newattr("type", "double")); + break; + case TOK_DOMString: + addnode(node, newattr("type", "DOMString")); + break; + case TOK_ByteString: + addnode(node, newattr("type", "ByteString")); + break; + case TOK_Date: + addnode(node, newattr("type", "Date")); + break; + case TOK_RegExp: + addnode(node, newattr("type", "RegExp")); + break; + + } + lexnocomment(); + } + return node; +} + +/*********************************************************************** + * parsenonanytype : parse NonAnyType + * + * Enter: tok = next token + * + * Return: node for type + * tok updated + */ +static struct node * +parsenonanytype(struct tok *tok) +{ + struct node *node; + switch (tok->type) { + case TOK_IDENTIFIER: + node = newelement("Type"); + addnode(node, parsescopedname(tok, "name", 1)); + node = parsetypesuffix(tok, node); + break; + case TOK_sequence: + node = newelement("Type"); + addnode(node, newattr("type", "sequence")); + lexnocomment(); + eat(tok, '<'); + addnode(node, parsetype(tok)); + eat(tok, '>'); + if (tok->type == '?') { + addnode(node, newattr("nullable", "nullable")); + lexnocomment(); + } + break; + case TOK_object: + node = newelement("Type"); + addnode(node, newattr("type", "object")); + lexnocomment(); + node = parsetypesuffix(tok, node); + break; + default: + node = parseprimitiveorstringtype(tok); + node = parsetypesuffix(tok, node); + break; + } + return node; +} + +/*********************************************************************** + * parseunionmembertype: parse UnionMemberType + * + * Enter: tok = next token + * + * Return: node for type + * tok updated + */ +static struct node * +parseunionmembertype(struct tok *tok) +{ + struct node *node; + if (tok->type == TOK_any) { + struct node *typenode = newelement("Type"); + addnode(typenode, newattr("type", "any")); + lexnocomment(); + eat(tok, TOK_DOUBLEBRACKET); + node = newelement("Type"); + addnode(node, newattr("type", "array")); + addnode(node, typenode); + lexnocomment(); + node = parsetypesuffix(tok, node); + } else if (tok->type == '(') { + node = parseuniontype(tok); + } else { + node = parsenonanytype(tok); + } + return node; +} + + +/*********************************************************************** + * parseuniontype : parse UnionType + * + * Enter: tok = next token + * + * Return: node for type + * tok updated + */ +static struct node * +parseuniontype(struct tok *tok) +{ + struct node *node; + eat(tok, '('); + node = newelement("Type"); + addnode(node, newattr("type", "union")); + if (tok->type != ')') { + for (;;) { + addnode(node, parseunionmembertype(tok)); + if (tok->type != TOK_or) + break; + lexnocomment(); + } + } + eat(tok, ')'); + node = parsetypesuffix(tok, node); + return node; +} + +/*********************************************************************** + * parsetype : parse [44] Type + * + * Enter: tok = next token + * + * Return: node for type + * tok updated + */ +static struct node * +parsetype(struct tok *tok) +{ + struct node *node; + if (tok->type == '(') { + node = parseuniontype(tok); + } else if (tok->type == TOK_any) { + node = newelement("Type"); + addnode(node, newattr("type", "any")); + lexnocomment(); + node = parsetypesuffixstartingwitharray(tok, node); + } else { + node = parsenonanytype(tok); + } + return node; +} + + +/*********************************************************************** + * parseextendedattribute : parse [39] ExtendedAttribute + * + * Enter: tok = next token + * + * Return: node for extended attribute + * + * This parses the various forms of extended attribute, as in + * rules [57] [58] [59] [60] [61]. + * + * This does not spot the error that you cannot have a ScopedName + * and an ArgumentList. + */ +static struct node * +parseextendedattribute(struct tok *tok) +{ + const char *start ; + struct node *node = newelement("ExtendedAttribute"); + char *attrname = setidentifier(tok); + addnode(node, newattr("name", attrname)); + start = tok->prestart; + node->wsstart = start; + node->end = tok->start + tok->len; + if(!strcmp(attrname, "Constructor") || !strcmp(attrname, "NamedConstructor")) { + setcommentnode(node); + } + lexnocomment(); + if (tok->type == '=') { + lexnocomment(); + addnode(node, parsescopedname(tok, "value", 0)); + } + if (tok->type == '(') { + lexnocomment(); + addnode(node, parseargumentlist(tok)); + node->end = tok->start + tok->len; + eat(tok, ')'); + } + return node; +} + +/*********************************************************************** + * parseextendedattributelist : parse [37] ExtendedAttributeList + * + * Enter: tok = next token + * + * Return: 0 else node for extended attribute list + * tok updated if anything parsed + */ +static struct node * +parseextendedattributelist(struct tok *tok) +{ + struct node *node; + if (tok->type != '[') + return 0; + node = newelement("ExtendedAttributeList"); + for (;;) { + lexnocomment(); + addnode(node, parseextendedattribute(tok)); + if (tok->type != ',') + break; + } + if (tok->type != ']') + tokerrorexit(tok, "expected ',' or ']'"); + lexnocomment(); + return node; +} + +/*********************************************************************** + * parseexceptionfield : parse [36] ExceptionField + * + * Enter: tok = next token + * eal = 0 else extended attribute list node + * + * Return: new node for the exceptionfield + * tok updated + */ +static struct node * +parseexceptionfield(struct tok *tok, struct node *eal) +{ + struct node *node = newelement("ExceptionField"); + if (eal) addnode(node, eal); + setcommentnode(node); + addnode(node, parsetype(tok)); + addnode(node, newattr("name", setidentifier(tok))); + tok = lexnocomment(); + return node; +} + +/*********************************************************************** + * parseargument : parse [31] Argument + * + * Enter: tok = next token + * + * Return: new node + * + * tok updated on return + */ +static struct node * +parseargument(struct tok *tok) +{ + struct node *node = newelement("Argument"); + struct node *eal = parseextendedattributelist(tok); + setcommentnode(node); + if (eal) addnode(node, eal); + if (tok->type == TOK_optional) { + addnode(node, newattr("optional", "optional")); + lexnocomment(); + } + addnode(node, parsetype(tok)); + if (tok->type == TOK_ELLIPSIS) { + addnode(node, newattr("ellipsis", "ellipsis")); + lexnocomment(); + } + addnode(node, newattr("name", setargumentname(tok))); + lexnocomment(); + // Optional default value + if (tok->type == '=') { + tok = lexnocomment(); + node = parsedefaultvalue(tok, node); + } + return node; +} + +/*********************************************************************** + * parseargumentlist : parse [29] ArgumentList + * + * Enter: tok = next token + * + * Return: new node for the arglist + * tok updated + */ +static struct node * +parseargumentlist(struct tok *tok) +{ + struct node *node = newelement("ArgumentList"); + /* We rely on the fact that ArgumentList is always followed by ')'. */ + if (tok->type != ')') { + for (;;) { + addnode(node, parseargument(tok)); + if (tok->type != ',') + break; + lexnocomment(); + } + } + return node; +} + + +/*********************************************************************** + * parseoperationrest : parse [25] OperationRest + * + * Enter: tok = next token + * node + * + * Return: node + * tok on terminating ';' + */ +static struct node * +parseoperationrest(struct tok *tok, struct node *node) +{ + if (tok->type == TOK_IDENTIFIER) { + addnode(node, newattr("name", setidentifier(tok))); + lexnocomment(); + } + eat(tok, '('); + addnode(node, parseargumentlist(tok)); + eat(tok, ')'); + return node; +} + +/*********************************************************************** + * parsereturntypeandoperationrest: parse ReturnType OperationRest + * Enter: tok = next token + * eal + * attrs list of attributes + * Return: node + * tok on terminating ';' + */ +static struct node * +parsereturntypeandoperationrest(struct tok *tok, struct node *eal, struct node *attrs) +{ + struct node *node = newelement("Operation"); + struct node *nodeType = parsereturntype(tok); + if (eal) addnode(node, eal); + setcommentnode(node); + addnode(node, attrs); + addnode(node, nodeType); + return parseoperationrest(tok, node); +} + +/*********************************************************************** + * parseiteratorrest : parse OptionalIteratorInterface + * + * Enter: tok = next token + * node + * + * Return: node + * tok on terminating ';' + */ +static struct node * +parseoptionaliteratorinterface(struct tok *tok, struct node *node) +{ + if (tok->type == '=') { + lexnocomment(); + addnode(node, newattr("interface", setidentifier(tok))); + lexnocomment(); + } + return node; +} + +/*********************************************************************** + * parseoperationoriteratorrest : parse [25] OperationOrIteratorRest + * + * Enter: tok = next token + * eal = 0 else extended attribute list node + * attrs = list-of-attrs node containing attrs to add to new node + * + * Return: new node + * tok on terminating ';' + */ +static struct node * +parseoperationoriteratorrest(struct tok *tok, struct node *eal, struct node *attrs) +{ + struct node *node; + struct node *nodeType = parsereturntype(tok); + unsigned int isIterator = 0; + if (tok->type == TOK_iterator) { + lexnocomment(); + if (tok->type == TOK_object) { + lexnocomment(); + node = newelement("IteratorObject"); + addnode(node, nodeType); + return node; + } else { + node = newelement("Iterator"); + isIterator = 1; + } + } else { + node = newelement("Operation"); + } + if (eal) addnode(node, eal); + setcommentnode(node); + addnode(node, attrs); + addnode(node, nodeType); + if (isIterator) + return parseoptionaliteratorinterface(tok, node); + else + return parseoperationrest(tok, node); +} + + +/*********************************************************************** + * parseattribute : parse [17] Attribute + * + * Enter: tok = next token ("readonly" or "attribute") + * eal = 0 else extended attribute list node + * attrs = list-of-attrs node containing attrs to add to new node + * + * Return: node + * tok on terminating ';' + */ +static struct node * +parseattribute(struct tok *tok, struct node *eal, struct node *attrs) +{ + struct node *node = newelement("Attribute"); + if (eal) addnode(node, eal); + setcommentnode(node); + addnode(node, attrs); + if (tok->type == TOK_inherit) { + lexnocomment(); + addnode(node, newattr("inherit", "inherit")); + } + if (tok->type == TOK_readonly) { + lexnocomment(); + addnode(node, newattr("readonly", "readonly")); + } + eat(tok, TOK_attribute); + addnode(node, parsetype(tok)); + addnode(node, newattr("name", setidentifier(tok))); + lexnocomment(); + return node; +} + +/*********************************************************************** + * parseserializer : parse Serializer + * + * Enter: tok = next token + * eal + * + * Return: node updated with value + * tok updated + */ +static struct node * +parseserializer (struct tok *tok, struct node *eal) { + struct node *nodeAttribute; + struct node *node = newelement("Serializer"); + if (tok->type == '=') { + if (eal) addnode(node, eal); + lexnocomment(); + if (tok->type == TOK_IDENTIFIER) { + addnode(node, newattr("attribute", setidentifier(tok))); + lexnocomment(); + } else if (tok->type == '{') { + unsigned int done = 0; + struct node *nodeMap = newelement("Map"); + lexnocomment(); + if (tok->type == TOK_getter) { + addnode(nodeMap, newattr("pattern", "getter")); + done = 1; + } else if (tok->type == TOK_attribute) { + addnode(nodeMap, newattr("pattern", "all")); + done = 1; + } else if (tok->type == TOK_inherit) { + addnode(nodeMap, newattr("inherit", "inherit")); + lexnocomment(); + eat(tok, ','); + if (tok->type == TOK_attribute) { + addnode(nodeMap, newattr("pattern", "all")); + done = 1; + } + } else if (tok->type != TOK_IDENTIFIER) { + tokerrorexit(tok, "expected 'attribute', 'getter', 'inherit' or attribute identifiers in serializer map"); + } + if (done) { + lexnocomment(); + eat(tok, '}'); + } else { + addnode(nodeMap, newattr("pattern", "selection")); + do { + if (tok->type != TOK_IDENTIFIER) + tokerrorexit(tok, "expected attribute identifiers in serializer map %s", tok->prestart); + nodeAttribute = newelement("PatternAttribute"); + addnode(nodeAttribute, newattr("name", setidentifier(tok))); + addnode(nodeMap, nodeAttribute); + lexnocomment(); + if (tok->type == ',') + lexnocomment(); + } while (tok->type != '}'); + eat(tok, '}'); + } + addnode(node, nodeMap); + } else if (tok->type == '[') { + struct node *nodeList = newelement("List"); + lexnocomment(); + if (tok->type == TOK_getter) { + addnode(nodeList, newattr("pattern", "getter")); + lexnocomment(); + eat(tok, ']'); + } else { + addnode(nodeList, newattr("pattern", "selection")); + do { + if (tok->type != TOK_IDENTIFIER) + tokerrorexit(tok, "expected attribute identifiers in serializer list"); + nodeAttribute = newelement("PatternAttribute"); + addnode(nodeAttribute, newattr("name", setidentifier(tok))); + addnode(nodeList, nodeAttribute); + lexnocomment(); + if (tok->type == ',') + lexnocomment(); + } while (tok->type != ']'); + eat(tok, ']'); + } + addnode(node, nodeList); + } else { + tokerrorexit(tok, "Expected '{', '[' or an attribute identifier in the serializer declaration"); + } + return node; + } else { + if (eal) addnode(node, eal); + return node; + } +} + +/*********************************************************************** + * parseattributeoroperationoriterator : parse [15] AttributeOrOperationOrIterator + * + * Enter: tok = next token + * eal = 0 else extended attribute list node + * + * Return: new node + * tok on terminating ';' + */ +static struct node * +parseattributeoroperationoriterator(struct tok *tok, struct node *eal) +{ + int alreadyseen ; + struct node *attrs = newattrlist(); + if (tok->type == TOK_serializer) { + lexnocomment(); + if (tok->type == '=' || tok->type ==';') { + return parseserializer(tok, eal); + } else { + addnode(attrs, newattr("serializer", "serializer")); + return parsereturntypeandoperationrest(tok, eal, attrs); + } + } + if (tok->type == TOK_stringifier) { + addnode(attrs, newattr("stringifier", "stringifier")); + lexnocomment(); + if (tok->type == ';') { + struct node *node = newelement("Stringifier"); + if (eal) addnode(node, eal); + return node; + } + } + if (tok->type == TOK_static) { + lexnocomment(); + addnode(attrs, newattr("static", "static")); + } + if (tok->type == TOK_inherit || tok->type == TOK_readonly || tok->type == TOK_attribute) + return parseattribute(tok, eal, attrs); + if (!nodeisempty(attrs)) + return parsereturntypeandoperationrest(tok, eal, attrs); + alreadyseen = 0; + for (;;) { + static const int t[] = { TOK_getter, + TOK_setter, TOK_creator, TOK_deleter, TOK_legacycaller, + 0 }; + const int *tt = t; + char *s; + while (*tt && *tt != tok->type) + tt++; + if (!*tt) + break; + s = memprintf("%.*s", tok->len, tok->start); + if (alreadyseen & (1 << (tt - t))) + tokerrorexit(tok, "'%s' qualifier cannot be repeated", s); + alreadyseen |= 1 << (tt - t); + addnode(attrs, newattr(s, s)); + lexnocomment(); + } + if (!nodeisempty(attrs)) + return parsereturntypeandoperationrest(tok, eal, attrs); + else + return parseoperationoriteratorrest(tok, eal, attrs); +} + + +/*********************************************************************** + * parseconstexpr : parse ConstValue + * + * Enter: tok = next token + * node + * + * Return: node updated with value + * tok updated + */ +static struct node * +parseconstexpr (struct tok *tok, struct node *node) { + char *s; + switch(tok->type) { + case TOK_true: + case TOK_false: + case TOK_minusinfinity: + case TOK_INTEGER: + case TOK_FLOAT: + case TOK_null: + case TOK_infinity: + case TOK_NaN: + break; + default: + tokerrorexit(tok, "expected constant value"); + break; + } + s = memalloc(tok->len + 1); + memcpy(s, tok->start, tok->len); + s[tok->len] = 0; + if (tok->type != TOK_STRING) { + addnode(node, newattr("value", s)); + } else { + addnode(node, newattr("stringvalue", s)); + } + lexnocomment(); + return node; +} + +/*********************************************************************** + * parsedefaultvalue : parse DefaultValue + * + * Enter: tok = next token + * node + * + * Return: node updated with value + * tok updated + */ +static struct node * +parsedefaultvalue (struct tok *tok, struct node *node) { + char *s; + if (tok->type == TOK_STRING) { + s = memalloc(tok->len + 1); + memcpy(s, tok->start, tok->len); + s[tok->len] = 0; + addnode(node, newattr("stringvalue", s)); + lexnocomment(); + return node; + } else { + return parseconstexpr(tok, node); + } +} + + + +/*********************************************************************** + * parsedictionarymember : parse DictionaryMember + * + * Enter: tok = next token + * eal = 0 else extended attribute list node + * + * Return: new node + * tok on terminating ';' + */ +static struct node * +parsedictionarymember(struct tok *tok, struct node *eal) +{ + struct node *node = newelement("DictionaryMember"); + if (eal) addnode(node, eal); + setcommentnode(node); + addnode(node, parsetype(tok)); + addnode(node, newattr("name", setidentifier(tok))); + tok = lexnocomment(); + // Optional value + if (tok->type == '=') { + tok = lexnocomment(); + node = parsedefaultvalue(tok, node); + } + return node; +} + +/*********************************************************************** + * parseconst : parse [12] Const + * + * Enter: tok = next token, known to be TOK_const + * eal = 0 else extended attribute list node + * + * Return: new node for the const + * tok on terminating ';' + */ +static struct node * +parseconst(struct tok *tok, struct node *eal) +{ + struct node *node = newelement("Const"); + setcommentnode(node); + if (eal) addnode(node, eal); + tok = lexnocomment(); + switch(tok->type) { + case TOK_boolean: + case TOK_byte: + case TOK_octet: + case TOK_float: + case TOK_double: + case TOK_unsigned: + case TOK_unrestricted: + case TOK_short: + case TOK_long: + addnode(node, parsetype(tok)); + break; + default: + tokerrorexit(tok, "expected acceptable constant type"); + break; + } + addnode(node, newattr("name", setidentifier(tok))); + tok = lexnocomment(); + eat(tok, '='); + node = parseconstexpr(tok, node); + return node; +} + +/*********************************************************************** + * parseimplementsstatement : parse [11] ImplementsStatement + * + * Enter: tok = next token, known to be :: or TOK_IDENTIFIER + * eal = 0 else extended attribute list node + * + * Return: new node for the typedef + * tok updated to the terminating ';' + */ +static struct node * +parseimplementsstatement(struct tok *tok, struct node *eal) +{ + struct node *node = newelement("Implements"); + setcommentnode(node); + if (eal) addnode(node, eal); + addnode(node, parsescopedname(tok, "name1", 1)); + eat(tok, TOK_implements); + addnode(node, parsescopedname(tok, "name2", 1)); + return node; +} + +/*********************************************************************** + * parsetypedef : parse [10] Typedef + * + * Enter: tok = next token, known to be TOK_typedef + * eal = 0 else extended attribute list node + * + * Return: new node for the typedef + * tok updated to the terminating ';' + */ +static struct node * +parsetypedef(struct tok *tok, struct node *eal) +{ +struct node *ealtype; +struct node *typenode; + struct node *node = newelement("Typedef"); + setcommentnode(node); + if (eal) addnode(node, eal); + tok = lexnocomment(); + ealtype = parseextendedattributelist(tok); + typenode = parsetype(tok); + if (ealtype) addnode(typenode, ealtype); + addnode(node, typenode); + addnode(node, newattr("name", setidentifier(tok))); + tok = lexnocomment(); + return node; +} + +/*********************************************************************** + * parseexception : parse [8] Exception + * + * Enter: tok = next token, known to be TOK_exception + * eal = 0 else extended attribute list node + * + * Return: new node for the exception + * tok updated to the terminating ';' + */ +static struct node * +parseexception(struct tok *tok, struct node *eal) +{ + struct node *node = newelement("Exception"); + setcommentnode(node); + if (eal) addnode(node, eal); + tok = lexnocomment(); + addnode(node, newattr("name", setidentifier(tok))); + lexnocomment(); + if (tok->type == ':') { + lexnocomment(); + addnode(node, parsescopednamelist(tok, "ExceptionInheritance", "Name", 1)); + } + eat(tok, '{'); + while (tok->type != '}') { + const char *start = tok->prestart; + struct node *node2; + struct node *eal = parseextendedattributelist(tok); + if (tok->type == TOK_const) + node2 = parseconst(tok, eal); + else + node2 = parseexceptionfield(tok, eal); + addnode(node, node2); + node2->wsstart = start; + node2->end = tok->start + tok->len; + setid(node2); + eat(tok, ';'); + } + lexnocomment(); + return node; +} + +/*********************************************************************** + * parseinterface : parse [4] Interface + * + * Enter: tok = next token, known to be TOK_interface + * eal = 0 else extended attribute list node + * + * Return: new node for the interface + * tok updated to the terminating ';' + */ +static struct node * +parseinterface(struct tok *tok, struct node *eal) +{ + struct node *node = newelement("Interface"); + if (eal) addnode(node, eal); + setcommentnode(node); + tok = lexnocomment(); + addnode(node, newattr("name", setidentifier(tok))); + tok = lexnocomment(); + if (tok->type == ':') { + lexnocomment(); + addnode(node, parsescopednamelist(tok, "InterfaceInheritance", "Name", 1)); + } + eat(tok, '{'); + while (tok->type != '}') { + const char *start = tok->prestart; + struct node *eal = parseextendedattributelist(tok); + struct node *node2; + if (tok->type == TOK_const) + addnode(node, node2 = parseconst(tok, eal)); + else + addnode(node, node2 = parseattributeoroperationoriterator(tok, eal)); + node2->wsstart = start; + node2->end = tok->start + tok->len; + setid(node2); + eat(tok, ';'); + } + lexnocomment(); + return node; +} + +/*********************************************************************** + * parsecallback : parse Callback + * + * Enter: tok = next token, known to be TOK_dictionary + * eal = 0 else extended attribute list node + * + * Return: new node for the enum + * tok updated to the terminating ';' + */ +static struct node * +parsecallback(struct tok *tok, struct node *eal) +{ + struct node *node; + if (tok->type == TOK_interface) { + node = parseinterface(tok, eal); + addnode(node, newattr("callback", "callback")); + } else { + node = newelement("Callback"); + if (eal) addnode(node, eal); + setcommentnode(node); + addnode(node, newattr("name", setidentifier(tok))); + tok = lexnocomment(); + eat(tok, '='); + addnode(node, parsereturntype(tok)); + eat(tok, '('); + addnode(node, parseargumentlist(tok)); + eat(tok, ')'); + } + return node; +} + +/*********************************************************************** + * parsedictionary : parse Dictionary + * + * Enter: tok = next token, known to be TOK_dictionary + * eal = 0 else extended attribute list node + * + * Return: new node for the dictionary + * tok updated to the terminating ';' + */ +static struct node * +parsedictionary(struct tok *tok, struct node *eal) +{ + struct node *node = newelement("Dictionary"); + if (eal) addnode(node, eal); + setcommentnode(node); + tok = lexnocomment(); + addnode(node, newattr("name", setidentifier(tok))); + tok = lexnocomment(); + if (tok->type == ':') { + lexnocomment(); + addnode(node, parsescopednamelist(tok, "DictionaryInheritance", "Name", 1)); + } + eat(tok, '{'); + while (tok->type != '}') { + const char *start = tok->prestart; + struct node *eal = parseextendedattributelist(tok); + struct node *node2; + if (tok->type == TOK_const) + addnode(node, node2 = parseconst(tok, eal)); + else + addnode(node, node2 = parsedictionarymember(tok, eal)); + node2->wsstart = start; + node2->end = tok->start + tok->len; + setid(node2); + eat(tok, ';'); + } + lexnocomment(); + return node; +} + +/*********************************************************************** + * parseenum : parse Enum + * + * Enter: tok = next token, known to be TOK_dictionary + * eal = 0 else extended attribute list node + * + * Return: new node for the enum + * tok updated to the terminating ';' + */ +static struct node * +parseenum(struct tok *tok, struct node *eal) +{ + char *s; + struct node *node = newelement("Enum"); + if (eal) addnode(node, eal); + setcommentnode(node); + tok = lexnocomment(); + addnode(node, newattr("name", setidentifier(tok))); + tok = lexnocomment(); + eat(tok, '{'); + while (tok->type != '}') { + if (tok->type == TOK_STRING) { + const char *start = tok->prestart; + struct node *node2 = newelement("EnumValue"); + setcommentnode(node2); + + s = memalloc(tok->len + 1); + memcpy(s, tok->start, tok->len); + s[tok->len] = 0; + addnode(node2, newattr("stringvalue", s)); + node2->wsstart = start; + node2->end = tok->start + tok->len; + setid(node2); + addnode(node, node2); + } else { + tokerrorexit(tok, "expected string in enum"); + } + lexnocomment(); + if (tok->type == ',') { + lexnocomment(); + } + } + eat(tok, '}'); + return node; +} + +/*********************************************************************** + * parsedefinitions : parse [1] Definitions + * + * Enter: tok = next token + * parent = parent node to add definitions to + * + * On return, tok has been updated. + */ +static void +parsedefinitions(struct tok *tok, struct node *parent) +{ + parent->wsstart = tok->prestart; + for (;;) { + const char *wsstart = tok->prestart; + struct node *eal = parseextendedattributelist(tok); + struct node *node; + switch (tok->type) { + case TOK_partial: + eat(tok, TOK_partial); + if (tok->type == TOK_dictionary) { + node = parsedictionary(tok, eal); + } else { + node = parseinterface(tok, eal); + } + addnode(node, newattr("partial", "partial")); + break; + case TOK_interface: + node = parseinterface(tok, eal); + break; + case TOK_callback: + eat(tok, TOK_callback); + node = parsecallback(tok, eal); + break; + case TOK_dictionary: + node = parsedictionary(tok, eal); + break; + case TOK_enum: + node = parseenum(tok, eal); + break; + case TOK_exception: + node = parseexception(tok, eal); + break; + case TOK_typedef: + node = parsetypedef(tok, eal); + break; + case TOK_IDENTIFIER: + node = parseimplementsstatement(tok, eal); + break; + default: + if (eal) + tokerrorexit(tok, "expected definition after extended attribute list"); + node = 0; + break; + } + if (!node) + break; + node->wsstart = wsstart; + node->end = tok->start + tok->len; + eat(tok, ';'); + addnode(parent, node); + setid(node); + parent->end = node->end; + } +} + +/*********************************************************************** + * parse + * + * Return: root element containing (possibly empty) list of definitions + */ +struct node * +parse(void) +{ + struct tok *tok; + struct node *root = newelement("Definitions"); + setcommentnode(root); + tok = lexnocomment(); + parsedefinitions(tok, root); + if (tok->type != TOK_EOF) + tokerrorexit(tok, "expected end of input"); + reversechildren(root); + return root; +} + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/src/parse.h b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/parse.h new file mode 100644 index 000000000..ad9071b45 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/parse.h @@ -0,0 +1,19 @@ +/*********************************************************************** + * $Id$ + * Copyright 2009 Aplix Corporation. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***********************************************************************/ +#ifndef parse_h +#define parse_h + +struct node *parse(void); + +#endif /* ndef parse_h */ diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/src/process.c b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/process.c new file mode 100644 index 000000000..d6a343b8a --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/process.c @@ -0,0 +1,319 @@ +/*********************************************************************** + * $Id$ + * Copyright 2009 Aplix Corporation. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***********************************************************************/ +#include +#include +#include +#include "comment.h" +#include "lex.h" +#include "misc.h" +#include "node.h" +#include "os.h" +#include "parse.h" +#include "process.h" + +#if 0 +static const char ntnames[] = { NTNAMES }; +#endif /*0*/ + +/*********************************************************************** + * printtext : print text with xml entity escapes + * + * Enter: s = text + * len = number of bytes + * escamp = whether to escape & + * + * This also escapes double quote mark so it can be used for an + * attribute value. It also turns a tab into spaces. + */ +void +printtext(const char *s, unsigned int len, int escamp) +{ + const char *p = s, *end = s + len; + unsigned int count = 0; + while (p != end) { + int ch = *p; + char buf[9]; + const char *seq = 0; + count++; + switch (ch) { + case '<': + seq = "<"; + break; + case '&': + seq = escamp ? "&" : "&"; + break; + case '"': + seq = """; + break; + case '\n': + p++; + count = 0; + continue; + case '\t': + seq = " " + ((count - 1) & 7); + count = 0; + break; + default: + if ((unsigned char)ch >= 0x20) { + p++; + continue; + } + snprintf(buf, 9, "&#%i;", ch); + seq = buf; + break; + } + if (p - s != fwrite(s, 1, p - s, stdout)) + errorexit("write error"); + fputs(seq, stdout); + s = ++p; + } + if (p - s != fwrite(s, 1, p - s, stdout)) + errorexit("write error"); +} + +#if 0 +/*********************************************************************** + * outputnodeastext : output parse node and descendants as deparsed text + * + * Enter: node = parse node + * needspace = true if last output char was an identifier char + * + * Return: updated needspace value + */ +static int +outputnodeastext(struct node *node, int needspace) +{ + if (node->type >= NT_START) { + struct node *child = node->children; + while (child) { + needspace = outputnodeastext(child, needspace); + child = child->next; + } + } else { + unsigned int len = strlen(node->name); + if (len) { + int ch = node->name[0]; + if (ch == '_' || ((unsigned)(ch - '0') < 10 + || (unsigned)((ch & ~0x20) - 'A') < 26)) + { + if (needspace) putchar(' '); + } + ch = node->name[len - 1]; + if (ch == '_' || ((unsigned)(ch - '0') < 10 + || (unsigned)((ch & ~0x20) - 'A') < 26)) + { + needspace = 1; + } + printtext(node->name, len, 1); + } + } + return needspace; +} + +/*********************************************************************** + * printfqid : print fully-qualified id + * + * Enter: node struct + * + * Return: whether anything printed + */ +static int +printfqid(struct node *node) +{ + int any = 0; + struct node *identifier; + if (node->parent) { + any = printfqid(node->parent); + } + switch (node->type) { + case NT_Module: + case NT_Interface: + case NT_Typedef: + case NT_Operation: + case NT_Attribute: + case NT_Const: + if (any) + printf(":"); + /* Find identifier child if any. */ + identifier = node->children; + while (identifier) { + if (identifier->type == TOK_IDENTIFIER) + break; + if (identifier->type == NT_TypedefRest) { + identifier = identifier->children; + continue; + } + identifier = identifier->next; + } + if (identifier) { + printtext(identifier->name, strlen(identifier->name), 1); + any = 1; + } + break; + } + return any; +} + +/*********************************************************************** + * output : output subtree of parse tree + * + * Enter: node = root of subtree + * extendedattributelist = 0 else extended attribute list node + * applying to node + * indent = indent (nesting) level + */ +static void outputchildren(struct node *node, struct node *identifier, unsigned int indent); + +static void +output(struct node *node, struct node *extendedattributelist, + unsigned int indent) +{ + if (extendedattributelist) { + node->wsstart = extendedattributelist->wsstart; + node->start = extendedattributelist->start; + } + if (node->type == NT_ExtendedAttribute) { + printf("%*s\n"); + } else if (node->type == NT_BooleanLiteral) { + printf("%*s", indent, "", + node->children->name); + } else if (node->type == NT_ReadOnly) { + printf("%*s\n", indent, ""); + } else if (node->type >= NT_START) { + const char *ntname; + /* Find identifier child if any. */ + struct node *identifier = node->children; + while (identifier) { + if (identifier->type == TOK_IDENTIFIER) + break; + identifier = identifier->next; + } + /* Find nonterminal name. */ + ntname = ntnames + 2; + while (node->type - NT_START != ((unsigned char)ntname[-2] | (unsigned char)ntname[-1] << 8)) + ntname += strlen(ntname) + 3; + /* Output start of element. */ + printf("%*s<%s", indent, "", ntname); + /* Output identifier if any as attribute. */ + if (identifier) { + printf(" identifier=\""); + printtext(identifier->name, strlen(identifier->name), 1); + printf("\""); + } + switch (node->type) { + case NT_Module: + case NT_Interface: + case NT_Typedef: + case NT_Const: + /* Output fully qualified id. */ + printf(" fqid=\""); + printfqid(node); + printf("\""); + break; + } + if (!identifier && !extendedattributelist && !node->children && !node->comments) + printf("/>\n"); + else { + printf(">\n"); + /* Output descriptive elements (doxygen comments) for node. */ + outputdescriptive(node, indent + 2); + /* Output descriptive elements (doxygen comments) for identifier. */ + if (identifier) + outputdescriptive(identifier, indent + 2); + /* Output extended attribute list. */ + if (extendedattributelist) + output(extendedattributelist, 0, indent + 2); + /* Output children (excluding identifier child). */ + outputchildren(node, identifier, indent + 2); + printf("%*s\n", indent, "", ntname); + } + } else switch (node->type) { + case TOK_DOMString: + case TOK_any: + case TOK_boolean: + case TOK_octet: + case TOK_float: + case TOK_double: + case TOK_Object: + case TOK_unsigned: + case TOK_short: + case TOK_long: + case TOK_void: + printf("%*s<%s/>\n", indent, "", node->name); + break; + case TOK_INTEGER: + printf("%*sname, strlen(node->name), 1); + printf("\"/>\n"); + break; + case TOK_FLOAT: + printf("%*sname, strlen(node->name), 1); + printf("\"/>\n"); + break; + case TOK_STRING: + printf("%*sname, strlen(node->name), 1); + printf("\"/>\n"); + break; + } +} + +/*********************************************************************** + * outputchildren : call output for each child of node + * + * Enter: node + * identifier = child node to omit from output + * indent = indent (nesting) level + */ +static void +outputchildren(struct node *node, struct node *identifier, unsigned int indent) +{ + struct node *extendedattributelist; + struct node *child; + child = node->children; + extendedattributelist = 0; + while (child) { + if (child->type == NT_ExtendedAttributeList && node->type != NT_Argument) + extendedattributelist = child; + else { + if (identifier != child) + output(child, extendedattributelist, indent); + extendedattributelist = 0; + } + child = child->next; + } +} +#endif /*0*/ + +/*********************************************************************** + * processfiles : process input files + * + * Enter: name = filename + */ +void +processfiles(const char *const *names, int dtdref) +{ + struct node *root; + readinput(names); + root = parse(); + processcomments(root); + printf("\n"); + if(dtdref) + printf("\n"); + outputnode(root, 0); +} + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/src/process.h b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/process.h new file mode 100644 index 000000000..bb92b22ce --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/process.h @@ -0,0 +1,27 @@ +/*********************************************************************** + * $Id$ + * Copyright 2009 Aplix Corporation. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***********************************************************************/ +#ifndef process_h +#define process_h + +#if 0 +#define NT_START 0x100 +#include "nonterminals.h" +#endif/*0*/ + +void printtext(const char *s, unsigned int len, int escamp); + +void processfiles(const char *const *names, int dtdref); + +#endif /* ndef process_h */ + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/src/widlprocxmltohtml.xsl b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/widlprocxmltohtml.xsl new file mode 100644 index 000000000..2b583371e --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/src/widlprocxmltohtml.xsl @@ -0,0 +1,828 @@ + + + + + + + + + + + + + + + + <xsl:value-of select="$title"/> + + + + + + + + + + +
+ Bondi logo +

+

12 May 2009

+ +

Authors

+
    + +
+ + + +
+ +

Abstract

+ + + + + +

Table of Contents

+ + +
+ +

Summary of Methods

+ + +

Introduction

+ + + + + +
+

Feature set

+

This is the URI used to declare this API's feature set, for use in bondi.requestFeature. For the URL, the list of features included by the feature set is provided.

+ +
+
+ +
+

Features

+

This is the list of URIs used to declare this API's features, for use in bondi.requestFeature. For each URL, the list of functions covered is provided.

+ + +
+
+ +
+

Device capabilities

+
+ +
+
+
+ +
+

Type Definitions

+ +
+
+ +
+

Interfaces

+ +
+
+ +
+

Dictionary types

+ +
+
+ +
+

Callbacks

+ +
+
+ +
+

Enums

+ +
+
+
+
+ + + +
+
+
+ + + + +
+

+ Includes API features: +

+
    + +
  • +
    +
+
+
+
+
+
+ + + +
+
+
+ + + + +
+

+ Device capabilities: +

+
    + +
  • +
    +
+
+
+
+
+
+ + + +
+
+ + + + +
+

Security parameters:

+
    + +
+
+
+
+
+ + + + + + element not supported + + + + + +
+

2..

+ + + + +
+
+ + + + +
+

+ + + + + + + +
+

Constants

+
+ +
+
+
+ +
+

Constructors

+
+ +
+
+
+ +
+

Attributes

+
+ +
+
+
+ +
+

Methods

+
+ +
+
+
+
+
+ + + + + + +
+

+ + + + + + +
+

Constants

+
+ +
+
+
+ +
+

Attributes

+
+ +
+
+
+
+
+ + + + +

+ This interface inherits from: + + + , + +

+
+ + + +
+ + + stringifier + + + readonly + + + + +
+
+ + + + + +
+
+ + + +
+ + + + + +
+
+ + + +
+
+ + + +
+ + + ( + + + + ); + +
+
+ + + + + +
+
API features
+
+ +
+
+
+ + +
+
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + ( + + + + ); + +
+
+ + + + + + +
+
Return value
+ +
+
+ + +
+
API features
+
+ +
+
+
+ +
+
+ + + + +
+

+ +
+ + + +
+
Signature
+
+	                
+	                 
+	                
+	                (
+	                
+	                    
+	                
+	                );
+
+
+ + + +
+
Return value
+ +
+
+ +
+
+
+ + + + + + + + + + + + + + + + +
+
Parameters
+
    + +
+
+
+
+
+ + + + + + + + + + , + + + + + ... + + + + Default value: + + + Default value: "" + + + + +
  • + : + +
  • +
    +
    +
    + + + +
    +
    Exceptions
    +
      + +
    +
    +
    + + + +
  • + : + +
  • +
    + + + + + + sequence < + + > + + + + + + ? + + + + + + + + +
    +

    + + + + +
    +

    Values

    +
    + +
    +
    +
    +
    + + + + + +
    + + + +
    +
    + + + +
    +
    + + + + + + + + + + +
    +

    + +

    +
    +
    + + + + + + + + + +
    + +
    +
    +
    +
    + + + +
    + +
    +
    + + + +
    + + +
    +
    + +
    Code example
    +
    +
    +
    +
    +
    + + + +
    WebIDL
    +
    +
    + + + +
  • +
    + + + +
    +

    + Version: +

    +
    +
    + + + +
    + +
    +
    + +
    +
    + + + +
  • + : + +
  • +
    + + + + +

    + + + When the feature + + + When any of the features + + +

    +
      + +
    • + +
    • +
      +
    +

    + is successfully requested, the interface + + is instantiated, and the resulting object appears in the global + namespace as + .. +

    +
    + + + + + + + + + + + + + + + + + + + + +
    InterfaceMethod
    + + + + + + ( + + + + , + + ) +
    +
    +
    +
    + + + + + + + + +
    + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/Makefile b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/Makefile new file mode 100644 index 000000000..c40939e36 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/Makefile @@ -0,0 +1,91 @@ +######################################################################## +# $Id: Makefile 418 2010-06-16 15:26:51Z tpr $ +# Copyright 2009 Aplix Corporation. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +######################################################################## + +UNAME = $(shell uname) +VALIDTESTDIR = valid/idl +VALIDTESTREFDIR = valid/xml +VALIDTESTOBJDIR = valid/obj +INVALIDTESTDIR = invalid/idl +INVALIDTESTREFDIR = invalid/error +INVALIDTESTOBJDIR = invalid/obj + +# The settings of SRCDIR (where to find the xsl style sheets), OBJDIR (where to +# find widlproc and widlprocxml.dtd) and VALDTESTOBJDIR (where to put the +# resulting XML files) reflect the directory +# structure of the released widlproc.zip file when unzipped. ../Makefile calls +# this Makefile with these settings overridden to reflect the directory +# structure in svn. +SRCDIR = .. +OBJDIR = .. + +######################################################################## +# Linux configuration +# +ifneq (,$(filter Linux%, $(UNAME))) + +EXESUFFIX = + +else +######################################################################## +# Darwin configuration +# +ifneq (,$(filter Darwin%, $(UNAME))) + +EXESUFFIX = + +else +######################################################################## +# Windows (cygwin but using MS compiler) configuration +# +ifneq (,$(filter CYGWIN%, $(UNAME))) + +EXESUFFIX = .exe + +endif +endif +endif + +######################################################################## +# Common makefile +# +WIDLPROC = $(OBJDIR)/widlproc$(EXESUFFIX) +DTD = $(OBJDIR)/widlprocxml.dtd + +VALID_WIDLS = $(patsubst $(VALIDTESTDIR)/%, %, $(wildcard $(VALIDTESTDIR)/*.widl)) +INVALID_WIDLS = $(patsubst $(INVALIDTESTDIR)/%, %, $(wildcard $(INVALIDTESTDIR)/*.widl)) + +test : $(patsubst %.widl, $(VALIDTESTOBJDIR)/%.widlprocxml, $(VALID_WIDLS)) $(patsubst %.widl, $(INVALIDTESTOBJDIR)/%.txt, $(INVALID_WIDLS)) $(WIDLPROC) + @echo "$@ pass" + +#$(EXAMPLESOBJDIR)/%.html : $(EXAMPLESOBJDIR)/%.widlprocxml $(SRCDIR)/widlprocxmltohtml.xsl Makefile +# cp $(SRCDIR)/widlprocxmltohtml.xsl $(dir $@)/ +# xsltproc $(dir $@)/widlprocxmltohtml.xsl $< >$@ + + +$(VALIDTESTOBJDIR)/%.widlprocxml : $(VALIDTESTDIR)/%.widl $(WIDLPROC) $(DTD) Makefile $(patsubst %.widl, $(VALIDTESTREFDIR)/%.widlprocxml, $(VALID_WIDLS)) + mkdir -p $(dir $@) + $(WIDLPROC) $< >$@ + cp $(OBJDIR)/widlprocxml.dtd $(dir $@)/ + xmllint --noout --dtdvalid $(DTD) $@ + diff $@ $(VALIDTESTREFDIR)/`basename $@` + +$(INVALIDTESTOBJDIR)/%.txt : $(INVALIDTESTDIR)/%.widl $(WIDLPROC) Makefile $(patsubst %.widl, $(INVALIDTESTREFDIR)/%.txt, $(INVALID_WIDLS)) + mkdir -p $(dir $@) + -$(WIDLPROC) $< >$@ 2>&1 + diff $@ $(INVALIDTESTREFDIR)/`basename $@` + + + +.DELETE_ON_ERROR: + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/enum.txt b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/enum.txt new file mode 100644 index 000000000..6f8ba8eef --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/enum.txt @@ -0,0 +1 @@ +invalid/idl/enum.widl: 1: at '1': expected string in enum diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/module.txt b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/module.txt new file mode 100644 index 000000000..7e504316e --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/module.txt @@ -0,0 +1 @@ +invalid/idl/module.widl: 2: at 'gfx': expected 'implements' diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/nonnullableany.txt b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/nonnullableany.txt new file mode 100644 index 000000000..eeeb25f12 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/nonnullableany.txt @@ -0,0 +1 @@ +invalid/idl/nonnullableany.widl: 2: at '?': expected identifier diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/nonnullableobjects.txt b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/nonnullableobjects.txt new file mode 100644 index 000000000..526622599 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/nonnullableobjects.txt @@ -0,0 +1 @@ +invalid/idl/nonnullableobjects.widl: 4: at '?': expected identifier diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/scopedname.txt b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/scopedname.txt new file mode 100644 index 000000000..5646608cd --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/scopedname.txt @@ -0,0 +1 @@ +invalid/idl/scopedname.widl: 2: at ':': expected identifier diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/sequenceAsAttribute.txt b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/sequenceAsAttribute.txt new file mode 100644 index 000000000..15960cb8b --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/sequenceAsAttribute.txt @@ -0,0 +1 @@ +invalid/idl/sequenceAsAttribute.widl: 2: at 'sequence': expected type diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/stringconstants.idl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/stringconstants.idl new file mode 100644 index 000000000..155a892c5 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/error/stringconstants.idl @@ -0,0 +1 @@ +invalid/idl/stringconstants.idl: 2: at 'DOMString': expected acceptable constant type diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/enum.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/enum.widl new file mode 100644 index 000000000..c355c3251 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/enum.widl @@ -0,0 +1 @@ +enum foo { 1, 2, 3}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/module.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/module.widl new file mode 100644 index 000000000..a4c79fdf1 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/module.widl @@ -0,0 +1,25 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +module gfx { + + module geom { + interface Shape { /* ... */ }; + interface Rectangle : Shape { /* ... */ }; + interface Path : Shape { /* ... */ }; + }; + + interface GraphicsContext { + void fillShape(geom::Shape s); + void strokeShape(geom::Shape s); + }; +}; + +module gui { + + interface Widget { /* ... */ }; + + interface Window : Widget { + gfx::GraphicsContext getGraphicsContext(); + }; + + interface Button : Widget { /* ... */ }; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/nonnullableany.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/nonnullableany.widl new file mode 100644 index 000000000..389576555 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/nonnullableany.widl @@ -0,0 +1,3 @@ +interface NonNullable { + attribute any? foo; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/nonnullableobjects.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/nonnullableobjects.widl new file mode 100644 index 000000000..1deac5aee --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/nonnullableobjects.widl @@ -0,0 +1,5 @@ +interface Foo {}; + +interface NonNullable { + attribute Foo?? foo; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/raises.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/raises.widl new file mode 100644 index 000000000..ff65522f2 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/raises.widl @@ -0,0 +1,18 @@ +// getraises and setraises are not longer valid Web IDL +interface Person { + + // An attribute that can raise an exception if it is set to an invalid value. + attribute DOMString name setraises (InvalidName); + + // An attribute whose value cannot be assigned to, and which can raise an + // exception some circumstances. + readonly attribute DOMString petName getraises (NoSuchPet); +}; + +exception SomeException { +}; + +interface ExceptionThrower { + // This attribute always throws a SomeException and never returns a value. + attribute long valueOf getraises(SomeException); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/scopedname.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/scopedname.widl new file mode 100644 index 000000000..cfcb1ccc9 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/scopedname.widl @@ -0,0 +1,2 @@ +// scoped names are no longer valid in WebIDL + typedef gfx::geom::geom2d::Point Point; diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/sequenceAsAttribute.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/sequenceAsAttribute.widl new file mode 100644 index 000000000..c23da82ac --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/sequenceAsAttribute.widl @@ -0,0 +1,3 @@ +interface sequenceAsAttribute { + attribute sequence invalid; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/special-omittable.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/special-omittable.widl new file mode 100644 index 000000000..bdfbfa709 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/special-omittable.widl @@ -0,0 +1,8 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +// omittable is no longer a recognized keywoard as of 20110905 +interface Dictionary { + readonly attribute unsigned long propertyCount; + + omittable getter float getProperty(DOMString propertyName); + omittable setter void setProperty(DOMString propertyName, float propertyValue); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/stringconstants.idl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/stringconstants.idl new file mode 100644 index 000000000..44fd3ff13 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/invalid/idl/stringconstants.idl @@ -0,0 +1,3 @@ +interface Util { + const DOMString hello = "world"; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/allowany.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/allowany.widl new file mode 100644 index 000000000..2343bb963 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/allowany.widl @@ -0,0 +1,6 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface B { + void g(); + void g(B b); + void g([AllowAny] DOMString s); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/array.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/array.widl new file mode 100644 index 000000000..22e21fb65 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/array.widl @@ -0,0 +1,5 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +[Constructor] +interface LotteryResults { + readonly attribute unsigned short[][] numbers; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/attributes.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/attributes.widl new file mode 100644 index 000000000..7e1d691cb --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/attributes.widl @@ -0,0 +1,14 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +exception InvalidName { + DOMString reason; +}; + +exception NoSuchPet { }; + +interface Person { + + // A simple attribute that can be set to any value the range an unsigned + // short can take. + attribute unsigned short age; + +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/callback.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/callback.widl new file mode 100644 index 000000000..d92f6a18c --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/callback.widl @@ -0,0 +1,5 @@ +callback AsyncOperationCallback = void (DOMString status); + +callback interface EventHandler { + void eventOccurred(DOMString details); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/caller.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/caller.widl new file mode 100644 index 000000000..92acb1c01 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/caller.widl @@ -0,0 +1,5 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface NumberQuadrupler { + // This operation simply returns four times the given number x. + legacycaller float compute(float x); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/constants.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/constants.widl new file mode 100644 index 000000000..5e28ae9c1 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/constants.widl @@ -0,0 +1,18 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface Util { + const boolean DEBUG = false; + const short negative = -1; + const octet LF = 10; + const unsigned long BIT_MASK = 0x0000fc00; + const float AVOGADRO = 6.022e23; + const unrestricted float sobig = Infinity; + const unrestricted double minusonedividedbyzero = -Infinity; + const short notanumber = NaN; +}; + +exception Error { + const short ERR_UNKNOWN = 0; + const short ERR_OUT_OF_MEMORY = 1; + + short errorCode; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/constructor.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/constructor.widl new file mode 100644 index 000000000..f93ec08a6 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/constructor.widl @@ -0,0 +1,9 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +[Constructor, + Constructor(float radius)] +interface Circle { + attribute float r; + attribute float cx; + attribute float cy; + readonly attribute float circumference; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/dictionary-inherits.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/dictionary-inherits.widl new file mode 100644 index 000000000..48f8a0fdc --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/dictionary-inherits.widl @@ -0,0 +1,9 @@ +dictionary PaintOptions { + DOMString? fillPattern = "black"; + DOMString? strokePattern = null; + Point position; +}; + +dictionary WetPaintOptions : PaintOptions { + float hydrometry; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/dictionary.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/dictionary.widl new file mode 100644 index 000000000..f46b7ba78 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/dictionary.widl @@ -0,0 +1,11 @@ +// Extracted from Web IDL editors draft May 31 2011 +dictionary PaintOptions { + DOMString? fillPattern = "black"; + DOMString? strokePattern = null; + Point position; +}; + +partial dictionary A { + long h; + long d; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/documentation-dos.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/documentation-dos.widl new file mode 100644 index 000000000..fb801101f --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/documentation-dos.widl @@ -0,0 +1,33 @@ +/** +* \brief Testing documentation features +* +* This is a +* single paragraph +* +*

    This is valid.

    +*

    This is valid.

    +*

    This is valid.

    +*

    This is valid.

    +*
      +*
    • This
    • +*
    • is
    • +*
    • valid
    • +*
    +*
    +*
    This
    +*
    valid
    +*
    +* +* +* +* +* +* +* +* +*
    thisis
    valid
    +*

    This is
    valid.

    +*

    This is
    valid.

    +*

    This is
    valid.

    +*/ +interface Documentation {}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/documentation.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/documentation.widl new file mode 100644 index 000000000..003e9226f --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/documentation.widl @@ -0,0 +1,34 @@ +/** +* \brief Testing documentation features +* +* This is a +* single paragraph +* +*

    This is valid.

    +*

    This is valid.

    +*

    This is valid.

    +*

    This is valid.

    +*
      +*
    • This
    • +*
    • is
    • +*
    • valid
    • +*
    +*
    +*
    This
    +*
    valid
    +*
    +* +* +* +* +* +* +* +* +*
    thisis
    valid
    +*

    This is
    valid.

    +*

    This is
    valid.

    +*

    This is
    valid.

    +*

    Valid

    +*/ +interface Documentation {}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/enum.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/enum.widl new file mode 100644 index 000000000..851fca2e6 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/enum.widl @@ -0,0 +1,8 @@ +enum MealType { "rice", "noodles", "other" }; + +interface Meal { + attribute MealType type; + attribute float size; // in grams + + void initialize(MealType type, float size); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/equivalent-decl.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/equivalent-decl.widl new file mode 100644 index 000000000..6b3e0eda2 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/equivalent-decl.widl @@ -0,0 +1,18 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface Dictionary { + readonly attribute unsigned long propertyCount; + + getter float getProperty(DOMString propertyName); + setter void setProperty(DOMString propertyName, float propertyValue); +}; + + +interface Dictionary { + readonly attribute unsigned long propertyCount; + + float getProperty(DOMString propertyName); + void setProperty(DOMString propertyName, float propertyValue); + + getter float (DOMString propertyName); + setter void (DOMString propertyName, float propertyValue); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/exception-inheritance.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/exception-inheritance.widl new file mode 100644 index 000000000..258fdeba6 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/exception-inheritance.widl @@ -0,0 +1,7 @@ +// from http://lists.w3.org/Archives/Public/public-script-coord/2010OctDec/0112.html + exception DOMException { + unsigned short code; + }; + + exception HierarchyRequestError : DOMException { }; + exception NoModificationAllowedError : DOMException { }; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/exception.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/exception.widl new file mode 100644 index 000000000..f4b6ae29e --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/exception.widl @@ -0,0 +1,8 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface Dahut { + attribute DOMString type; +}; + +exception SomeException { +}; + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/getter-setter.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/getter-setter.widl new file mode 100644 index 000000000..bdf87e1c7 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/getter-setter.widl @@ -0,0 +1,7 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface Dictionary { + readonly attribute unsigned long propertyCount; + + getter float (DOMString propertyName); + setter void (DOMString propertyName, float propertyValue); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/identifier-qualified-names.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/identifier-qualified-names.widl new file mode 100644 index 000000000..33893d4c6 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/identifier-qualified-names.widl @@ -0,0 +1,44 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 + // Typedef identifier: "number" + // Qualified name: "::framework::number" + typedef float number; + + // Exception identifier: "FrameworkException" + // Qualified name: "::framework::FrameworkException" + exception FrameworkException { + + // Constant identifier: "ERR_NOT_FOUND" + // Qualified name: "::framework::FrameworkException::ERR_NOT_FOUND" + const long ERR_NOT_FOUND = 1; + + // Exception field identifier: "code" + long code; + }; + + // Interface identifier: "System" + // Qualified name: "::framework::System" + interface System { + + // Operation identifier: "createObject" + // Operation argument identifier: "interface" + object createObject(DOMString _interface); + + // Operation has no identifier; it declares a getter. + getter DOMString (DOMString keyName); + }; + + + // Interface identifier: "TextField" + // Qualified name: "::framework::gui::TextField" + interface TextField { + + // Attribute identifier: "const" + attribute boolean _const; + + // Attribute identifier: "value" + attribute DOMString? _value; + }; + +interface Foo { + void op(object interface); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/implements.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/implements.widl new file mode 100644 index 000000000..7a310926f --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/implements.widl @@ -0,0 +1,14 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 + interface Node { + readonly attribute unsigned short nodeType; + // ... + }; + + interface EventTarget { + void addEventListener(DOMString type, + EventListener listener, + boolean useCapture); + // ... + }; + + Node implements EventTarget; diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/indexed-properties.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/indexed-properties.widl new file mode 100644 index 000000000..acf0ed3bf --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/indexed-properties.widl @@ -0,0 +1,12 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface OrderedMap { + readonly attribute unsigned long size; + + getter any getByIndex(unsigned long index); + setter void setByIndex(unsigned long index, any value); + deleter void removeByIndex(unsigned long index); + + getter any get(DOMString name); + setter creator void set(DOMString name, any value); + deleter void remove(DOMString name); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/inherits-getter.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/inherits-getter.widl new file mode 100644 index 000000000..558e81164 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/inherits-getter.widl @@ -0,0 +1,16 @@ +interface Animal { + + // A simple attribute that can be set to any string value. + readonly attribute DOMString name; +}; + +interface Person : Animal { + + // An attribute whose value cannot be assigned to. + readonly attribute unsigned short age; + + // An attribute that can raise an exception if it is set to an invalid value. + // Its getter behavior is inherited from Animal, and need not be specified + // the description of Person. + inherit attribute DOMString name; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/interface-inherits.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/interface-inherits.widl new file mode 100644 index 000000000..7921def77 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/interface-inherits.widl @@ -0,0 +1,12 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface Animal { + attribute DOMString name; +}; + +interface Human : Animal { + attribute Dog pet; +}; + +interface Dog : Animal { + attribute Human owner; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/iterator.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/iterator.widl new file mode 100644 index 000000000..3bf1b36de --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/iterator.widl @@ -0,0 +1,35 @@ +interface SessionManager { + Session getSessionForUser(DOMString username); + readonly attribute unsigned long sessionCount; + + Session iterator; +}; + +interface Session { + readonly attribute DOMString username; + // ... +}; + +interface SessionManager2 { + Session2 getSessionForUser(DOMString username); + readonly attribute unsigned long sessionCount; + + Session2 iterator = SessionIterator; +}; + +interface Session2 { + readonly attribute DOMString username; + // ... +}; + +interface SessionIterator { + readonly attribute unsigned long remainingSessions; +}; + + interface NodeList { + Node iterator = NodeIterator; + }; + + interface NodeIterator { + Node iterator object; + }; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/namedconstructor.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/namedconstructor.widl new file mode 100644 index 000000000..c468b78f8 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/namedconstructor.widl @@ -0,0 +1,6 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +[NamedConstructor=Audio, + NamedConstructor=Audio(DOMString src)] +interface HTMLAudioElement : HTMLMediaElement { + // ... +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/nointerfaceobject.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/nointerfaceobject.widl new file mode 100644 index 000000000..c17d75ff8 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/nointerfaceobject.widl @@ -0,0 +1,5 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +[NoInterfaceObject] +interface Query { + any lookupEntry(unsigned long key); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/nullable.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/nullable.widl new file mode 100644 index 000000000..ccbf625ff --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/nullable.widl @@ -0,0 +1,9 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface MyConstants { + const boolean? ARE_WE_THERE_YET = false; +}; + +interface Node { + readonly attribute DOMString? namespaceURI; + // ... +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/nullableobjects.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/nullableobjects.widl new file mode 100644 index 000000000..83d1d40b2 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/nullableobjects.widl @@ -0,0 +1,13 @@ +// Extracted from WebIDL spec 2011-05-23 + +interface A { + // ... +}; +interface B { + // ... +}; +interface C { + void f(A? x); + void f(B? x); + +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/operation-optional-arg.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/operation-optional-arg.widl new file mode 100644 index 000000000..379053b45 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/operation-optional-arg.widl @@ -0,0 +1,4 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface ColorCreator { + object createColor(float v1, float v2, float v3, optional float alpha = 3.5); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/overloading.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/overloading.widl new file mode 100644 index 000000000..ef1288a88 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/overloading.widl @@ -0,0 +1,20 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface A { + // ... +}; + +interface B { + // ... +}; + +interface C { + void f(A x); + void f(B x); +}; + +interface A { + /* f1 */ void f(DOMString a); + /* f2 */ void f([AllowAny] DOMString a, DOMString b, float... c); + /* f3 */ void f(); + /* f4 */ void f(long a, DOMString b, optional DOMString c, float... d); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/overridebuiltins.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/overridebuiltins.widl new file mode 100644 index 000000000..79211c29e --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/overridebuiltins.widl @@ -0,0 +1,6 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +[OverrideBuiltins] +interface StringMap2 { + readonly attribute unsigned long length; + getter DOMString lookup(DOMString key); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/partial-interface.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/partial-interface.widl new file mode 100644 index 000000000..90e7e0ea4 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/partial-interface.widl @@ -0,0 +1,7 @@ +interface Foo { + attribute DOMString bar; +}; + +partial interface Foo { + attribute DOMString quux; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/primitives.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/primitives.widl new file mode 100644 index 000000000..92939601a --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/primitives.widl @@ -0,0 +1,19 @@ +interface Primitives { + attribute boolean truth; + attribute byte character; + attribute octet value; + attribute short number; + attribute unsigned short positive; + attribute long big; + attribute unsigned long bigpositive; + attribute long long bigbig; + attribute unsigned long long bigbigpositive; + attribute float real; + attribute double bigreal; + attribute unrestricted float realwithinfinity; + attribute unrestricted double bigrealwithinfinity; + attribute DOMString string; + attribute ByteString bytes; + attribute Date date; + attribute RegExp regexp; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/prototyperoot.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/prototyperoot.widl new file mode 100644 index 000000000..30dd5cbca --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/prototyperoot.widl @@ -0,0 +1,5 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +[PrototypeRoot] +interface Node { + readonly attribute unsigned short nodeType; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/putforwards.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/putforwards.widl new file mode 100644 index 000000000..1e50a4ee3 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/putforwards.widl @@ -0,0 +1,5 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface Person { + [PutForwards=full] readonly attribute Name name; + attribute unsigned short age; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/reg-operations.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/reg-operations.widl new file mode 100644 index 000000000..13997cb1d --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/reg-operations.widl @@ -0,0 +1,17 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface Dimensions { + attribute unsigned long width; + attribute unsigned long height; +}; + +exception NoPointerDevice { }; + +interface Button { + + // An operation that takes no arguments, returns a boolean + boolean isMouseOver(); + + // Overloaded operations. + void setDimensions(Dimensions size); + void setDimensions(unsigned long width, unsigned long height); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/replaceable.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/replaceable.widl new file mode 100644 index 000000000..c14d0c376 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/replaceable.widl @@ -0,0 +1,5 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface Counter { + [Replaceable] readonly attribute unsigned long value; + void increment(); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/sequence.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/sequence.widl new file mode 100644 index 000000000..a1aa931f5 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/sequence.widl @@ -0,0 +1,7 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +// edited to remove sequence as attributes, now invalid +interface Canvas { + void drawPolygon(sequence coordinates); + sequence getInflectionPoints(); + // ... +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/serializer.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/serializer.widl new file mode 100644 index 000000000..6f6ccd0e8 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/serializer.widl @@ -0,0 +1,64 @@ +interface Transaction { + readonly attribute Account from; + readonly attribute Account to; + readonly attribute float amount; + readonly attribute DOMString description; + readonly attribute unsigned long number; + + serializer; +}; + +interface Account { + attribute DOMString name; + attribute unsigned long number; + serializer DOMString serialize(); +}; + +interface Transaction2 { + readonly attribute Account2 from; + readonly attribute Account2 to; + readonly attribute float amount; + readonly attribute DOMString description; + readonly attribute unsigned long number; + + serializer = { from, to, amount, description }; +}; + +interface Account2 { + attribute DOMString name; + attribute unsigned long number; + serializer = number; +}; + +interface Account3 { + attribute DOMString name; + attribute unsigned long number; + + serializer = { attribute }; +}; + +interface Account4 { + getter object getItem(unsigned long index); + serializer = { getter }; +}; + +interface Account5 : Account { + attribute DOMString secondname; + serializer = { inherit, secondname }; +}; + +interface Account6 : Account { + attribute DOMString secondname; + serializer = { inherit, attribute }; +}; + +interface Account7 { + attribute DOMString name; + attribute unsigned long number; + serializer = [ name, number ]; +}; + +interface Account8 { + getter object getItem(unsigned long index); + serializer = [ getter ]; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/static.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/static.widl new file mode 100644 index 000000000..5b2cd3659 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/static.widl @@ -0,0 +1,11 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface Point { /* ... */ }; + +interface Circle { + attribute float cx; + attribute float cy; + attribute float radius; + + static readonly attribute long triangulationCount; + static Point triangulate(Circle c1, Circle c2, Circle c3); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/stringifier-attribute.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/stringifier-attribute.widl new file mode 100644 index 000000000..c964ecb93 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/stringifier-attribute.widl @@ -0,0 +1,6 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +[Constructor] +interface Student { + attribute unsigned long id; + stringifier attribute DOMString name; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/stringifier-custom.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/stringifier-custom.widl new file mode 100644 index 000000000..b5d7c87e7 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/stringifier-custom.widl @@ -0,0 +1,9 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +[Constructor] +interface Student { + attribute unsigned long id; + attribute DOMString? familyName; + attribute DOMString givenName; + + stringifier DOMString (); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/stringifier.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/stringifier.widl new file mode 100644 index 000000000..4eb483d9b --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/stringifier.widl @@ -0,0 +1,8 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface A { + stringifier DOMString (); +}; + +interface A { + stringifier; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/treatasnull.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/treatasnull.widl new file mode 100644 index 000000000..d3c55b008 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/treatasnull.widl @@ -0,0 +1,7 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface Dog { + attribute DOMString name; + attribute DOMString owner; + + boolean isMemberOfBreed([TreatNullAs=EmptyString] DOMString breedName); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/treatasundefined.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/treatasundefined.widl new file mode 100644 index 000000000..e30050f84 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/treatasundefined.widl @@ -0,0 +1,7 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface Cat { + attribute DOMString name; + attribute DOMString owner; + + boolean isMemberOfBreed([TreatUndefinedAs=EmptyString] DOMString breedName); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/typedef.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/typedef.widl new file mode 100644 index 000000000..b4c17d8d3 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/typedef.widl @@ -0,0 +1,22 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 + interface Point { + attribute float x; + attribute float y; + }; + + typedef sequence PointSequence; + + interface Rect { + attribute Point topleft; + attribute Point bottomright; + }; + + interface Widget { + + readonly attribute Rect bounds; + + boolean pointWithinBounds(Point p); + boolean allPointsWithinBounds(PointSequence ps); + }; + + typedef [Clamp] octet value; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/typesuffixes.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/typesuffixes.widl new file mode 100644 index 000000000..95e31c169 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/typesuffixes.widl @@ -0,0 +1,3 @@ +interface Suffixes { + void test(sequence? foo); +}; diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/uniontype.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/uniontype.widl new file mode 100644 index 000000000..4d99f0196 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/uniontype.widl @@ -0,0 +1,3 @@ +interface Union { + attribute (float or (Date or Event) or (Node or DOMString)?) test; +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/variadic-operations.widl b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/variadic-operations.widl new file mode 100644 index 000000000..51fae4cc1 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/idl/variadic-operations.widl @@ -0,0 +1,7 @@ +// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06 +interface IntegerSet { + readonly attribute unsigned long cardinality; + + void union(long... ints); + void intersection(long... ints); +}; \ No newline at end of file diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/allowany.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/allowany.widlprocxml new file mode 100644 index 000000000..7da508bcb --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/allowany.widlprocxml @@ -0,0 +1,44 @@ + + + + interface B { + void g(); + void g(B b); + void g([AllowAny] DOMString s); +}; + + interface B { + void g(); + void g(B b); + void g([AllowAny] DOMString s); +}; + + void g(); + + + + + void g(B b); + + + + + + + + + void g([AllowAny] DOMString s); + + + + + + AllowAny + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/array.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/array.widlprocxml new file mode 100644 index 000000000..3df72ff16 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/array.widlprocxml @@ -0,0 +1,27 @@ + + + + [Constructor] +interface LotteryResults { + readonly attribute unsigned short[][] numbers; +}; + + [Constructor] +interface LotteryResults { + readonly attribute unsigned short[][] numbers; +}; + + + Constructor + + + + readonly attribute unsigned short[][] numbers; + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/attributes.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/attributes.widlprocxml new file mode 100644 index 000000000..89bd8ac9b --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/attributes.widlprocxml @@ -0,0 +1,38 @@ + + + + exception InvalidName { + DOMString reason; +}; + +exception NoSuchPet { }; + +interface Person { + + attribute unsigned short age; + +}; + + exception InvalidName { + DOMString reason; +}; + + DOMString reason; + + + + + exception NoSuchPet { }; + + + interface Person { + + attribute unsigned short age; + +}; + + attribute unsigned short age; + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/callback.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/callback.widlprocxml new file mode 100644 index 000000000..9eac06ce2 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/callback.widlprocxml @@ -0,0 +1,32 @@ + + + + callback AsyncOperationCallback = void (DOMString status); + +callback interface EventHandler { + void eventOccurred(DOMString details); +}; + + callback AsyncOperationCallback = void (DOMString status); + + + + + + + + + callback interface EventHandler { + void eventOccurred(DOMString details); +}; + + void eventOccurred(DOMString details); + + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/caller.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/caller.widlprocxml new file mode 100644 index 000000000..9754d4e02 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/caller.widlprocxml @@ -0,0 +1,21 @@ + + + + interface NumberQuadrupler { + legacycaller float compute(float x); +}; + + interface NumberQuadrupler { + legacycaller float compute(float x); +}; + + legacycaller float compute(float x); + + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/constants.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/constants.widlprocxml new file mode 100644 index 000000000..51cb4331f --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/constants.widlprocxml @@ -0,0 +1,85 @@ + + + + interface Util { + const boolean DEBUG = false; + const short negative = -1; + const octet LF = 10; + const unsigned long BIT_MASK = 0x0000fc00; + const float AVOGADRO = 6.022e23; + const unrestricted float sobig = Infinity; + const unrestricted double minusonedividedbyzero = -Infinity; + const short notanumber = NaN; +}; + +exception Error { + const short ERR_UNKNOWN = 0; + const short ERR_OUT_OF_MEMORY = 1; + + short errorCode; +}; + + interface Util { + const boolean DEBUG = false; + const short negative = -1; + const octet LF = 10; + const unsigned long BIT_MASK = 0x0000fc00; + const float AVOGADRO = 6.022e23; + const unrestricted float sobig = Infinity; + const unrestricted double minusonedividedbyzero = -Infinity; + const short notanumber = NaN; +}; + + const boolean DEBUG = false; + + + + const short negative = -1; + + + + const octet LF = 10; + + + + const unsigned long BIT_MASK = 0x0000fc00; + + + + const float AVOGADRO = 6.022e23; + + + + const unrestricted float sobig = Infinity; + + + + const unrestricted double minusonedividedbyzero = -Infinity; + + + + const short notanumber = NaN; + + + + + exception Error { + const short ERR_UNKNOWN = 0; + const short ERR_OUT_OF_MEMORY = 1; + + short errorCode; +}; + + const short ERR_UNKNOWN = 0; + + + + const short ERR_OUT_OF_MEMORY = 1; + + + + short errorCode; + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/constructor.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/constructor.widlprocxml new file mode 100644 index 000000000..8e78fbab3 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/constructor.widlprocxml @@ -0,0 +1,51 @@ + + + + [Constructor, + Constructor(float radius)] +interface Circle { + attribute float r; + attribute float cx; + attribute float cy; + readonly attribute float circumference; +}; + + [Constructor, + Constructor(float radius)] +interface Circle { + attribute float r; + attribute float cx; + attribute float cy; + readonly attribute float circumference; +}; + + + Constructor + + + Constructor(float radius) + + + + + + + + + attribute float r; + + + + attribute float cx; + + + + attribute float cy; + + + + readonly attribute float circumference; + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/dictionary-inherits.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/dictionary-inherits.widlprocxml new file mode 100644 index 000000000..269a83cd8 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/dictionary-inherits.widlprocxml @@ -0,0 +1,44 @@ + + + + dictionary PaintOptions { + DOMString? fillPattern = "black"; + DOMString? strokePattern = null; + Point position; +}; + +dictionary WetPaintOptions : PaintOptions { + float hydrometry; +}; + + dictionary PaintOptions { + DOMString? fillPattern = "black"; + DOMString? strokePattern = null; + Point position; +}; + + DOMString? fillPattern = "black"; + + + + DOMString? strokePattern = null; + + + + Point position; + + + + + dictionary WetPaintOptions : PaintOptions { + float hydrometry; +}; + + + + + float hydrometry; + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/dictionary.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/dictionary.widlprocxml new file mode 100644 index 000000000..978ccb4e2 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/dictionary.widlprocxml @@ -0,0 +1,47 @@ + + + + dictionary PaintOptions { + DOMString? fillPattern = "black"; + DOMString? strokePattern = null; + Point position; +}; + +partial dictionary A { + long h; + long d; +}; + + dictionary PaintOptions { + DOMString? fillPattern = "black"; + DOMString? strokePattern = null; + Point position; +}; + + DOMString? fillPattern = "black"; + + + + DOMString? strokePattern = null; + + + + Point position; + + + + + partial dictionary A { + long h; + long d; +}; + + long h; + + + + long d; + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/documentation-dos.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/documentation-dos.widlprocxml new file mode 100644 index 000000000..1611f0e57 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/documentation-dos.widlprocxml @@ -0,0 +1,59 @@ + + + + interface Documentation {}; + + interface Documentation {}; + + + Testing documentation features + + +

    +This is a +single paragraph +

    +

    +This is valid.

    +

    +This is valid.

    +

    +This is valid.

    +

    +This is valid.

    +
      +
    • +This
    • +
    • +is
    • +
    • +valid
    • +
    +
    +
    +This
    +
    +valid
    +
    + + + + + + + + +
    +this +is
    +valid
    +

    +This is
    valid.

    +

    +This is
    valid.

    +

    +This is
    valid.

    +
    +
    +
    +
    diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/documentation.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/documentation.widlprocxml new file mode 100644 index 000000000..afe4527c2 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/documentation.widlprocxml @@ -0,0 +1,61 @@ + + + + interface Documentation {}; + + interface Documentation {}; + + + Testing documentation features + + +

    +This is a +single paragraph +

    +

    +This is valid.

    +

    +This is valid.

    +

    +This is valid.

    +

    +This is valid.

    +
      +
    • +This
    • +
    • +is
    • +
    • +valid
    • +
    +
    +
    +This
    +
    +valid
    +
    + + + + + + + + +
    +this +is
    +valid
    +

    +This is
    valid.

    +

    +This is
    valid.

    +

    +This is
    valid.

    +

    +Valid

    +
    +
    +
    +
    diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/enum.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/enum.widlprocxml new file mode 100644 index 000000000..e1e8258fb --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/enum.widlprocxml @@ -0,0 +1,52 @@ + + + + enum MealType { "rice", "noodles", "other" }; + +interface Meal { + attribute MealType type; + attribute float size; + + void initialize(MealType type, float size); +}; + + enum MealType { "rice", "noodles", "other" }; + + "rice + + + "noodles + + + "other + + + + interface Meal { + attribute MealType type; + attribute float size; + + void initialize(MealType type, float size); +}; + + attribute MealType type; + + + + attribute float size; + + + + void initialize(MealType type, float size); + + + + + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/equivalent-decl.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/equivalent-decl.widlprocxml new file mode 100644 index 000000000..c322d0a5e --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/equivalent-decl.widlprocxml @@ -0,0 +1,111 @@ + + + + interface Dictionary { + readonly attribute unsigned long propertyCount; + + getter float getProperty(DOMString propertyName); + setter void setProperty(DOMString propertyName, float propertyValue); +}; + + +interface Dictionary { + readonly attribute unsigned long propertyCount; + + float getProperty(DOMString propertyName); + void setProperty(DOMString propertyName, float propertyValue); + + getter float (DOMString propertyName); + setter void (DOMString propertyName, float propertyValue); +}; + + interface Dictionary { + readonly attribute unsigned long propertyCount; + + getter float getProperty(DOMString propertyName); + setter void setProperty(DOMString propertyName, float propertyValue); +}; + + readonly attribute unsigned long propertyCount; + + + + getter float getProperty(DOMString propertyName); + + + + + + + + + setter void setProperty(DOMString propertyName, float propertyValue); + + + + + + + + + + + + + interface Dictionary { + readonly attribute unsigned long propertyCount; + + float getProperty(DOMString propertyName); + void setProperty(DOMString propertyName, float propertyValue); + + getter float (DOMString propertyName); + setter void (DOMString propertyName, float propertyValue); +}; + + readonly attribute unsigned long propertyCount; + + + + float getProperty(DOMString propertyName); + + + + + + + + + void setProperty(DOMString propertyName, float propertyValue); + + + + + + + + + + + + getter float (DOMString propertyName); + + + + + + + + + setter void (DOMString propertyName, float propertyValue); + + + + + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/exception-inheritance.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/exception-inheritance.widlprocxml new file mode 100644 index 000000000..3a1f868a4 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/exception-inheritance.widlprocxml @@ -0,0 +1,31 @@ + + + + exception DOMException { + unsigned short code; + }; + + exception HierarchyRequestError : DOMException { }; + exception NoModificationAllowedError : DOMException { }; + + exception DOMException { + unsigned short code; + }; + + unsigned short code; + + + + + exception HierarchyRequestError : DOMException { }; + + + + + + exception NoModificationAllowedError : DOMException { }; + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/exception.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/exception.widlprocxml new file mode 100644 index 000000000..ac93320fe --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/exception.widlprocxml @@ -0,0 +1,23 @@ + + + + interface Dahut { + attribute DOMString type; +}; + +exception SomeException { +}; + + interface Dahut { + attribute DOMString type; +}; + + attribute DOMString type; + + + + + exception SomeException { +}; + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/getter-setter.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/getter-setter.widlprocxml new file mode 100644 index 000000000..76afc058c --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/getter-setter.widlprocxml @@ -0,0 +1,43 @@ + + + + interface Dictionary { + readonly attribute unsigned long propertyCount; + + getter float (DOMString propertyName); + setter void (DOMString propertyName, float propertyValue); +}; + + interface Dictionary { + readonly attribute unsigned long propertyCount; + + getter float (DOMString propertyName); + setter void (DOMString propertyName, float propertyValue); +}; + + readonly attribute unsigned long propertyCount; + + + + getter float (DOMString propertyName); + + + + + + + + + setter void (DOMString propertyName, float propertyValue); + + + + + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/identifier-qualified-names.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/identifier-qualified-names.widlprocxml new file mode 100644 index 000000000..b6024e5ff --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/identifier-qualified-names.widlprocxml @@ -0,0 +1,107 @@ + + + + typedef float number; + + exception FrameworkException { + + const long ERR_NOT_FOUND = 1; + + long code; + }; + + interface System { + + object createObject(DOMString _interface); + + getter DOMString (DOMString keyName); + }; + + + interface TextField { + + attribute boolean _const; + + attribute DOMString? _value; + }; + +interface Foo { + void op(object interface); +}; + + typedef float number; + + + + exception FrameworkException { + + const long ERR_NOT_FOUND = 1; + + long code; + }; + + const long ERR_NOT_FOUND = 1; + + + + long code; + + + + + interface System { + + object createObject(DOMString _interface); + + getter DOMString (DOMString keyName); + }; + + object createObject(DOMString _interface); + + + + + + + + + getter DOMString (DOMString keyName); + + + + + + + + + + interface TextField { + + attribute boolean _const; + + attribute DOMString? _value; + }; + + attribute boolean _const; + + + + attribute DOMString? _value; + + + + + interface Foo { + void op(object interface); +}; + + void op(object interface); + + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/implements.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/implements.widlprocxml new file mode 100644 index 000000000..3d1c1ab84 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/implements.widlprocxml @@ -0,0 +1,51 @@ + + + + interface Node { + readonly attribute unsigned short nodeType; + }; + + interface EventTarget { + void addEventListener(DOMString type, + EventListener listener, + boolean useCapture); + }; + + Node implements EventTarget; + + interface Node { + readonly attribute unsigned short nodeType; + }; + + readonly attribute unsigned short nodeType; + + + + + interface EventTarget { + void addEventListener(DOMString type, + EventListener listener, + boolean useCapture); + }; + + void addEventListener(DOMString type, + EventListener listener, + boolean useCapture); + + + + + + + + + + + + + + + + Node implements EventTarget; + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/indexed-properties.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/indexed-properties.widlprocxml new file mode 100644 index 000000000..fb83621b6 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/indexed-properties.widlprocxml @@ -0,0 +1,92 @@ + + + + interface OrderedMap { + readonly attribute unsigned long size; + + getter any getByIndex(unsigned long index); + setter void setByIndex(unsigned long index, any value); + deleter void removeByIndex(unsigned long index); + + getter any get(DOMString name); + setter creator void set(DOMString name, any value); + deleter void remove(DOMString name); +}; + + interface OrderedMap { + readonly attribute unsigned long size; + + getter any getByIndex(unsigned long index); + setter void setByIndex(unsigned long index, any value); + deleter void removeByIndex(unsigned long index); + + getter any get(DOMString name); + setter creator void set(DOMString name, any value); + deleter void remove(DOMString name); +}; + + readonly attribute unsigned long size; + + + + getter any getByIndex(unsigned long index); + + + + + + + + + setter void setByIndex(unsigned long index, any value); + + + + + + + + + + + + deleter void removeByIndex(unsigned long index); + + + + + + + + + getter any get(DOMString name); + + + + + + + + + setter creator void set(DOMString name, any value); + + + + + + + + + + + + deleter void remove(DOMString name); + + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/inherits-getter.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/inherits-getter.widlprocxml new file mode 100644 index 000000000..55e7a317f --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/inherits-getter.widlprocxml @@ -0,0 +1,44 @@ + + + + interface Animal { + + readonly attribute DOMString name; +}; + +interface Person : Animal { + + readonly attribute unsigned short age; + + inherit attribute DOMString name; +}; + + interface Animal { + + readonly attribute DOMString name; +}; + + readonly attribute DOMString name; + + + + + interface Person : Animal { + + readonly attribute unsigned short age; + + inherit attribute DOMString name; +}; + + + + + readonly attribute unsigned short age; + + + + inherit attribute DOMString name; + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/interface-inherits.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/interface-inherits.widlprocxml new file mode 100644 index 000000000..94f0e29df --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/interface-inherits.widlprocxml @@ -0,0 +1,48 @@ + + + + interface Animal { + attribute DOMString name; +}; + +interface Human : Animal { + attribute Dog pet; +}; + +interface Dog : Animal { + attribute Human owner; +}; + + interface Animal { + attribute DOMString name; +}; + + attribute DOMString name; + + + + + interface Human : Animal { + attribute Dog pet; +}; + + + + + attribute Dog pet; + + + + + interface Dog : Animal { + attribute Human owner; +}; + + + + + attribute Human owner; + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/iterator.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/iterator.widlprocxml new file mode 100644 index 000000000..8ca95fbbd --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/iterator.widlprocxml @@ -0,0 +1,132 @@ + + + + interface SessionManager { + Session getSessionForUser(DOMString username); + readonly attribute unsigned long sessionCount; + + Session iterator; +}; + +interface Session { + readonly attribute DOMString username; +}; + +interface SessionManager2 { + Session2 getSessionForUser(DOMString username); + readonly attribute unsigned long sessionCount; + + Session2 iterator = SessionIterator; +}; + +interface Session2 { + readonly attribute DOMString username; +}; + +interface SessionIterator { + readonly attribute unsigned long remainingSessions; +}; + + interface NodeList { + Node iterator = NodeIterator; + }; + + interface NodeIterator { + Node iterator object; + }; + + interface SessionManager { + Session getSessionForUser(DOMString username); + readonly attribute unsigned long sessionCount; + + Session iterator; +}; + + Session getSessionForUser(DOMString username); + + + + + + + + + readonly attribute unsigned long sessionCount; + + + + Session iterator; + + + + + interface Session { + readonly attribute DOMString username; +}; + + readonly attribute DOMString username; + + + + + interface SessionManager2 { + Session2 getSessionForUser(DOMString username); + readonly attribute unsigned long sessionCount; + + Session2 iterator = SessionIterator; +}; + + Session2 getSessionForUser(DOMString username); + + + + + + + + + readonly attribute unsigned long sessionCount; + + + + Session2 iterator = SessionIterator; + + + + + interface Session2 { + readonly attribute DOMString username; +}; + + readonly attribute DOMString username; + + + + + interface SessionIterator { + readonly attribute unsigned long remainingSessions; +}; + + readonly attribute unsigned long remainingSessions; + + + + + interface NodeList { + Node iterator = NodeIterator; + }; + + Node iterator = NodeIterator; + + + + + interface NodeIterator { + Node iterator object; + }; + + Node iterator object; + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/module.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/module.widlprocxml new file mode 100644 index 000000000..b575b8705 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/module.widlprocxml @@ -0,0 +1,99 @@ + + + + + module gfx { + + module geom { + interface Shape { }; + interface Rectangle : Shape { }; + interface Path : Shape { }; + }; + + interface GraphicsContext { + void fillShape(geom::Shape s); + void strokeShape(geom::Shape s); + }; +}; + + module geom { + interface Shape { }; + interface Rectangle : Shape { }; + interface Path : Shape { }; + }; + + interface Shape { }; + + + interface Rectangle : Shape { }; + + + + + + interface Path : Shape { }; + + + + + + + interface GraphicsContext { + void fillShape(geom::Shape s); + void strokeShape(geom::Shape s); + }; + + void fillShape(geom::Shape s); + + + + + + + + + void strokeShape(geom::Shape s); + + + + + + + + + + + module gui { + + interface Widget { }; + + interface Window : Widget { + gfx::GraphicsContext getGraphicsContext(); + }; + + interface Button : Widget { }; +}; + + interface Widget { }; + + + interface Window : Widget { + gfx::GraphicsContext getGraphicsContext(); + }; + + + + + gfx::GraphicsContext getGraphicsContext(); + + + + + + interface Button : Widget { }; + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/namedconstructor.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/namedconstructor.widlprocxml new file mode 100644 index 000000000..9f6616128 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/namedconstructor.widlprocxml @@ -0,0 +1,30 @@ + + + + [NamedConstructor=Audio, + NamedConstructor=Audio(DOMString src)] +interface HTMLAudioElement : HTMLMediaElement { +}; + + [NamedConstructor=Audio, + NamedConstructor=Audio(DOMString src)] +interface HTMLAudioElement : HTMLMediaElement { +}; + + + NamedConstructor + + + NamedConstructor=Audio(DOMString src) + + + + + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/namespaceobject.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/namespaceobject.widlprocxml new file mode 100644 index 000000000..af0cde937 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/namespaceobject.widlprocxml @@ -0,0 +1,60 @@ + + + + + [NamespaceObject] +module acme { + + exception DeviceException { }; + + module pim { + + [Constructor] + interface Contact { }; + + [Constructor, + NamedConstructor=RecurringEvent(long freq)] + interface CalendarEvent { }; + }; +}; + + + + + exception DeviceException { }; + + + module pim { + + [Constructor] + interface Contact { }; + + [Constructor, + NamedConstructor=RecurringEvent(long freq)] + interface CalendarEvent { }; + }; + + [Constructor] + interface Contact { }; + + + + + + [Constructor, + NamedConstructor=RecurringEvent(long freq)] + interface CalendarEvent { }; + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/nointerfaceobject.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/nointerfaceobject.widlprocxml new file mode 100644 index 000000000..f64f116b6 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/nointerfaceobject.widlprocxml @@ -0,0 +1,28 @@ + + + + [NoInterfaceObject] +interface Query { + any lookupEntry(unsigned long key); +}; + + [NoInterfaceObject] +interface Query { + any lookupEntry(unsigned long key); +}; + + + NoInterfaceObject + + + + any lookupEntry(unsigned long key); + + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/nullable.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/nullable.widlprocxml new file mode 100644 index 000000000..8739e4432 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/nullable.widlprocxml @@ -0,0 +1,29 @@ + + + + interface MyConstants { + const boolean? ARE_WE_THERE_YET = false; +}; + +interface Node { + readonly attribute DOMString? namespaceURI; +}; + + interface MyConstants { + const boolean? ARE_WE_THERE_YET = false; +}; + + const boolean? ARE_WE_THERE_YET = false; + + + + + interface Node { + readonly attribute DOMString? namespaceURI; +}; + + readonly attribute DOMString? namespaceURI; + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/nullableobjects.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/nullableobjects.widlprocxml new file mode 100644 index 000000000..22d9fdd25 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/nullableobjects.widlprocxml @@ -0,0 +1,46 @@ + + + + interface A { +}; +interface B { +}; +interface C { + void f(A? x); + void f(B? x); + +}; + + interface A { +}; + + + interface B { +}; + + + interface C { + void f(A? x); + void f(B? x); + +}; + + void f(A? x); + + + + + + + + + void f(B? x); + + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/operation-optional-arg.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/operation-optional-arg.widlprocxml new file mode 100644 index 000000000..54aef1f87 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/operation-optional-arg.widlprocxml @@ -0,0 +1,30 @@ + + + + interface ColorCreator { + object createColor(float v1, float v2, float v3, optional float alpha = 3.5); +}; + + interface ColorCreator { + object createColor(float v1, float v2, float v3, optional float alpha = 3.5); +}; + + object createColor(float v1, float v2, float v3, optional float alpha = 3.5); + + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/overloading.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/overloading.widlprocxml new file mode 100644 index 000000000..db6da7a68 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/overloading.widlprocxml @@ -0,0 +1,113 @@ + + + + interface A { +}; + +interface B { +}; + +interface C { + void f(A x); + void f(B x); +}; + +interface A { +void f(DOMString a); +void f([AllowAny] DOMString a, DOMString b, float... c); +void f(); +void f(long a, DOMString b, optional DOMString c, float... d); +}; + + interface A { +}; + + + interface B { +}; + + + interface C { + void f(A x); + void f(B x); +}; + + void f(A x); + + + + + + + + + void f(B x); + + + + + + + + + + interface A { +void f(DOMString a); +void f([AllowAny] DOMString a, DOMString b, float... c); +void f(); +void f(long a, DOMString b, optional DOMString c, float... d); +}; + + void f(DOMString a); + + + + + + + + + void f([AllowAny] DOMString a, DOMString b, float... c); + + + + + + AllowAny + + + + + + + + + + + + + + void f(); + + + + + void f(long a, DOMString b, optional DOMString c, float... d); + + + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/overridebuiltins.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/overridebuiltins.widlprocxml new file mode 100644 index 000000000..56c92517b --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/overridebuiltins.widlprocxml @@ -0,0 +1,34 @@ + + + + [OverrideBuiltins] +interface StringMap2 { + readonly attribute unsigned long length; + getter DOMString lookup(DOMString key); +}; + + [OverrideBuiltins] +interface StringMap2 { + readonly attribute unsigned long length; + getter DOMString lookup(DOMString key); +}; + + + OverrideBuiltins + + + + readonly attribute unsigned long length; + + + + getter DOMString lookup(DOMString key); + + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/partial-interface.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/partial-interface.widlprocxml new file mode 100644 index 000000000..8d7dcb4e4 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/partial-interface.widlprocxml @@ -0,0 +1,29 @@ + + + + interface Foo { + attribute DOMString bar; +}; + +partial interface Foo { + attribute DOMString quux; +}; + + interface Foo { + attribute DOMString bar; +}; + + attribute DOMString bar; + + + + + partial interface Foo { + attribute DOMString quux; +}; + + attribute DOMString quux; + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/primitives.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/primitives.widlprocxml new file mode 100644 index 000000000..46977a2d7 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/primitives.widlprocxml @@ -0,0 +1,112 @@ + + + + interface Primitives { + attribute boolean truth; + attribute byte character; + attribute octet value; + attribute short number; + attribute unsigned short positive; + attribute long big; + attribute unsigned long bigpositive; + attribute long long bigbig; + attribute unsigned long long bigbigpositive; + attribute float real; + attribute double bigreal; + attribute unrestricted float realwithinfinity; + attribute unrestricted double bigrealwithinfinity; + attribute DOMString string; + attribute ByteString bytes; + attribute Date date; + attribute RegExp regexp; +}; + + interface Primitives { + attribute boolean truth; + attribute byte character; + attribute octet value; + attribute short number; + attribute unsigned short positive; + attribute long big; + attribute unsigned long bigpositive; + attribute long long bigbig; + attribute unsigned long long bigbigpositive; + attribute float real; + attribute double bigreal; + attribute unrestricted float realwithinfinity; + attribute unrestricted double bigrealwithinfinity; + attribute DOMString string; + attribute ByteString bytes; + attribute Date date; + attribute RegExp regexp; +}; + + attribute boolean truth; + + + + attribute byte character; + + + + attribute octet value; + + + + attribute short number; + + + + attribute unsigned short positive; + + + + attribute long big; + + + + attribute unsigned long bigpositive; + + + + attribute long long bigbig; + + + + attribute unsigned long long bigbigpositive; + + + + attribute float real; + + + + attribute double bigreal; + + + + attribute unrestricted float realwithinfinity; + + + + attribute unrestricted double bigrealwithinfinity; + + + + attribute DOMString string; + + + + attribute ByteString bytes; + + + + attribute Date date; + + + + attribute RegExp regexp; + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/prototyperoot.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/prototyperoot.widlprocxml new file mode 100644 index 000000000..2e56cd75e --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/prototyperoot.widlprocxml @@ -0,0 +1,23 @@ + + + + [PrototypeRoot] +interface Node { + readonly attribute unsigned short nodeType; +}; + + [PrototypeRoot] +interface Node { + readonly attribute unsigned short nodeType; +}; + + + PrototypeRoot + + + + readonly attribute unsigned short nodeType; + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/putforwards.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/putforwards.widlprocxml new file mode 100644 index 000000000..634fad55a --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/putforwards.widlprocxml @@ -0,0 +1,27 @@ + + + + interface Person { + [PutForwards=full] readonly attribute Name name; + attribute unsigned short age; +}; + + interface Person { + [PutForwards=full] readonly attribute Name name; + attribute unsigned short age; +}; + + [PutForwards=full] readonly attribute Name name; + + + PutForwards + + + + + + attribute unsigned short age; + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/reg-operations.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/reg-operations.widlprocxml new file mode 100644 index 000000000..3b756ed68 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/reg-operations.widlprocxml @@ -0,0 +1,70 @@ + + + + interface Dimensions { + attribute unsigned long width; + attribute unsigned long height; +}; + +exception NoPointerDevice { }; + +interface Button { + + boolean isMouseOver(); + + void setDimensions(Dimensions size); + void setDimensions(unsigned long width, unsigned long height); +}; + + interface Dimensions { + attribute unsigned long width; + attribute unsigned long height; +}; + + attribute unsigned long width; + + + + attribute unsigned long height; + + + + + exception NoPointerDevice { }; + + + interface Button { + + boolean isMouseOver(); + + void setDimensions(Dimensions size); + void setDimensions(unsigned long width, unsigned long height); +}; + + boolean isMouseOver(); + + + + + void setDimensions(Dimensions size); + + + + + + + + + void setDimensions(unsigned long width, unsigned long height); + + + + + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/replaceable.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/replaceable.widlprocxml new file mode 100644 index 000000000..f97621668 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/replaceable.widlprocxml @@ -0,0 +1,28 @@ + + + + interface Counter { + [Replaceable] readonly attribute unsigned long value; + void increment(); +}; + + interface Counter { + [Replaceable] readonly attribute unsigned long value; + void increment(); +}; + + [Replaceable] readonly attribute unsigned long value; + + + Replaceable + + + + + + void increment(); + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/sequence.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/sequence.widlprocxml new file mode 100644 index 000000000..d5f456417 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/sequence.widlprocxml @@ -0,0 +1,32 @@ + + + + interface Canvas { + void drawPolygon(sequence<float> coordinates); + sequence<float> getInflectionPoints(); +}; + + interface Canvas { + void drawPolygon(sequence<float> coordinates); + sequence<float> getInflectionPoints(); +}; + + void drawPolygon(sequence<float> coordinates); + + + + + + + + + + + sequence<float> getInflectionPoints(); + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/serializer.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/serializer.widlprocxml new file mode 100644 index 000000000..eb4219f8a --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/serializer.widlprocxml @@ -0,0 +1,296 @@ + + + + interface Transaction { + readonly attribute Account from; + readonly attribute Account to; + readonly attribute float amount; + readonly attribute DOMString description; + readonly attribute unsigned long number; + + serializer; +}; + +interface Account { + attribute DOMString name; + attribute unsigned long number; + serializer DOMString serialize(); +}; + +interface Transaction2 { + readonly attribute Account2 from; + readonly attribute Account2 to; + readonly attribute float amount; + readonly attribute DOMString description; + readonly attribute unsigned long number; + + serializer = { from, to, amount, description }; +}; + +interface Account2 { + attribute DOMString name; + attribute unsigned long number; + serializer = number; +}; + +interface Account3 { + attribute DOMString name; + attribute unsigned long number; + + serializer = { attribute }; +}; + +interface Account4 { + getter object getItem(unsigned long index); + serializer = { getter }; +}; + +interface Account5 : Account { + attribute DOMString secondname; + serializer = { inherit, secondname }; +}; + +interface Account6 : Account { + attribute DOMString secondname; + serializer = { inherit, attribute }; +}; + +interface Account7 { + attribute DOMString name; + attribute unsigned long number; + serializer = [ name, number ]; +}; + +interface Account8 { + getter object getItem(unsigned long index); + serializer = [ getter ]; +}; + + interface Transaction { + readonly attribute Account from; + readonly attribute Account to; + readonly attribute float amount; + readonly attribute DOMString description; + readonly attribute unsigned long number; + + serializer; +}; + + readonly attribute Account from; + + + + readonly attribute Account to; + + + + readonly attribute float amount; + + + + readonly attribute DOMString description; + + + + readonly attribute unsigned long number; + + + + serializer; + + + + interface Account { + attribute DOMString name; + attribute unsigned long number; + serializer DOMString serialize(); +}; + + attribute DOMString name; + + + + attribute unsigned long number; + + + + serializer DOMString serialize(); + + + + + + interface Transaction2 { + readonly attribute Account2 from; + readonly attribute Account2 to; + readonly attribute float amount; + readonly attribute DOMString description; + readonly attribute unsigned long number; + + serializer = { from, to, amount, description }; +}; + + readonly attribute Account2 from; + + + + readonly attribute Account2 to; + + + + readonly attribute float amount; + + + + readonly attribute DOMString description; + + + + readonly attribute unsigned long number; + + + + serializer = { from, to, amount, description }; + + + + + + + + + + interface Account2 { + attribute DOMString name; + attribute unsigned long number; + serializer = number; +}; + + attribute DOMString name; + + + + attribute unsigned long number; + + + + serializer = number; + + + + interface Account3 { + attribute DOMString name; + attribute unsigned long number; + + serializer = { attribute }; +}; + + attribute DOMString name; + + + + attribute unsigned long number; + + + + serializer = { attribute }; + + + + + interface Account4 { + getter object getItem(unsigned long index); + serializer = { getter }; +}; + + getter object getItem(unsigned long index); + + + + + + + + + serializer = { getter }; + + + + + interface Account5 : Account { + attribute DOMString secondname; + serializer = { inherit, secondname }; +}; + + + + + attribute DOMString secondname; + + + + serializer = { inherit, secondname }; + + + + + + + interface Account6 : Account { + attribute DOMString secondname; + serializer = { inherit, attribute }; +}; + + + + + attribute DOMString secondname; + + + + serializer = { inherit, attribute }; + + + + + interface Account7 { + attribute DOMString name; + attribute unsigned long number; + serializer = [ name, number ]; +}; + + attribute DOMString name; + + + + attribute unsigned long number; + + + + serializer = [ name, number ]; + + + + + + + + interface Account8 { + getter object getItem(unsigned long index); + serializer = [ getter ]; +}; + + getter object getItem(unsigned long index); + + + + + + + + + serializer = [ getter ]; + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/special-omittable.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/special-omittable.widlprocxml new file mode 100644 index 000000000..1986d190a --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/special-omittable.widlprocxml @@ -0,0 +1,37 @@ + + + + + interface Dictionary { + readonly attribute unsigned long propertyCount; + + omittable getter float getProperty(DOMString propertyName); + omittable setter void setProperty(DOMString propertyName, float propertyValue); +}; + + readonly attribute unsigned long propertyCount; + + + + omittable getter float getProperty(DOMString propertyName); + + + + + + + + + omittable setter void setProperty(DOMString propertyName, float propertyValue); + + + + + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/static.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/static.widlprocxml new file mode 100644 index 000000000..03c14e16e --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/static.widlprocxml @@ -0,0 +1,58 @@ + + + + interface Point { }; + +interface Circle { + attribute float cx; + attribute float cy; + attribute float radius; + + static readonly attribute long triangulationCount; + static Point triangulate(Circle c1, Circle c2, Circle c3); +}; + + interface Point { }; + + + interface Circle { + attribute float cx; + attribute float cy; + attribute float radius; + + static readonly attribute long triangulationCount; + static Point triangulate(Circle c1, Circle c2, Circle c3); +}; + + attribute float cx; + + + + attribute float cy; + + + + attribute float radius; + + + + static readonly attribute long triangulationCount; + + + + static Point triangulate(Circle c1, Circle c2, Circle c3); + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/stringifier-attribute.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/stringifier-attribute.widlprocxml new file mode 100644 index 000000000..082ce4d34 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/stringifier-attribute.widlprocxml @@ -0,0 +1,29 @@ + + + + [Constructor] +interface Student { + attribute unsigned long id; + stringifier attribute DOMString name; +}; + + [Constructor] +interface Student { + attribute unsigned long id; + stringifier attribute DOMString name; +}; + + + Constructor + + + + attribute unsigned long id; + + + + stringifier attribute DOMString name; + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/stringifier-custom.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/stringifier-custom.widlprocxml new file mode 100644 index 000000000..cdab1ccfc --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/stringifier-custom.widlprocxml @@ -0,0 +1,44 @@ + + + + [Constructor] +interface Student { + attribute unsigned long id; + attribute DOMString? familyName; + attribute DOMString givenName; + + stringifier DOMString (); +}; + + [Constructor] +interface Student { + attribute unsigned long id; + attribute DOMString? familyName; + attribute DOMString givenName; + + stringifier DOMString (); +}; + + + Constructor + + + + attribute unsigned long id; + + + + attribute DOMString? familyName; + + + + attribute DOMString givenName; + + + + stringifier DOMString (); + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/stringifier.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/stringifier.widlprocxml new file mode 100644 index 000000000..4a18b80b7 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/stringifier.widlprocxml @@ -0,0 +1,29 @@ + + + + interface A { + stringifier DOMString (); +}; + +interface A { + stringifier; +}; + + interface A { + stringifier DOMString (); +}; + + stringifier DOMString (); + + + + + + interface A { + stringifier; +}; + + stringifier; + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/treatasnull.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/treatasnull.widlprocxml new file mode 100644 index 000000000..a57ae163f --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/treatasnull.widlprocxml @@ -0,0 +1,40 @@ + + + + interface Dog { + attribute DOMString name; + attribute DOMString owner; + + boolean isMemberOfBreed([TreatNullAs=EmptyString] DOMString breedName); +}; + + interface Dog { + attribute DOMString name; + attribute DOMString owner; + + boolean isMemberOfBreed([TreatNullAs=EmptyString] DOMString breedName); +}; + + attribute DOMString name; + + + + attribute DOMString owner; + + + + boolean isMemberOfBreed([TreatNullAs=EmptyString] DOMString breedName); + + + + + + TreatNullAs + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/treatasundefined.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/treatasundefined.widlprocxml new file mode 100644 index 000000000..17e71081d --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/treatasundefined.widlprocxml @@ -0,0 +1,40 @@ + + + + interface Cat { + attribute DOMString name; + attribute DOMString owner; + + boolean isMemberOfBreed([TreatUndefinedAs=EmptyString] DOMString breedName); +}; + + interface Cat { + attribute DOMString name; + attribute DOMString owner; + + boolean isMemberOfBreed([TreatUndefinedAs=EmptyString] DOMString breedName); +}; + + attribute DOMString name; + + + + attribute DOMString owner; + + + + boolean isMemberOfBreed([TreatUndefinedAs=EmptyString] DOMString breedName); + + + + + + TreatUndefinedAs + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/typedef.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/typedef.widlprocxml new file mode 100644 index 000000000..785f6706e --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/typedef.widlprocxml @@ -0,0 +1,100 @@ + + + + interface Point { + attribute float x; + attribute float y; + }; + + typedef sequence<Point> PointSequence; + + interface Rect { + attribute Point topleft; + attribute Point bottomright; + }; + + interface Widget { + + readonly attribute Rect bounds; + + boolean pointWithinBounds(Point p); + boolean allPointsWithinBounds(PointSequence ps); + }; + + typedef [Clamp] octet value; + + interface Point { + attribute float x; + attribute float y; + }; + + attribute float x; + + + + attribute float y; + + + + + typedef sequence<Point> PointSequence; + + + + + + interface Rect { + attribute Point topleft; + attribute Point bottomright; + }; + + attribute Point topleft; + + + + attribute Point bottomright; + + + + + interface Widget { + + readonly attribute Rect bounds; + + boolean pointWithinBounds(Point p); + boolean allPointsWithinBounds(PointSequence ps); + }; + + readonly attribute Rect bounds; + + + + boolean pointWithinBounds(Point p); + + + + + + + + + boolean allPointsWithinBounds(PointSequence ps); + + + + + + + + + + typedef [Clamp] octet value; + + + + Clamp + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/typesuffixes.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/typesuffixes.widlprocxml new file mode 100644 index 000000000..830fe62bc --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/typesuffixes.widlprocxml @@ -0,0 +1,25 @@ + + + + interface Suffixes { + void test(sequence<DOMString[]?>? foo); +}; + + interface Suffixes { + void test(sequence<DOMString[]?>? foo); +}; + + void test(sequence<DOMString[]?>? foo); + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/uniontype.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/uniontype.widlprocxml new file mode 100644 index 000000000..7d0880799 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/uniontype.widlprocxml @@ -0,0 +1,26 @@ + + + + interface Union { + attribute (float or (Date or Event) or (Node or DOMString)?) test; +}; + + interface Union { + attribute (float or (Date or Event) or (Node or DOMString)?) test; +}; + + attribute (float or (Date or Event) or (Node or DOMString)?) test; + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/variadic-operations.widlprocxml b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/variadic-operations.widlprocxml new file mode 100644 index 000000000..0bc9f7844 --- /dev/null +++ b/testing/web-platform/tests/resources/webidl2/test/widlproc/test/valid/xml/variadic-operations.widlprocxml @@ -0,0 +1,40 @@ + + + + interface IntegerSet { + readonly attribute unsigned long cardinality; + + void union(long... ints); + void intersection(long... ints); +}; + + interface IntegerSet { + readonly attribute unsigned long cardinality; + + void union(long... ints); + void intersection(long... ints); +}; + + readonly attribute unsigned long cardinality; + + + + void union(long... ints); + + + + + + + + + void intersection(long... ints); + + + + + + + + + -- cgit v1.2.3