From 9af61ee45a7f7b10397b1a039803c8ca687a3338 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Sat, 24 Dec 2016 14:14:30 +0100 Subject: [PATCH] licensing and readme for new structure + candy generator --- .settings/org.eclipse.wst.common.component | 6 - ....eclipse.wst.common.project.facet.core.xml | 6 - LICENSE | 203 +- README.md | 187 +- doc/LICENSE | 359 + jsweet-candy-generator/.gitignore | 8 + jsweet-candy-generator/CONTRIBUTING.md | 26 + jsweet-candy-generator/LICENSE | 674 + jsweet-candy-generator/README.md | 2 + jsweet-candy-generator/build.xml | 66 + jsweet-candy-generator/copyright.txt | 16 + jsweet-candy-generator/pom.xml | 206 + .../org/jsweet/JSweetDefTranslatorConfig.java | 255 + .../typescriptdef/TypescriptDef2Java.java | 457 + .../typescriptdef/ast/AbstractAstNode.java | 46 + .../ast/AbstractDeclaration.java | 302 + .../typescriptdef/ast/AbstractPrinter.java | 127 + .../ast/AbstractTypedDeclaration.java | 29 + .../typescriptdef/ast/ArrayTypeReference.java | 87 + .../input/typescriptdef/ast/AstNode.java | 23 + .../typescriptdef/ast/CompilationUnit.java | 195 + .../input/typescriptdef/ast/Context.java | 615 + .../input/typescriptdef/ast/Declaration.java | 48 + .../ast/DeclarationContainer.java | 35 + .../typescriptdef/ast/DeclarationHelper.java | 411 + .../ast/FullFunctionDeclaration.java | 35 + .../ast/FunctionDeclaration.java | 121 + .../ast/FunctionalTypeReference.java | 102 + .../input/typescriptdef/ast/Literal.java | 30 + .../typescriptdef/ast/ModuleDeclaration.java | 117 + .../input/typescriptdef/ast/NamedElement.java | 15 + .../ast/ParameterDeclaration.java | 38 + .../ast/QualifiedDeclaration.java | 35 + .../ast/ReferenceDeclaration.java | 55 + .../input/typescriptdef/ast/Scanner.java | 743 + .../jsweet/input/typescriptdef/ast/Token.java | 80 + .../jsweet/input/typescriptdef/ast/Type.java | 9 + .../typescriptdef/ast/TypeDeclaration.java | 247 + .../ast/TypeMacroDeclaration.java | 45 + .../ast/TypeParameterDeclaration.java | 47 + .../ast/TypeParameterizedElement.java | 9 + .../typescriptdef/ast/TypeReference.java | 231 + .../typescriptdef/ast/TypedDeclaration.java | 10 + .../typescriptdef/ast/UnionTypeReference.java | 352 + .../ast/VariableDeclaration.java | 59 + .../input/typescriptdef/ast/Visitable.java | 12 + .../input/typescriptdef/ast/Visitor.java | 33 + .../input/typescriptdef/parser/GenParser.java | 11 + .../typescriptdef/parser/SyntaxError.java | 34 + .../typescriptdef/parser/TestParser.java | 11 + .../parser/TypescriptDefParser.java | 3291 ++++ .../parser/TypescriptDefScanner.java | 1329 ++ .../parser/TypescriptDefScanner.java~ | 1258 ++ .../input/typescriptdef/parser/sym.java | 88 + .../input/typescriptdef/parser/test.d.ts | 108 + .../typescriptdef/parser/typescriptdef.cup | 628 + .../typescriptdef/parser/typescriptdef.lex | 225 + .../typescriptdef/util/CopyrightHelper.java | 57 + .../typescriptdef/util/DeclarationFinder.java | 71 + .../typescriptdef/util/DirectedGraph.java | 503 + .../input/typescriptdef/util/NameUtils.java | 26 + .../input/typescriptdef/util/NodeFinder.java | 69 + .../input/typescriptdef/util/ProcessUtil.java | 82 + .../jsweet/input/typescriptdef/util/Tree.java | 367 + .../jsweet/input/typescriptdef/util/Util.java | 636 + .../visitor/ConstructorInterfacesMerger.java | 80 + .../ConstructorTypeReferenceReplacer.java | 34 + .../visitor/DeclarationBinder.java | 38 + .../typescriptdef/visitor/DocFiller.java | 400 + .../visitor/DuplicateMethodsCleaner.java | 645 + .../DynamicTypeParametersExpander.java | 74 + .../visitor/EmptyConstructorAdder.java | 58 + .../visitor/EmptyModulesCleaner.java | 51 + .../visitor/FactoryMethodsCreator.java | 58 + .../visitor/FieldTypeFunctionInjector.java | 149 + .../visitor/ForEachClashRemover.java | 46 + .../visitor/FunctionKindAdapter.java | 49 + .../visitor/FunctionTypeOfReplacer.java | 45 + .../visitor/FunctionalInterfacesCreator.java | 193 + .../visitor/FunctionalParametersExpander.java | 44 + .../typescriptdef/visitor/GlobalsCreator.java | 72 + .../ImportedAndExportedReferenceExpander.java | 504 + .../visitor/IterableInjector.java | 82 + .../visitor/JavaDefModelPrinter.java | 614 + .../visitor/ModuleToTypeMerger.java | 78 + .../typescriptdef/visitor/NameAdapter.java | 66 + .../typescriptdef/visitor/NameChecker.java | 91 + .../visitor/ObjectTypeCreator.java | 164 + .../visitor/ObjectTypeDuplicateMerger.java | 164 + .../OptionalLambdasParametersExpander.java | 105 + .../visitor/OptionalParametersExpander.java | 48 + ...alParametersInFunctionalTypesExpander.java | 54 + .../visitor/PackageOrganizer.java | 88 + .../ParentMethodReturnTypeSusbtitutor.java | 86 + .../visitor/SerializableHandler.java | 43 + .../visitor/StringTypeCreator.java | 126 + .../visitor/StringTypeExpander.java | 53 + .../visitor/SuperTypesMerger.java | 122 + .../visitor/TupleTypeCreator.java | 89 + .../visitor/TypeKindChooser.java | 47 + .../visitor/TypeMacroReplacer.java | 134 + .../typescriptdef/visitor/TypeMerger.java | 151 + .../visitor/TypeParametersSubstitutor.java | 99 + .../visitor/TypeReferenceChecker.java | 22 + .../visitor/TypeReferenceExpander.java | 68 + .../visitor/UnionInterfacesCreator.java | 113 + .../visitor/UnionTypesEraser.java | 46 + .../visitor/UnionTypesExpander.java | 146 + .../src/main/resources/DefinitelyTypedLicense | 8 + .../src/main/resources/TypeScriptLicense | 53 + .../src/main/resources/application.properties | 3 + .../src/main/resources/log4j.properties | 8 + .../typescriptdef/test/AbstractTest.java | 99 + .../typescriptdef/test/PackagingTest.java | 186 + .../typescriptdef/test/StructureTest.java | 47 + .../input/typescriptdef/test/SyntaxTest.java | 88 + .../typescriptdef/test/TranslationTest.java | 509 + .../test/references/import-test.d.ts | 55 + .../structure/constructor-interface-test.d.ts | 15 + .../test/structure/globals-test.d.ts | 25 + .../test/syntax/comment1-test.d.ts | 124 + .../test/syntax/comment2-test.d.ts | 107 + .../test/syntax/comment3-test.d.ts | 44 + .../test/syntax/default-test.d.ts | 134 + .../typescriptdef/test/syntax/enum-test.d.ts | 32 + .../test/syntax/export-test.d.ts | 14 + .../test/syntax/identifier-test.d.ts | 14 + .../test/syntax/keyword-test.d.ts | 59 + .../typescriptdef/test/syntax/lf-test.d.ts | 24 + .../test/types/default-test.d.ts | 127 + .../test/types/functional-interface-test.d.ts | 17 + .../test/types/object-type-test.d.ts | 28 + .../test/types/type-macro-test.d.ts | 77 + .../typescriptdef/test/types/type-test.d.ts | 30 + .../test/types/union-type-test.d.ts | 38 + .../src/test/resources/lib.core/lib.core.d.ts | 3922 +++++ .../test/resources/lib.core/lib.core.ext.d.ts | 52 + .../src/test/resources/lib.core/lib.dom.d.ts | 13208 ++++++++++++++++ jsweet-core/LICENSE | 202 + jsweet-transpiler/.gitignore | 1 + jsweet-transpiler/CONTRIBUTING.md | 26 + jsweet-transpiler/LICENSE | 202 + jsweet-transpiler/README.md | 183 + jsweet-transpiler/copyright.txt | 16 + 144 files changed, 40431 insertions(+), 393 deletions(-) delete mode 100644 .settings/org.eclipse.wst.common.component delete mode 100644 .settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 doc/LICENSE create mode 100644 jsweet-candy-generator/.gitignore create mode 100644 jsweet-candy-generator/CONTRIBUTING.md create mode 100644 jsweet-candy-generator/LICENSE create mode 100644 jsweet-candy-generator/README.md create mode 100644 jsweet-candy-generator/build.xml create mode 100644 jsweet-candy-generator/copyright.txt create mode 100644 jsweet-candy-generator/pom.xml create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/JSweetDefTranslatorConfig.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/TypescriptDef2Java.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/AbstractAstNode.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/AbstractDeclaration.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/AbstractPrinter.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/AbstractTypedDeclaration.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/ArrayTypeReference.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/AstNode.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/CompilationUnit.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Context.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Declaration.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/DeclarationContainer.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/DeclarationHelper.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/FullFunctionDeclaration.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/FunctionDeclaration.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/FunctionalTypeReference.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Literal.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/ModuleDeclaration.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/NamedElement.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/ParameterDeclaration.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/QualifiedDeclaration.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/ReferenceDeclaration.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Scanner.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Token.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Type.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypeDeclaration.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypeMacroDeclaration.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypeParameterDeclaration.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypeParameterizedElement.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypeReference.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypedDeclaration.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/UnionTypeReference.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/VariableDeclaration.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Visitable.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Visitor.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/GenParser.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/SyntaxError.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/TestParser.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/TypescriptDefParser.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/TypescriptDefScanner.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/TypescriptDefScanner.java~ create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/sym.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/test.d.ts create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/typescriptdef.cup create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/typescriptdef.lex create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/CopyrightHelper.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/DeclarationFinder.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/DirectedGraph.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/NameUtils.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/NodeFinder.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/ProcessUtil.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/Tree.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/Util.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ConstructorInterfacesMerger.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ConstructorTypeReferenceReplacer.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/DeclarationBinder.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/DocFiller.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/DuplicateMethodsCleaner.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/DynamicTypeParametersExpander.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/EmptyConstructorAdder.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/EmptyModulesCleaner.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FactoryMethodsCreator.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FieldTypeFunctionInjector.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ForEachClashRemover.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FunctionKindAdapter.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FunctionTypeOfReplacer.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FunctionalInterfacesCreator.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FunctionalParametersExpander.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/GlobalsCreator.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ImportedAndExportedReferenceExpander.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/IterableInjector.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/JavaDefModelPrinter.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ModuleToTypeMerger.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/NameAdapter.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/NameChecker.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ObjectTypeCreator.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ObjectTypeDuplicateMerger.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/OptionalLambdasParametersExpander.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/OptionalParametersExpander.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/OptionalParametersInFunctionalTypesExpander.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/PackageOrganizer.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ParentMethodReturnTypeSusbtitutor.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/SerializableHandler.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/StringTypeCreator.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/StringTypeExpander.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/SuperTypesMerger.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TupleTypeCreator.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeKindChooser.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeMacroReplacer.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeMerger.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeParametersSubstitutor.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeReferenceChecker.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeReferenceExpander.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/UnionInterfacesCreator.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/UnionTypesEraser.java create mode 100644 jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/UnionTypesExpander.java create mode 100644 jsweet-candy-generator/src/main/resources/DefinitelyTypedLicense create mode 100644 jsweet-candy-generator/src/main/resources/TypeScriptLicense create mode 100644 jsweet-candy-generator/src/main/resources/application.properties create mode 100644 jsweet-candy-generator/src/main/resources/log4j.properties create mode 100644 jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/AbstractTest.java create mode 100644 jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/PackagingTest.java create mode 100644 jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/StructureTest.java create mode 100644 jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/SyntaxTest.java create mode 100644 jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/TranslationTest.java create mode 100644 jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/references/import-test.d.ts create mode 100644 jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/structure/constructor-interface-test.d.ts create mode 100644 jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/structure/globals-test.d.ts create mode 100644 jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/comment1-test.d.ts create mode 100644 jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/comment2-test.d.ts create mode 100644 jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/comment3-test.d.ts create mode 100644 jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/default-test.d.ts create mode 100644 jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/enum-test.d.ts create mode 100644 jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/export-test.d.ts create mode 100644 jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/identifier-test.d.ts create mode 100644 jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/keyword-test.d.ts create mode 100644 jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/lf-test.d.ts create mode 100644 jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/default-test.d.ts create mode 100644 jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/functional-interface-test.d.ts create mode 100644 jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/object-type-test.d.ts create mode 100644 jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/type-macro-test.d.ts create mode 100644 jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/type-test.d.ts create mode 100644 jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/union-type-test.d.ts create mode 100644 jsweet-candy-generator/src/test/resources/lib.core/lib.core.d.ts create mode 100644 jsweet-candy-generator/src/test/resources/lib.core/lib.core.ext.d.ts create mode 100644 jsweet-candy-generator/src/test/resources/lib.core/lib.dom.d.ts create mode 100644 jsweet-core/LICENSE create mode 100644 jsweet-transpiler/CONTRIBUTING.md create mode 100644 jsweet-transpiler/LICENSE create mode 100644 jsweet-transpiler/README.md create mode 100644 jsweet-transpiler/copyright.txt diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component deleted file mode 100644 index 6b280f18..00000000 --- a/.settings/org.eclipse.wst.common.component +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml deleted file mode 100644 index 22590b00..00000000 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/LICENSE b/LICENSE index 8f71f43f..539455f6 100644 --- a/LICENSE +++ b/LICENSE @@ -1,202 +1 @@ - 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. - +Each project has its own licensing, we therefore invite you to check each one individually. diff --git a/README.md b/README.md index 2015b480..e01ca03a 100644 --- a/README.md +++ b/README.md @@ -1,183 +1,12 @@ -# JSweet: a Java to JavaScript transpiler [![Build Status](https://travis-ci.org/cincheo/jsweet.svg?branch=master)](https://travis-ci.org/cincheo/jsweet) +# Welcome on the JSweet repository! -JSweet leverages TypeScript to write rich and responsive Web applications in Java through the use of JavaScript libraries and frameworks. With JSweet, Java programs are transpiled (source-to-source compiled) to TypeScript and JavaScript for being run in browsers, mobile Web views, or in Node.js. - -* JSweet is safe and reliable. It provides web applications with type-checking and generates fully type-checked JavaScript programs. It stands on Oracle's Java Compiler (javac) and on Microsoft's TypeScript (tsc). -* JSweet allows you to use your favorite JS library ([JSweet+Angular2](https://github.com/cincheo/jsweet-angular2-quickstart), [JSweet+threejs](https://github.com/cincheo/jsweet-examples-threejs), [IONIC/Cordova](https://github.com/lgrignon/jsweet-cordova-ionic-example), ...). -* JSweet enables code sharing between server-side Java and client-side JavaScript. JSweet provides implementations for the core Java libraries for code sharing and legacy Java migration purpose. -* JSweet is fast, lightweight and fully JavaScript-interoperable. The generated code is regular JavaScript code, which implies no overhead compared to JavaScript, and can directly interoperate with existing JavaScript programs and libraries. - -How does it work? JSweet depends on well-typed descriptions of JavaScript APIs, so-called "candies", most of them being automatically generated from TypeScript definition files. These API descriptions in Java can be seen as headers (similarly to *.h header files in C) to bridge JavaSript libraries from Java. There are several sources of candies for existing libraries and you can easily build a candy for any library out there (see [more details](http://www.jsweet.org/jsweet-candies/)). - -With JSweet, you take advantage of all the Java tooling (IDE's, Maven, ...) to program real JavaScript applications using the latest JavaScript libraries. - -## Java -> TypeScript -> JavaScript - -Here is a first taste of what you get by using JSweet. Consider this simple Java program: - -```java -package org.jsweet; - -import static jsweet.dom.Globals.*; - -/** - * This is a very simple example that just shows an alert. - */ -public class HelloWorld { - public static void main(String[] args) { - alert("Hi there!"); - } -} -``` - -Transpiling with JSweet gives the following TypeScript program: - -```TypeScript -namespace org.jsweet { - /** - * This is a very simple example that just shows an alert. - */ - export class HelloWorld { - public static main(args : string[]) { - alert("Hi there!"); - } - } -} -org.jsweet.HelloWorld.main(null); -``` - -Which in turn produces the following JavaScript output: - -```JavaScript -var org; -(function (org) { - var jsweet; - (function (jsweet) { - /** - * This is a very simple example that just shows an alert. - */ - var HelloWorld = (function () { - function HelloWorld() { - } - HelloWorld.main = function (args) { - alert("Hi there!"); - }; - return HelloWorld; - }()); - jsweet.HelloWorld = HelloWorld; - })(jsweet = org.jsweet || (org.jsweet = {})); -})(org || (org = {})); -org.jsweet.HelloWorld.main(null); -``` - -More with the [live sandbox](http://www.jsweet.org/jsweet-live-sandbox/). - -## Features - -- Full syntax mapping between Java and TypeScript, including classes, interfaces, functional types, union types, tuple types, object types, string types, and so on. -- Extensive support of Java constructs and semantics added since [version 1.1.0](https://github.com/cincheo/jsweet/releases/tag/v1.1.0) (inner classes, anonymous classes, final fields, method overloading, instanceof operator, static initializers, ...). -- *Over 1000 JavaScript libraries*, frameworks and plugins to write Web and Mobile HTML5 applications (JQuery, Underscore, Angular, Backbone, Cordova, Node.js, and much [more](http://www.jsweet.org/candies-snapshots/)). -- A [Maven repository](http://repository.jsweet.org/artifactory) containing all the available libraries in Maven artifacts (a.k.a. candies). -- Support for Java basic APIs as the [J4TS](https://github.com/cincheo/j4ts) candy (forked from the GWT's JRE emulation). -- An [Eclipse plugin](https://github.com/cincheo/jsweet-eclipse-plugin) for easy installation and use. -- A [Maven plugin](https://github.com/lgrignon/jsweet-maven-plugin) to use JSweet from any other IDE or from the command line. -- A debug mode to enable Java code debugging within your favorite browser. -- A set of nice [WEB/Mobile HTML5 examples](https://github.com/cincheo/jsweet-examples) to get started and get used to JSweet and the most common JavaScript APIs (even more examples in the Examples section). -- Support for bundles to run the generated programs in the most simple way. -- Support for JavaScript modules (commonjs, amd, umd). JSweet programs *can* run in a browser or in Node.js. -- Support for various EcmaScript target versions (ES3 to ES6). -- ... - -For more details, go to the [language specifications](https://github.com/cincheo/jsweet/blob/master/doc/jsweet-language-specifications.md) ([PDF](https://github.com/cincheo/jsweet/raw/master/doc/jsweet-language-specifications.pdf)). - -## Getting started - -- Step 1: Install (or check that you have installed) [Git](https://git-scm.com/downloads), [Node.js](https://nodejs.org) and [Maven](https://maven.apache.org/) (commands `git`, `node`, `npm` and `mvn` should be in your path). -- Step 2: Clone the [jsweet-quickstart](https://github.com/cincheo/jsweet-quickstart) project from Github: -``` -> git clone https://github.com/cincheo/jsweet-quickstart.git -``` -- Step 3: Run the transpiler to generate the JavaScript code: -``` -> cd jsweet-quickstart -> mvn generate-sources -``` -- Step 4: Check out the result in your browser: -``` -> firefox webapp/index.html -``` -- Step 5: Edit the project and start programming: - - Checkout the examples to see various use cases - - Get access to hundreds of [libs (candies)](http://www.jsweet.org/jsweet-candies/) - - Refer to the [language specifications](https://github.com/cincheo/jsweet/blob/master/doc/jsweet-language-specifications.md) to know more about programming with JSweet - - Eclipse users: install the [Eclipse plugin](http://www.jsweet.org/eclipse-plugin/) to get inline error reporting, build-on-save, and easy configuration UI - -More info at http://www.jsweet.org. - -## Examples - -- Simple examples illustrating the use of various frameworks in Java (jQuery, Underscore, Backbone, AngularJS, Knockout): https://github.com/cincheo/jsweet-examples -- Simple examples illustrating the use of the Threejs framework in Java: https://github.com/cincheo/jsweet-examples-threejs) -- Node.js + Socket.IO + AngularJS: https://github.com/lgrignon/jsweet-node-example -- Some simple examples to get started with React.js: https://github.com/cincheo/jsweet-examples-react -- JSweet JAX-RS server example (how to share a Java model between client and server): https://github.com/lgrignon/jsweet-jaxrs-server-example -- JSweet Cordova / Polymer example: https://github.com/lgrignon/jsweet-cordova-polymer-example -- JSweet Cordova / Ionic example: https://github.com/lgrignon/jsweet-cordova-ionic-example -- JSweet Angular 2 example: https://github.com/cincheo/jsweet-angular2-quickstart -- JSweet Angular 2 + PrimeNG: https://github.com/cincheo/jsweet-primeng-quickstart - -## Tooling - -- [Eclipse plugin](https://github.com/cincheo/jsweet-eclipse-plugin) -- [Maven plugin](https://github.com/lgrignon/jsweet-maven-plugin) -- [Gradle plugin](https://github.com/lgrignon/jsweet-gradle-plugin) - -## News and more information - -Most information is available on the http://www.jsweet.org. Developers, check out the [wiki](https://github.com/cincheo/jsweet/wiki). - -## How to build - -Prerequisites: `node` and `npm` executables must be in the path (https://nodejs.org). Note that there seem to be an issue with the `node` executable on some Unix-based machines, which should be fixed (see for instance: http://askubuntu.com/questions/235655/node-js-conflicts-sbin-node-vs-usr-bin-node). - -To build the `jsweet-transpiler` jars (in the project's directory): - -``` -> mvn package -``` - -To install the `jsweet-transpiler` artifact in your local Maven repository: - -``` -> mvn install -``` - -Note that current JUnit tests launch a Node.js instance for each test and will be quite slow (this will be improved). In order to easily test some changes locally without having to run all the tests, use the following command: - -``` -> mvn package -Dmaven.test.skip=true -``` - -or - -``` -> mvn install -Dmaven.test.skip=true -``` - -To generate the markdown language specifications from the Latex source file with [Pandoc](http://pandoc.org/): - -``` -> cd doc -> pandoc -r latex -w markdown_github --base-header-level=2 -s --toc --number-sections -B header.md -o jsweet-language-specifications.md jsweet-language-specifications.tex -``` - -Note that the following command will output the document in HTML: - -``` -> pandoc -r latex -w html5 --base-header-level=3 -o jsweet-language-specifications.html jsweet-language-specifications.tex -``` +Let us take you to the project you are looking for: +* [JSweet transpiler](https://github.com/cincheo/jsweet/tree/master/jsweet-transpiler) +* [JSweet documentation](https://github.com/cincheo/jsweet/tree/master/doc) +* [JSweet core candy](https://github.com/cincheo/jsweet/tree/master/jsweet-core) +* [JDK runtime for TypeScript](https://github.com/cincheo/jsweet/tree/master/j4ts) +* [JSweet candy generator](https://github.com/cincheo/jsweet/tree/master/jsweet-candy-generator) ## License - -JSweet is under the Apache 2.0 Open Source license. +Each project has its own licensing, we therefore invite you to check each one individually. diff --git a/doc/LICENSE b/doc/LICENSE new file mode 100644 index 00000000..604209a8 --- /dev/null +++ b/doc/LICENSE @@ -0,0 +1,359 @@ +Creative Commons Legal Code + +Attribution-ShareAlike 3.0 Unported + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR + DAMAGES RESULTING FROM ITS USE. + +License + +THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE +COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY +COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS +AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. + +BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE +TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY +BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS +CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND +CONDITIONS. + +1. Definitions + + a. "Adaptation" means a work based upon the Work, or upon the Work and + other pre-existing works, such as a translation, adaptation, + derivative work, arrangement of music or other alterations of a + literary or artistic work, or phonogram or performance and includes + cinematographic adaptations or any other form in which the Work may be + recast, transformed, or adapted including in any form recognizably + derived from the original, except that a work that constitutes a + Collection will not be considered an Adaptation for the purpose of + this License. For the avoidance of doubt, where the Work is a musical + work, performance or phonogram, the synchronization of the Work in + timed-relation with a moving image ("synching") will be considered an + Adaptation for the purpose of this License. + b. "Collection" means a collection of literary or artistic works, such as + encyclopedias and anthologies, or performances, phonograms or + broadcasts, or other works or subject matter other than works listed + in Section 1(f) below, which, by reason of the selection and + arrangement of their contents, constitute intellectual creations, in + which the Work is included in its entirety in unmodified form along + with one or more other contributions, each constituting separate and + independent works in themselves, which together are assembled into a + collective whole. A work that constitutes a Collection will not be + considered an Adaptation (as defined below) for the purposes of this + License. + c. "Creative Commons Compatible License" means a license that is listed + at https://creativecommons.org/compatiblelicenses that has been + approved by Creative Commons as being essentially equivalent to this + License, including, at a minimum, because that license: (i) contains + terms that have the same purpose, meaning and effect as the License + Elements of this License; and, (ii) explicitly permits the relicensing + of adaptations of works made available under that license under this + License or a Creative Commons jurisdiction license with the same + License Elements as this License. + d. "Distribute" means to make available to the public the original and + copies of the Work or Adaptation, as appropriate, through sale or + other transfer of ownership. + e. "License Elements" means the following high-level license attributes + as selected by Licensor and indicated in the title of this License: + Attribution, ShareAlike. + f. "Licensor" means the individual, individuals, entity or entities that + offer(s) the Work under the terms of this License. + g. "Original Author" means, in the case of a literary or artistic work, + the individual, individuals, entity or entities who created the Work + or if no individual or entity can be identified, the publisher; and in + addition (i) in the case of a performance the actors, singers, + musicians, dancers, and other persons who act, sing, deliver, declaim, + play in, interpret or otherwise perform literary or artistic works or + expressions of folklore; (ii) in the case of a phonogram the producer + being the person or legal entity who first fixes the sounds of a + performance or other sounds; and, (iii) in the case of broadcasts, the + organization that transmits the broadcast. + h. "Work" means the literary and/or artistic work offered under the terms + of this License including without limitation any production in the + literary, scientific and artistic domain, whatever may be the mode or + form of its expression including digital form, such as a book, + pamphlet and other writing; a lecture, address, sermon or other work + of the same nature; a dramatic or dramatico-musical work; a + choreographic work or entertainment in dumb show; a musical + composition with or without words; a cinematographic work to which are + assimilated works expressed by a process analogous to cinematography; + a work of drawing, painting, architecture, sculpture, engraving or + lithography; a photographic work to which are assimilated works + expressed by a process analogous to photography; a work of applied + art; an illustration, map, plan, sketch or three-dimensional work + relative to geography, topography, architecture or science; a + performance; a broadcast; a phonogram; a compilation of data to the + extent it is protected as a copyrightable work; or a work performed by + a variety or circus performer to the extent it is not otherwise + considered a literary or artistic work. + i. "You" means an individual or entity exercising rights under this + License who has not previously violated the terms of this License with + respect to the Work, or who has received express permission from the + Licensor to exercise rights under this License despite a previous + violation. + j. "Publicly Perform" means to perform public recitations of the Work and + to communicate to the public those public recitations, by any means or + process, including by wire or wireless means or public digital + performances; to make available to the public Works in such a way that + members of the public may access these Works from a place and at a + place individually chosen by them; to perform the Work to the public + by any means or process and the communication to the public of the + performances of the Work, including by public digital performance; to + broadcast and rebroadcast the Work by any means including signs, + sounds or images. + k. "Reproduce" means to make copies of the Work by any means including + without limitation by sound or visual recordings and the right of + fixation and reproducing fixations of the Work, including storage of a + protected performance or phonogram in digital form or other electronic + medium. + +2. Fair Dealing Rights. Nothing in this License is intended to reduce, +limit, or restrict any uses free from copyright or rights arising from +limitations or exceptions that are provided for in connection with the +copyright protection under copyright law or other applicable laws. + +3. License Grant. Subject to the terms and conditions of this License, +Licensor hereby grants You a worldwide, royalty-free, non-exclusive, +perpetual (for the duration of the applicable copyright) license to +exercise the rights in the Work as stated below: + + a. to Reproduce the Work, to incorporate the Work into one or more + Collections, and to Reproduce the Work as incorporated in the + Collections; + b. to create and Reproduce Adaptations provided that any such Adaptation, + including any translation in any medium, takes reasonable steps to + clearly label, demarcate or otherwise identify that changes were made + to the original Work. For example, a translation could be marked "The + original work was translated from English to Spanish," or a + modification could indicate "The original work has been modified."; + c. to Distribute and Publicly Perform the Work including as incorporated + in Collections; and, + d. to Distribute and Publicly Perform Adaptations. + e. For the avoidance of doubt: + + i. Non-waivable Compulsory License Schemes. In those jurisdictions in + which the right to collect royalties through any statutory or + compulsory licensing scheme cannot be waived, the Licensor + reserves the exclusive right to collect such royalties for any + exercise by You of the rights granted under this License; + ii. Waivable Compulsory License Schemes. In those jurisdictions in + which the right to collect royalties through any statutory or + compulsory licensing scheme can be waived, the Licensor waives the + exclusive right to collect such royalties for any exercise by You + of the rights granted under this License; and, + iii. Voluntary License Schemes. The Licensor waives the right to + collect royalties, whether individually or, in the event that the + Licensor is a member of a collecting society that administers + voluntary licensing schemes, via that society, from any exercise + by You of the rights granted under this License. + +The above rights may be exercised in all media and formats whether now +known or hereafter devised. The above rights include the right to make +such modifications as are technically necessary to exercise the rights in +other media and formats. Subject to Section 8(f), all rights not expressly +granted by Licensor are hereby reserved. + +4. Restrictions. The license granted in Section 3 above is expressly made +subject to and limited by the following restrictions: + + a. You may Distribute or Publicly Perform the Work only under the terms + of this License. You must include a copy of, or the Uniform Resource + Identifier (URI) for, this License with every copy of the Work You + Distribute or Publicly Perform. You may not offer or impose any terms + on the Work that restrict the terms of this License or the ability of + the recipient of the Work to exercise the rights granted to that + recipient under the terms of the License. You may not sublicense the + Work. You must keep intact all notices that refer to this License and + to the disclaimer of warranties with every copy of the Work You + Distribute or Publicly Perform. When You Distribute or Publicly + Perform the Work, You may not impose any effective technological + measures on the Work that restrict the ability of a recipient of the + Work from You to exercise the rights granted to that recipient under + the terms of the License. This Section 4(a) applies to the Work as + incorporated in a Collection, but this does not require the Collection + apart from the Work itself to be made subject to the terms of this + License. If You create a Collection, upon notice from any Licensor You + must, to the extent practicable, remove from the Collection any credit + as required by Section 4(c), as requested. If You create an + Adaptation, upon notice from any Licensor You must, to the extent + practicable, remove from the Adaptation any credit as required by + Section 4(c), as requested. + b. You may Distribute or Publicly Perform an Adaptation only under the + terms of: (i) this License; (ii) a later version of this License with + the same License Elements as this License; (iii) a Creative Commons + jurisdiction license (either this or a later license version) that + contains the same License Elements as this License (e.g., + Attribution-ShareAlike 3.0 US)); (iv) a Creative Commons Compatible + License. If you license the Adaptation under one of the licenses + mentioned in (iv), you must comply with the terms of that license. If + you license the Adaptation under the terms of any of the licenses + mentioned in (i), (ii) or (iii) (the "Applicable License"), you must + comply with the terms of the Applicable License generally and the + following provisions: (I) You must include a copy of, or the URI for, + the Applicable License with every copy of each Adaptation You + Distribute or Publicly Perform; (II) You may not offer or impose any + terms on the Adaptation that restrict the terms of the Applicable + License or the ability of the recipient of the Adaptation to exercise + the rights granted to that recipient under the terms of the Applicable + License; (III) You must keep intact all notices that refer to the + Applicable License and to the disclaimer of warranties with every copy + of the Work as included in the Adaptation You Distribute or Publicly + Perform; (IV) when You Distribute or Publicly Perform the Adaptation, + You may not impose any effective technological measures on the + Adaptation that restrict the ability of a recipient of the Adaptation + from You to exercise the rights granted to that recipient under the + terms of the Applicable License. This Section 4(b) applies to the + Adaptation as incorporated in a Collection, but this does not require + the Collection apart from the Adaptation itself to be made subject to + the terms of the Applicable License. + c. If You Distribute, or Publicly Perform the Work or any Adaptations or + Collections, You must, unless a request has been made pursuant to + Section 4(a), keep intact all copyright notices for the Work and + provide, reasonable to the medium or means You are utilizing: (i) the + name of the Original Author (or pseudonym, if applicable) if supplied, + and/or if the Original Author and/or Licensor designate another party + or parties (e.g., a sponsor institute, publishing entity, journal) for + attribution ("Attribution Parties") in Licensor's copyright notice, + terms of service or by other reasonable means, the name of such party + or parties; (ii) the title of the Work if supplied; (iii) to the + extent reasonably practicable, the URI, if any, that Licensor + specifies to be associated with the Work, unless such URI does not + refer to the copyright notice or licensing information for the Work; + and (iv) , consistent with Ssection 3(b), in the case of an + Adaptation, a credit identifying the use of the Work in the Adaptation + (e.g., "French translation of the Work by Original Author," or + "Screenplay based on original Work by Original Author"). The credit + required by this Section 4(c) may be implemented in any reasonable + manner; provided, however, that in the case of a Adaptation or + Collection, at a minimum such credit will appear, if a credit for all + contributing authors of the Adaptation or Collection appears, then as + part of these credits and in a manner at least as prominent as the + credits for the other contributing authors. For the avoidance of + doubt, You may only use the credit required by this Section for the + purpose of attribution in the manner set out above and, by exercising + Your rights under this License, You may not implicitly or explicitly + assert or imply any connection with, sponsorship or endorsement by the + Original Author, Licensor and/or Attribution Parties, as appropriate, + of You or Your use of the Work, without the separate, express prior + written permission of the Original Author, Licensor and/or Attribution + Parties. + d. Except as otherwise agreed in writing by the Licensor or as may be + otherwise permitted by applicable law, if You Reproduce, Distribute or + Publicly Perform the Work either by itself or as part of any + Adaptations or Collections, You must not distort, mutilate, modify or + take other derogatory action in relation to the Work which would be + prejudicial to the Original Author's honor or reputation. Licensor + agrees that in those jurisdictions (e.g. Japan), in which any exercise + of the right granted in Section 3(b) of this License (the right to + make Adaptations) would be deemed to be a distortion, mutilation, + modification or other derogatory action prejudicial to the Original + Author's honor and reputation, the Licensor will waive or not assert, + as appropriate, this Section, to the fullest extent permitted by the + applicable national law, to enable You to reasonably exercise Your + right under Section 3(b) of this License (right to make Adaptations) + but not otherwise. + +5. Representations, Warranties and Disclaimer + +UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR +OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY +KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, +INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, +FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF +LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, +WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION +OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. + +6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE +LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR +ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES +ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. Termination + + a. This License and the rights granted hereunder will terminate + automatically upon any breach by You of the terms of this License. + Individuals or entities who have received Adaptations or Collections + from You under this License, however, will not have their licenses + terminated provided such individuals or entities remain in full + compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will + survive any termination of this License. + b. Subject to the above terms and conditions, the license granted here is + perpetual (for the duration of the applicable copyright in the Work). + Notwithstanding the above, Licensor reserves the right to release the + Work under different license terms or to stop distributing the Work at + any time; provided, however that any such election will not serve to + withdraw this License (or any other license that has been, or is + required to be, granted under the terms of this License), and this + License will continue in full force and effect unless terminated as + stated above. + +8. Miscellaneous + + a. Each time You Distribute or Publicly Perform the Work or a Collection, + the Licensor offers to the recipient a license to the Work on the same + terms and conditions as the license granted to You under this License. + b. Each time You Distribute or Publicly Perform an Adaptation, Licensor + offers to the recipient a license to the original Work on the same + terms and conditions as the license granted to You under this License. + c. If any provision of this License is invalid or unenforceable under + applicable law, it shall not affect the validity or enforceability of + the remainder of the terms of this License, and without further action + by the parties to this agreement, such provision shall be reformed to + the minimum extent necessary to make such provision valid and + enforceable. + d. No term or provision of this License shall be deemed waived and no + breach consented to unless such waiver or consent shall be in writing + and signed by the party to be charged with such waiver or consent. + e. This License constitutes the entire agreement between the parties with + respect to the Work licensed here. There are no understandings, + agreements or representations with respect to the Work not specified + here. Licensor shall not be bound by any additional provisions that + may appear in any communication from You. This License may not be + modified without the mutual written agreement of the Licensor and You. + f. The rights granted under, and the subject matter referenced, in this + License were drafted utilizing the terminology of the Berne Convention + for the Protection of Literary and Artistic Works (as amended on + September 28, 1979), the Rome Convention of 1961, the WIPO Copyright + Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 + and the Universal Copyright Convention (as revised on July 24, 1971). + These rights and subject matter take effect in the relevant + jurisdiction in which the License terms are sought to be enforced + according to the corresponding provisions of the implementation of + those treaty provisions in the applicable national law. If the + standard suite of rights granted under applicable copyright law + includes additional rights not granted under this License, such + additional rights are deemed to be included in the License; this + License is not intended to restrict the license of any rights under + applicable law. + + +Creative Commons Notice + + Creative Commons is not a party to this License, and makes no warranty + whatsoever in connection with the Work. Creative Commons will not be + liable to You or any party on any legal theory for any damages + whatsoever, including without limitation any general, special, + incidental or consequential damages arising in connection to this + license. Notwithstanding the foregoing two (2) sentences, if Creative + Commons has expressly identified itself as the Licensor hereunder, it + shall have all rights and obligations of Licensor. + + Except for the limited purpose of indicating to the public that the + Work is licensed under the CCPL, Creative Commons does not authorize + the use by either party of the trademark "Creative Commons" or any + related trademark or logo of Creative Commons without the prior + written consent of Creative Commons. Any permitted use will be in + compliance with Creative Commons' then-current trademark usage + guidelines, as may be published on its website or otherwise made + available upon request from time to time. For the avoidance of doubt, + this trademark restriction does not form part of the License. + + Creative Commons may be contacted at https://creativecommons.org/. diff --git a/jsweet-candy-generator/.gitignore b/jsweet-candy-generator/.gitignore new file mode 100644 index 00000000..64cc92f7 --- /dev/null +++ b/jsweet-candy-generator/.gitignore @@ -0,0 +1,8 @@ +/target/ +/bin/ +/.classpath +/.project +/.settings/ +/js/ +/.jsweet/ +typings \ No newline at end of file diff --git a/jsweet-candy-generator/CONTRIBUTING.md b/jsweet-candy-generator/CONTRIBUTING.md new file mode 100644 index 00000000..40beef23 --- /dev/null +++ b/jsweet-candy-generator/CONTRIBUTING.md @@ -0,0 +1,26 @@ + +## What to contribute? + +Check out the issues and [wiki](https://github.com/cincheo/jsweet/wiki) for bugs, sub-projects and features where your contributions could be useful. + +## Your contributions + +Your contributions are most welcome. Bugs and features should be first reported in the Github issues space, so that we all know who is working on what, and so that we avoid duplicate efforts. + +### Bug fixes + +Bug fixes should come with the corresponding test(s) if possible. + +### Features + +Please make sure that contributed new features has been discussed thoroughly first (check out existing issues and the Wiki). It is important that they come with the appropriate test case(s) if possible. + + +## Contribution License Agreement + +By contributing through a pull request, you acknowledge that you fully own your Contribution and that you are legally entitled to make it available to the JSweet project under the terms and conditions of the Apache 2.0 license. This license implies that you grant the JSweet project, and those who receive the code directly or indirectly from the JSweet project, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license in the Contribution to reproduce, prepare derivative works of, publicly display, publicly perform, and distribute your Contribution and such derivative works, and to sublicense any or all of the foregoing rights to third parties. + +Your execution and/or acceptance of this agreement does not influence any of your right and title to use and distribute your own Contribution. + + + diff --git a/jsweet-candy-generator/LICENSE b/jsweet-candy-generator/LICENSE new file mode 100644 index 00000000..94a9ed02 --- /dev/null +++ b/jsweet-candy-generator/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/jsweet-candy-generator/README.md b/jsweet-candy-generator/README.md new file mode 100644 index 00000000..facf5bb8 --- /dev/null +++ b/jsweet-candy-generator/README.md @@ -0,0 +1,2 @@ +# JSweet candy generator +This tool is a helper to scaffold & package candy starting from a TypeScript definition file diff --git a/jsweet-candy-generator/build.xml b/jsweet-candy-generator/build.xml new file mode 100644 index 00000000..8606c75e --- /dev/null +++ b/jsweet-candy-generator/build.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + installing local tools.jar in local maven: ${lib.path} + WARNING: this script requires that your JAVA_HOME environment variable points to the Java 8 JDK (not JRE) + note that under Eclipse, you can locally set your JAVA_HOME variable in "External tools configuration -> Environment" + + + + + + + + WARNING: a successful build does not necessarily mean that you installed the right version of tools.jar + + + + + + + + + + + + + + Generating TSDef API parser... + + + + + + + + + + + + + + + Generating TSDef API lexer... + + + + + + + + diff --git a/jsweet-candy-generator/copyright.txt b/jsweet-candy-generator/copyright.txt new file mode 100644 index 00000000..eec3cfef --- /dev/null +++ b/jsweet-candy-generator/copyright.txt @@ -0,0 +1,16 @@ +/* + * JSweet - http://www.jsweet.org + * Copyright (C) 2015 CINCHEO SAS + * + * 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. + */ \ No newline at end of file diff --git a/jsweet-candy-generator/pom.xml b/jsweet-candy-generator/pom.xml new file mode 100644 index 00000000..8ee2bfc1 --- /dev/null +++ b/jsweet-candy-generator/pom.xml @@ -0,0 +1,206 @@ + + 4.0.0 + org.jsweet + jsweet-candy-generator + 2.0.0-SNAPSHOT + JSweet candy generator + + + rpawlak + Renaud Pawlak + renaud.pawlak@gmail.com + + + lgrignon + Louis Grignon + louis.grignon@gmail.com + + + + + jsweet-central + libs-release + http://repository.jsweet.org/artifactory/libs-release-local + + + + jsweet-snapshots + libs-snapshot + http://repository.jsweet.org/artifactory/libs-snapshot-local + + + jsweet-external + libs-release + http://repository.jsweet.org/artifactory/ext-release-local + + + + + cincheo + cincheo + http://repository.jsweet.org/artifactory/cincheo + + + + src/main/java + src/test/java + + + src/test/resources + true + + + + + src/main/resources + true + + + + + maven-compiler-plugin + 3.1 + + 1.8 + 1.8 + + + + + + maven-antrun-plugin + 1.7 + + + generate-sources + + + + + + + + + + run + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.apache.maven.plugins + + + maven-antrun-plugin + + + [1.7,) + + + run + + + + + + + + + + + + + + + + com.martiansoftware + jsap + 2.1 + + + edu.princeton.cup + java-cup + 10k + + + de.jflex + jflex + 1.3.5 + + + log4j + log4j + 1.2.17 + + + + org.apache.commons + commons-lang3 + 3.3.2 + + + commons-io + commons-io + 2.4 + + + org.jsoup + jsoup + 1.7.2 + + + + org.jsweet + jsweet-core + 5-SNAPSHOT + + + + com.google.code.gson + gson + 2.2.4 + compile + false + + + junit + junit + 4.12 + test + + + + JSweet + http://www.jsweet.org + + A project that defines translators that translate Javascript API definitions such as Typescript or IDL to Candies: JSweet defition APIs. + + + + cincheo + cincheo + http://repository.jsweet.org/artifactory/cincheo + + + cincheo + cincheo + http://repository.jsweet.org/artifactory/cincheo + + + + \ No newline at end of file diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/JSweetDefTranslatorConfig.java b/jsweet-candy-generator/src/main/java/org/jsweet/JSweetDefTranslatorConfig.java new file mode 100644 index 00000000..0dc01e74 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/JSweetDefTranslatorConfig.java @@ -0,0 +1,255 @@ +package org.jsweet; + +import java.io.InputStream; +import java.util.HashSet; +import java.util.Properties; +import java.util.Set; + +/** + * This class contains static constants and utilities. + * + * @author Renaud Pawlak + */ +public abstract class JSweetDefTranslatorConfig { + + private JSweetDefTranslatorConfig() { + } + + /** + * The properties coming from application.properties. + */ + public static Properties APPLICATION_PROPERTIES = new Properties(); + + static { + try (InputStream in = JSweetDefTranslatorConfig.class.getResourceAsStream("/application.properties")) { + APPLICATION_PROPERTIES.load(in); + in.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Gets the version number (not including suffix). + */ + public static String getVersionNumber() { + return APPLICATION_PROPERTIES.getProperty("application.version").split("-")[0]; + } + + /** + * The Maven group id where candies are deployed. + */ + public final static String MAVEN_CANDIES_GROUP = "org.jsweet.candies"; + + private final static String JAVA_PACKAGE = "java"; + public final static String ROOT_PACKAGE = "jsweet"; + /** The constant for the JSweet lang package. */ + public final static String LANG_PACKAGE = ROOT_PACKAGE + ".lang"; + /** The constant for the JSweet util package. */ + public final static String UTIL_PACKAGE = ROOT_PACKAGE + ".util"; + /** + * The constant for the JSweet lib package (where the definitions need to + * be). + */ + public final static String LIBS_PACKAGE = "def"; + /** The constant for the JSweet dom package. */ + public final static String DOM_PACKAGE = ROOT_PACKAGE + ".dom"; + /** + * The constant for the package generates top-level classes (one cannot use + * unnamed package in Java). + */ + public static final String GLOBALS_PACKAGE_NAME = "globals"; + /** + * The constant for the classes where members are generated as top-level + * elements (global variables and functions). + */ + public static final String GLOBALS_CLASS_NAME = "Globals"; + /** The constant for predefined utilities. */ + public static final String UTIL_CLASSNAME = UTIL_PACKAGE + ".Globals"; + /** + * The constant for the interface name that contains all the generated + * string types (short name). + */ + public static final String STRING_TYPES_INTERFACE_NAME = "StringTypes"; + /** The constant for the function classes package. */ + public static final String FUNCTION_CLASSES_PACKAGE = UTIL_PACKAGE + ".function"; + /** The constant for the tuple classes package. */ + public static final String TUPLE_CLASSES_PACKAGE = UTIL_PACKAGE + ".tuple"; + /** The constant for the tuple classes prefix. */ + public static final String TUPLE_CLASSES_PREFIX = "Tuple"; + /** The constant for the package containing union types. */ + public static final String UNION_PACKAGE = UTIL_PACKAGE + ".union"; + /** The constant for the Union core class full name. */ + public static final String UNION_CLASS_NAME = UNION_PACKAGE + ".Union"; + /** The constant for indexed access function. */ + public static final String INDEXED_GET_FUCTION_NAME = "$get"; + /** The constant for indexed assignment function. */ + public static final String INDEXED_SET_FUCTION_NAME = "$set"; + public static final String INDEXED_DELETE_FUCTION_NAME = "$delete"; + public static final String NEW_FUNCTION_NAME = "$new"; + public static final String ANONYMOUS_FUNCTION_NAME = "apply"; + public static final String ANONYMOUS_STATIC_FUNCTION_NAME = "applyStatic"; + + /** + * Default name of the directory where the TypeScript definition files can + * be found. + */ + public static final String TS_LIBS_DIR_NAME = "typings"; + + /** + * The constant for main functions (translate to global code, which is + * executed when the file is loaded). + */ + public static final String MAIN_FUNCTION_NAME = "main"; + + public static final String OBJECT_CLASSNAME = JSweetDefTranslatorConfig.LANG_PACKAGE + ".Object"; + + public static final String ANNOTATION_DISABLED = JSweetDefTranslatorConfig.LANG_PACKAGE + ".Disabled"; + public static final String ANNOTATION_ERASED = JSweetDefTranslatorConfig.LANG_PACKAGE + ".Erased"; + public static final String ANNOTATION_AMBIENT = JSweetDefTranslatorConfig.LANG_PACKAGE + ".Ambient"; + public static final String ANNOTATION_MIXIN = JSweetDefTranslatorConfig.LANG_PACKAGE + ".Mixin"; + public static final String ANNOTATION_OBJECT_TYPE = JSweetDefTranslatorConfig.LANG_PACKAGE + ".ObjectType"; + public static final String ANNOTATION_INTERFACE = JSweetDefTranslatorConfig.LANG_PACKAGE + ".Interface"; + public static final String ANNOTATION_OPTIONAL = JSweetDefTranslatorConfig.LANG_PACKAGE + ".Optional"; + public static final String ANNOTATION_STRING_TYPE = JSweetDefTranslatorConfig.LANG_PACKAGE + ".StringType"; + public static final String ANNOTATION_MODULE = JSweetDefTranslatorConfig.LANG_PACKAGE + ".Module"; + public static final String ANNOTATION_ROOT = JSweetDefTranslatorConfig.LANG_PACKAGE + ".Root"; + public static final String ANNOTATION_NAME = JSweetDefTranslatorConfig.LANG_PACKAGE + ".Name"; + public static final String ANNOTATION_EXTENDS = JSweetDefTranslatorConfig.LANG_PACKAGE + ".Extends"; + public static final String ANNOTATION_FUNCTIONAL_INTERFACE = FunctionalInterface.class.getName(); + + /** + * This map contains the Java keywords that are taken into account in the + * generation for avoiding keyword clashes. + */ + public static final Set JAVA_KEYWORDS = new HashSet(); + + public static final Set JAVA_TS_KEYWORDS = new HashSet(); + + /** + * This map contains the JS keywords that are taken into account in the + * generation for avoiding keyword clashes. + */ + public static final Set JS_KEYWORDS = new HashSet(); + + static { + // note TS keywords are removed from that list + JAVA_KEYWORDS.add("abstract"); + JAVA_KEYWORDS.add("assert"); + // JAVA_KEYWORDS.add("boolean"); + JAVA_KEYWORDS.add("break"); + JAVA_KEYWORDS.add("byte"); + JAVA_KEYWORDS.add("case"); + JAVA_KEYWORDS.add("catch"); + JAVA_KEYWORDS.add("char"); + // JAVA_KEYWORDS.add("class"); + JAVA_KEYWORDS.add("const"); + JAVA_KEYWORDS.add("continue"); + JAVA_KEYWORDS.add("default"); + JAVA_KEYWORDS.add("do"); + JAVA_KEYWORDS.add("double"); + JAVA_KEYWORDS.add("else"); + // JAVA_KEYWORDS.add("enum"); + JAVA_KEYWORDS.add("extends"); + JAVA_KEYWORDS.add("final"); + JAVA_KEYWORDS.add("finally"); + JAVA_KEYWORDS.add("float"); + JAVA_KEYWORDS.add("for"); + JAVA_KEYWORDS.add("goto"); + JAVA_KEYWORDS.add("if"); + // JAVA_KEYWORDS.add("implements"); + JAVA_KEYWORDS.add("import"); + JAVA_KEYWORDS.add("instanceof"); + JAVA_KEYWORDS.add("int"); + // JAVA_KEYWORDS.add("interface"); + JAVA_KEYWORDS.add("long"); + JAVA_KEYWORDS.add("native"); + JAVA_KEYWORDS.add("new"); + JAVA_KEYWORDS.add("package"); + JAVA_KEYWORDS.add("private"); + JAVA_KEYWORDS.add("protected"); + JAVA_KEYWORDS.add("public"); + JAVA_KEYWORDS.add("return"); + JAVA_KEYWORDS.add("short"); + JAVA_KEYWORDS.add("static"); + JAVA_KEYWORDS.add("strictfp"); + JAVA_KEYWORDS.add("super"); + JAVA_KEYWORDS.add("switch"); + JAVA_KEYWORDS.add("synchronized"); + JAVA_KEYWORDS.add("this"); + JAVA_KEYWORDS.add("throw"); + JAVA_KEYWORDS.add("throws"); + JAVA_KEYWORDS.add("transient"); + JAVA_KEYWORDS.add("try"); + // JAVA_KEYWORDS.add("void"); + JAVA_KEYWORDS.add("volatile"); + JAVA_KEYWORDS.add("while"); + + JAVA_TS_KEYWORDS.add("boolean"); + JAVA_TS_KEYWORDS.add("class"); + JAVA_TS_KEYWORDS.add("enum"); + JAVA_TS_KEYWORDS.add("implements"); + JAVA_TS_KEYWORDS.add("interface"); + JAVA_TS_KEYWORDS.add("void"); + + JS_KEYWORDS.add("function"); + JS_KEYWORDS.add("var"); + JS_KEYWORDS.add("typeof"); + } + + /** + * This function return a Javascript-friendly identifier from a + * Java-formatted one. + * + * @param identifier + * the Java-formatted identifier + * @return the Javascript-friendly identifier + */ + public static String toJsIdentifier(String identifier) { + if (!identifier.isEmpty() && Character.isUpperCase(identifier.charAt(0)) + && JSweetDefTranslatorConfig.JAVA_KEYWORDS.contains(identifier.toLowerCase())) { + return identifier.toLowerCase(); + } + // TODO: translate $$ + // if (Character.isDigit(identifier.charAt(0))) { + // return "$$" + identifier.charAt(0) + "$$" + identifier.substring(1); + // } + return identifier; + } + + public static boolean isJDKReplacementMode() { + return "java.lang".equals(LANG_PACKAGE); + } + + /** + * Gets the JSweet object's fully qualified name. + */ + public static String getObjectClassName() { + return LANG_PACKAGE + ".Object"; + } + + /** + * Tells if this qualified name belongs to the JDK (starts with + * {@value #JAVA_PACKAGE}). + */ + public static boolean isJDKPath(String qualifiedName) { + return qualifiedName.startsWith(JAVA_PACKAGE + "."); + } + + /** + * Tells if this qualified name belongs to any TypeScript library definition + * (starts with {@value #LIBS_PACKAGE}). + */ + public static boolean isLibPath(String qualifiedName) { + return qualifiedName.startsWith(LIBS_PACKAGE + "."); + } + + /** + * Tells if this qualified name belongs to one of the JSweet core package + * (starts with {@value #ROOT_PACKAGE}). + */ + public static boolean isJSweetPath(String qualifiedName) { + return qualifiedName.startsWith(ROOT_PACKAGE + "."); + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/TypescriptDef2Java.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/TypescriptDef2Java.java new file mode 100644 index 00000000..aec49752 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/TypescriptDef2Java.java @@ -0,0 +1,457 @@ +package org.jsweet.input.typescriptdef; + +import static java.util.Arrays.asList; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.BiConsumer; +import java.util.function.Predicate; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.commons.io.FileUtils; +import org.apache.log4j.Logger; +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.ast.CompilationUnit; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.parser.TypescriptDefParser; +import org.jsweet.input.typescriptdef.util.Util; +import org.jsweet.input.typescriptdef.visitor.ConstructorInterfacesMerger; +import org.jsweet.input.typescriptdef.visitor.ConstructorTypeReferenceReplacer; +import org.jsweet.input.typescriptdef.visitor.DeclarationBinder; +import org.jsweet.input.typescriptdef.visitor.DocFiller; +import org.jsweet.input.typescriptdef.visitor.DuplicateMethodsCleaner; +import org.jsweet.input.typescriptdef.visitor.DynamicTypeParametersExpander; +import org.jsweet.input.typescriptdef.visitor.EmptyConstructorAdder; +import org.jsweet.input.typescriptdef.visitor.EmptyModulesCleaner; +import org.jsweet.input.typescriptdef.visitor.FactoryMethodsCreator; +import org.jsweet.input.typescriptdef.visitor.FieldTypeFunctionInjector; +import org.jsweet.input.typescriptdef.visitor.ForEachClashRemover; +import org.jsweet.input.typescriptdef.visitor.FunctionKindAdapter; +import org.jsweet.input.typescriptdef.visitor.FunctionTypeOfReplacer; +import org.jsweet.input.typescriptdef.visitor.FunctionalInterfacesCreator; +import org.jsweet.input.typescriptdef.visitor.GlobalsCreator; +import org.jsweet.input.typescriptdef.visitor.ImportedAndExportedReferenceExpander; +import org.jsweet.input.typescriptdef.visitor.IterableInjector; +import org.jsweet.input.typescriptdef.visitor.JavaDefModelPrinter; +import org.jsweet.input.typescriptdef.visitor.ModuleToTypeMerger; +import org.jsweet.input.typescriptdef.visitor.NameAdapter; +import org.jsweet.input.typescriptdef.visitor.NameChecker; +import org.jsweet.input.typescriptdef.visitor.ObjectTypeCreator; +import org.jsweet.input.typescriptdef.visitor.ObjectTypeDuplicateMerger; +import org.jsweet.input.typescriptdef.visitor.OptionalParametersExpander; +import org.jsweet.input.typescriptdef.visitor.OptionalParametersInFunctionalTypesExpander; +import org.jsweet.input.typescriptdef.visitor.PackageOrganizer; +import org.jsweet.input.typescriptdef.visitor.ParentMethodReturnTypeSusbtitutor; +import org.jsweet.input.typescriptdef.visitor.SerializableHandler; +import org.jsweet.input.typescriptdef.visitor.StringTypeCreator; +import org.jsweet.input.typescriptdef.visitor.SuperTypesMerger; +import org.jsweet.input.typescriptdef.visitor.TupleTypeCreator; +import org.jsweet.input.typescriptdef.visitor.TypeKindChooser; +import org.jsweet.input.typescriptdef.visitor.TypeMacroReplacer; +import org.jsweet.input.typescriptdef.visitor.TypeMerger; +import org.jsweet.input.typescriptdef.visitor.TypeParametersSubstitutor; +import org.jsweet.input.typescriptdef.visitor.TypeReferenceChecker; +import org.jsweet.input.typescriptdef.visitor.TypeReferenceExpander; +import org.jsweet.input.typescriptdef.visitor.UnionInterfacesCreator; +import org.jsweet.input.typescriptdef.visitor.UnionTypesEraser; +import org.jsweet.input.typescriptdef.visitor.UnionTypesExpander; + +public class TypescriptDef2Java { + + private final static Logger logger = Logger.getLogger(TypescriptDef2Java.class); + + public static final String TS_CORE_LIB_DIR = "lib.core"; + public static final String TS_DOM_LIB_DIR = "lib.dom"; + public static boolean generateMissingTypes = false; + + private static void addTsDefFiles(File input, ArrayList files, Predicate libFilter) { + if (input.isDirectory()) { + File[] subFiles = input.listFiles(); + if (subFiles != null) { + for (File file : subFiles) { + addTsDefFiles(file, files, libFilter); + } + } + } else { + if (input.getName().endsWith(".d.ts") && !input.getPath().contains("legacy") && libFilter.test(input)) { + files.add(input); + } + } + + } + + private static void scan(CompilationUnit compilationUnit, Scanner scanner) { + try { + scanner.scan(compilationUnit); + } catch (Exception e) { + scanner.printStackTrace(System.err); + logger.error(e.getMessage(), e); + } + } + + private static void scan(List compilationUnits, Scanner... scanners) { + scan(null, compilationUnits, scanners); + } + + private static void scan(BiConsumer onScannedCallback, + List compilationUnits, Scanner... scanners) { + for (Scanner scanner : scanners) { + scanner.onScanStart(); + } + for (CompilationUnit compilationUnit : compilationUnits) { + for (Scanner scanner : scanners) { + scan(compilationUnit, scanner); + if (onScannedCallback != null) { + onScannedCallback.accept(compilationUnit, scanner); + } + } + } + for (Scanner scanner : scanners) { + scanner.onScanEnded(); + } + } + + public static void main(String[] args) throws Throwable { + translate( // + asList(new File("typings/globals/jquery/index.d.ts")), // + asList(new File("typings/lib.core/lib.core.d.ts"), new File("typings/lib.core/lib.core.ext.d.ts"), + new File("typings/lib.core/lib.dom.d.ts")), // + new File("OUT"), // + null, // + false); + } + + private static Pattern refPattern = Pattern.compile("^///\\p{Blank}*<.*$"); + + private static void grabReferences(CompilationUnit cu) throws IOException { + for (String s : FileUtils.readLines(cu.getFile())) { + Matcher m = refPattern.matcher(s); + if (m.matches()) { + cu.addReference(s); + } + } + } + + @SuppressWarnings("serial") + private static final Map IGNORED_REFERENCES = new HashMap() { + { + put("cordova/cordova.d.ts", new String[] { "plugins/.*" }); + } + }; + + private static void parse(Context context, File f) throws IOException { + // context.compilationUnits.stream().map((cu) -> { return + // cu.getFile();}). + if (context.compilationUnits.contains(new CompilationUnit(f))) { + // logger.info("skipping: " + f); + return; + } + logger.info("parsing: " + f); + TypescriptDefParser parser = TypescriptDefParser.parseFile(f); + context.compilationUnits.add(parser.compilationUnit); + grabReferences(parser.compilationUnit); + for (String reference : parser.compilationUnit.getReferences()) { + String path = Util.getLibPathFromReference(reference); + if (path != null) { + File dep = new File(f.getParent(), path); + if (!dep.exists()) { + context.reportError("dependency '" + dep + "' does not exist"); + } else { + File tsDefFile = parser.compilationUnit.getFile(); + boolean ignored = isIgnoredReference(tsDefFile, path); + if (dep.getPath().contains("..")) { + try { + Path currentPath = new File("").getAbsoluteFile().toPath(); + Path depPath = dep.getCanonicalFile().toPath(); + logger.debug("depPath: " + depPath); + Path relPath = currentPath.relativize(depPath); + if (!relPath.toString().contains("..")) { + dep = relPath.toFile(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + logger.info("handling dependency: " + dep); + if (ignored) { + context.getDependenciesDefinitions().add(dep); + } else { + parse(context, dep); + } + } + } + } + } + + private static boolean isIgnoredReference(File tsDefFile, String path) { + + for (Map.Entry ignoredReferenceEntry : IGNORED_REFERENCES.entrySet()) { + + if (tsDefFile.getPath().endsWith(ignoredReferenceEntry.getKey())) { + + String[] ignoredPaths = ignoredReferenceEntry.getValue(); + for (String ignoredPathRegex : ignoredPaths) { + if (Pattern.matches(ignoredPathRegex, path)) { + return true; + } + } + } + } + + return false; + } + + public static Context translate( // + File inputDir, // + File outputDir, // + String cacheDirPath, // + boolean fetchJavadoc, // + Predicate libFilter, // + Predicate dependenciesFilter) throws Throwable { + + logger.info("typings directory: " + inputDir); + logger.info("output directory: " + outputDir); + + ArrayList tsDefFiles = new ArrayList(); + addTsDefFiles(inputDir, tsDefFiles, libFilter); + + ArrayList tsDefDependencies = new ArrayList(); + addTsDefFiles(inputDir, tsDefDependencies, dependenciesFilter); + + File cacheDir = null; + if (cacheDirPath != null) { + cacheDir = new File(cacheDirPath); + } + + return translate(tsDefFiles, tsDefDependencies, outputDir, cacheDir, fetchJavadoc); + } + + public static Context translate( // + List tsDefFiles, // + List tsDefDependencies, // + File outputDir, // + File cacheDir, // + boolean fetchJavadoc) throws Throwable { + + // comp.compile(fileObjects); + logger.info("input files: " + tsDefFiles); + logger.info("dependencies: " + tsDefDependencies); + logger.info("output directory: " + outputDir); + + outputDir.mkdirs(); + + Context context = new Context(tsDefFiles, tsDefDependencies, fetchJavadoc); + context.verbose = false; + context.cacheDir = cacheDir; + + logger.info("all definitions: " + context.getAllDefinitions()); + + for (File f : context.getAllDefinitions()) { + parse(context, f); + } + + translateAst(context); + + printAst(outputDir, context); + + // copies core built-in srcs + // if (context.getLibrariesDefinitions() + // .contains(new File(JSweetDefTranslatorConfig.TS_LIBS_DIR_NAME + + // "/lib.core/lib.core.d.ts"))) { + // logger.info("copying built-in core '" + getBuiltInDir() + "' -> '" + + // outputDir); + // FileUtils.copyDirectory(new File(getBuiltInDir()), outputDir, new + // FileFilter() { + // + // @Override + // public boolean accept(File file) { + // return !file.getName().startsWith("."); + // } + // }); + // } + + // copies core packages' package-info if necessary + // File jsweetRootPackageDir = new File(outputDir, "jsweet"); + // if (jsweetRootPackageDir.isDirectory()) { + // for (File jsweetSubSourceDir : jsweetRootPackageDir.listFiles()) { + // File packageInfo = new File(BUILT_IN_DIR, + // "jsweet/" + jsweetSubSourceDir.getName() + "/package-info.java"); + // logger.info("copying package-info for '" + jsweetSubSourceDir + "' + // from " + packageInfo); + // FileUtils.copyFileToDirectory(packageInfo, jsweetSubSourceDir); + // } + // } + + // ===== + File tsdefDir = new File(outputDir, JSweetDefTranslatorConfig.TS_LIBS_DIR_NAME); + logger.info("copying tsdef: '" + context.getAllDefinitions() + "' -> '" + tsdefDir); + tsdefDir.mkdirs(); + + for (File tsDefFile : context.getAllDefinitions()) { + + File destDir = new File( // + tsdefDir, // + tsDefFile.getParentFile().getName() + "_" + tsDefFile.getName()); + FileUtils.copyFileToDirectory(tsDefFile, destDir); + File extFile = new File(tsDefFile.getParentFile(), tsDefFile.getName().replace(".d.ts", ".ext.d.ts")); + if (extFile.isFile() && extFile.canRead()) { + FileUtils.copyFileToDirectory(tsDefFile, destDir); + logger.info("ext file '" + extFile + "' copied as well"); + } + } + + mergeExtFiles(tsdefDir); + // createLibFile(tsdefDir); + // mergeDomToCore(tsdefDir); + + return context; + } + + public static void printAst(File outputDir, Context context) { + outputDir.mkdirs(); + try { + FileUtils.cleanDirectory(outputDir); + } catch (IOException e) { + logger.error("did not clean output directory: " + outputDir, e); + } + scan((cu, scanner) -> { + logger.info("translated " + cu); + }, context.compilationUnits, new JavaDefModelPrinter(context, outputDir)); + } + + public static void translateAst(Context context) { + + // List> l = + // context.findDeclarations(TypeDeclaration.class, "*.HTMLAttributes"); + // System.out.println(); + + scan(context.compilationUnits, new NameChecker(context)); + + scan(context.compilationUnits, new FunctionTypeOfReplacer(context)); + + scan(context.compilationUnits, new ImportedAndExportedReferenceExpander(context, false)); + scan(context.compilationUnits, new ImportedAndExportedReferenceExpander(context, true)); + + scan(context.compilationUnits, new EmptyModulesCleaner(context)); + + // assign module names + scan(context.compilationUnits, new PackageOrganizer(context), new TypeKindChooser(context), + new DeclarationBinder(context)); + + context.checkConsistency(); + + logger.info("dumping initial state"); + context.dump(logger); + + try { + Util.createDependencyGraph(context); + logger.info("dependency graph: " + context.dependencyGraph); + } catch (IOException e) { + logger.error("error when contructing dependency graph", e); + } + + // scan(context.compilationUnits, new GlobalsCreator(context)); + + scan(context.compilationUnits, new ModuleToTypeMerger(context)); + scan(context.compilationUnits, new ObjectTypeCreator(context), new ObjectTypeDuplicateMerger(context)); + scan(context.compilationUnits, new ConstructorInterfacesMerger(context)); + scan(context.compilationUnits, new TypeMerger(context)); + + scan(context.compilationUnits, new SuperTypesMerger(context)); + // does not work (prototype clashing) + // scan(context.compilationUnits, new + // FunctionalParametersExpander(context)); + scan(context.compilationUnits, new TypeReferenceExpander(context)); + + context.calculateArrayTypes(); + + scan(context.compilationUnits, new TypeMacroReplacer(context)); + + scan(context.compilationUnits, new UnionTypesEraser(context)); + + // scan(context.compilationUnits, new TypeReferenceChecker(context)); + + scan(context.compilationUnits, new OptionalParametersExpander(context), + new OptionalParametersInFunctionalTypesExpander(context), new UnionTypesExpander(context), + new StringTypeCreator(context), new FunctionalInterfacesCreator(context), + new TypeParametersSubstitutor(context), new DynamicTypeParametersExpander(context), + new TupleTypeCreator(context)); + + // optional parameters must have been fully expanded in super classes + scan(context.compilationUnits, new ParentMethodReturnTypeSusbtitutor(context)); + + scan(context.compilationUnits, new GlobalsCreator(context), new FieldTypeFunctionInjector(context)); + + // binds declarations again to grab newly created inner types + scan(context.compilationUnits, new DeclarationBinder(context)); + + scan(context.compilationUnits, new FactoryMethodsCreator(context)); + + // run type expansion again for partial names that would reference an + // import + scan(context.compilationUnits, new TypeReferenceExpander(context)); + + // context.dump(System.out); + scan(context.compilationUnits, new NameAdapter(context), new DeclarationBinder(context)); + // TODO : this should be the last and it should ignore java.util.* and + // so on + scan(context.compilationUnits, new TypeReferenceChecker(context)); + + scan(context.compilationUnits, new IterableInjector(context)); + + scan(context.compilationUnits, new FunctionKindAdapter(context)); + + scan(context.compilationUnits, new UnionInterfacesCreator(context)); + + scan(context.compilationUnits, new EmptyConstructorAdder(context), new SerializableHandler(context)); + + scan(context.compilationUnits, new ConstructorTypeReferenceReplacer(context)); + + scan(context.compilationUnits, new DuplicateMethodsCleaner(context)); + + scan(context.compilationUnits, new ForEachClashRemover(context)); + + if (context.fetchJavadoc) { + scan(context.compilationUnits, new DocFiller(context)); + } + + // l = context.findDeclarations(TypeDeclaration.class, + // "*.HTMLAttributes"); + // System.out.println(); + + context.checkConsistency(); + + logger.info("dumping final state"); + context.dump(logger); + + } + + private static void mergeExtFiles(File dir) { + for (File f : dir.listFiles()) { + if (f.isDirectory()) { + mergeExtFiles(f); + } else { + if (f.getName().endsWith(".ext.d.ts")) { + logger.info("merging ext file: " + f); + File target = new File(dir, f.getName().replace(".ext.d.ts", ".d.ts")); + if (target.exists()) { + try { + FileUtils.writeByteArrayToFile(target, FileUtils.readFileToByteArray(f), true); + FileUtils.deleteQuietly(f); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + } + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/AbstractAstNode.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/AbstractAstNode.java new file mode 100644 index 00000000..96210515 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/AbstractAstNode.java @@ -0,0 +1,46 @@ +package org.jsweet.input.typescriptdef.ast; + +public abstract class AbstractAstNode implements AstNode { + + private Token token; + public int nodeTypeId = -1; + private boolean hidden = false; + + public AbstractAstNode(Token token) { + super(); + // if(token==null) { + // throw new RuntimeException("token cannot be null"); + // } + this.token = token; + } + + @Override + public Token getToken() { + return token; + } + + @Override + public String getLocation() { + if (token != null) { + return token.getLocation(); + } else { + return ""; + } + } + + @Override + public String toString() { + return token == null ? "null" : token.toString(); + } + + @Override + public boolean isHidden() { + return hidden; + } + + @Override + public void setHidden(boolean hidden) { + this.hidden = hidden; + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/AbstractDeclaration.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/AbstractDeclaration.java new file mode 100644 index 00000000..b579c238 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/AbstractDeclaration.java @@ -0,0 +1,302 @@ +package org.jsweet.input.typescriptdef.ast; + +import java.lang.annotation.Annotation; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.lang3.ArrayUtils; + +public abstract class AbstractDeclaration extends AbstractAstNode implements Declaration { + protected String name; + protected String originalName; + protected String documentation; + private Set modifiers; + private Map, Annotation[]> annotationMap; + private List stringAnnotations; + protected boolean quotedName = false; + + public AbstractDeclaration(Token token, String name) { + super(token); + setName(name); + } + + @Override + public Set getModifiers() { + return modifiers; + } + + @Override + public void setModifiers(Set modifiers) { + this.modifiers = modifiers; + } + + @Override + public String toString() { + return name; + } + + @Override + public String getName() { + return name; + } + + @Override + public void setName(String name) { + if (name != null && (name.contains("\"") || name.contains("'"))) { + this.name = name.replace("\"", "").replace("'", ""); + setQuotedName(true); + } else { + this.name = name; + } + } + + @Override + public String getDocumentation() { + return documentation; + } + + @Override + public void setDocumentation(String documentation) { + this.documentation = documentation; + } + + @Override + public void addModifier(String modifier) { + if (modifiers == null) { + modifiers = new HashSet(); + } + if (modifier.contains(" ")) { + for (String s : modifier.split(" ")) { + modifiers.add(s); + } + } else { + modifiers.add(modifier); + } + } + + @Override + public void removeModifier(String modifier) { + if (modifiers != null) { + modifiers.remove(modifier); + } + } + + @Override + public boolean hasModifier(String modifier) { + if (modifiers != null) { + return modifiers.contains(modifier); + } + return false; + } + + @Override + public boolean isAnonymous() { + return name == null; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null) { + return false; + } + if (!o.getClass().equals(getClass())) { + return false; + } + Declaration d = (Declaration) o; + if (d.getName() == null && getName() != null) { + return false; + } + if (!d.getName().equals(getName())) { + return false; + } + return true; + } + + @Override + public boolean isInputAnnotatedWith(String annotation) { + return getDocumentation() != null && getDocumentation().contains("@" + annotation); + } + + @Override + public void addStringAnnotation(String annotation) { + if (stringAnnotations == null) { + stringAnnotations = new ArrayList(); + } + stringAnnotations.add(annotation); + } + + @Override + public void removeStringAnnotation(String annotation) { + if (stringAnnotations == null) { + return; + } + for (String a : new ArrayList<>(stringAnnotations)) { + if (a.startsWith(annotation)) { + stringAnnotations.remove(a); + } + } + } + + @Override + public List getStringAnnotations() { + return stringAnnotations; + } + + @Override + public boolean hasStringAnnotation(String annotation) { + if (stringAnnotations == null) { + return false; + } + for (String a : stringAnnotations) { + if (a.startsWith(annotation)) { + return true; + } + } + return false; + } + + @Override + public String getStringAnnotation(String annotation) { + if (stringAnnotations == null) { + return null; + } + for (String a : stringAnnotations) { + if (a.startsWith(annotation)) { + return a; + } + } + return null; + } + + @Override + public void addAnnotation(Annotation annotation) { + if (annotationMap == null) { + annotationMap = new HashMap, Annotation[]>(); + } + Class annotationClass = annotation.annotationType(); + Annotation[] annotations = annotationMap.get(annotationClass); + if (annotations == null) { + annotations = new Annotation[0]; + } + annotations = ArrayUtils.add(annotations, annotation); + annotationMap.put(annotationClass, annotations); + } + + @Override + public T getAnnotation(Class annotationClass) { + if (annotationMap == null) { + return null; + } + Annotation[] annotations = annotationMap.get(annotationClass); + if (annotations != null && annotations.length > 0) { + @SuppressWarnings("unchecked") + T annotation = (T) annotations[0]; + return annotation; + } else { + return null; + } + } + + @Override + public T removeAnnotation(Class annotationClass) { + if (annotationMap == null) { + return null; + } + Annotation[] annotations = annotationMap.get(annotationClass); + if (annotations != null && annotations.length > 0) { + @SuppressWarnings("unchecked") + T annotation = (T) annotations[0]; + + annotations = ArrayUtils.removeElement(annotations, annotation); + annotationMap.put(annotationClass, annotations); + + return annotation; + } else { + return null; + } + } + + @Override + public Annotation[] getAnnotations() { + if (annotationMap == null) { + return new Annotation[0]; + } + List l = new ArrayList(); + for (Annotation[] annotations : annotationMap.values()) { + l.addAll(Arrays.asList(annotations)); + } + return l.toArray(new Annotation[0]); + } + + @Override + public Annotation[] getDeclaredAnnotations() { + return getAnnotations(); + } + + @Override + public boolean isAnnotationPresent(Class annotationClass) { + if (annotationMap == null) { + return false; + } + return annotationMap.containsKey(annotationClass); + } + + @Override + public T[] getAnnotationsByType(Class annotationClass) { + if (annotationMap == null || !annotationMap.containsKey(annotationClass)) { + @SuppressWarnings("unchecked") + T[] r = (T[]) new Annotation[0]; + return r; + } + @SuppressWarnings("unchecked") + T[] r = (T[]) annotationMap.get(annotationClass); + return r; + } + + @Override + public T getDeclaredAnnotation(Class annotationClass) { + return getAnnotation(annotationClass); + } + + @Override + public T[] getDeclaredAnnotationsByType(Class annotationClass) { + return getAnnotationsByType(annotationClass); + } + + @Override + public void setStringAnnotations(List stringAnnotations) { + this.stringAnnotations = stringAnnotations; + } + + @Override + public boolean isQuotedName() { + return quotedName; + } + + @Override + public void setQuotedName(boolean quotedName) { + this.quotedName = quotedName; + } + + @Override + public String getOriginalName() { + if (originalName == null) { + return name; + } + return originalName; + } + + @Override + public void setOriginalName(String originalName) { + this.originalName = originalName; + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/AbstractPrinter.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/AbstractPrinter.java new file mode 100644 index 00000000..33b31c96 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/AbstractPrinter.java @@ -0,0 +1,127 @@ +package org.jsweet.input.typescriptdef.ast; + +import static org.apache.commons.lang3.StringUtils.isBlank; + +import java.lang.annotation.Annotation; + +import org.jsweet.input.typescriptdef.util.Util; + +public abstract class AbstractPrinter extends Scanner { + + private static final String INDENT = " "; + + private StringBuilder out = new StringBuilder(); + + private int indent = 0; + + private int currentLine = 1; + + private int currentColumn = 0; + + public AbstractPrinter(Context context) { + super(context); + } + + protected void clearOutput() { + out = new StringBuilder(); + } + + public AbstractPrinter print(Visitable element) { + scan(element); + return this; + } + + protected String getIndent() { + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < indent; i++) { + sb.append(INDENT); + } + return sb.toString(); + } + + public AbstractPrinter printIndent() { + return print(getIndent()); + } + + public AbstractPrinter startIndent() { + indent++; + return this; + } + + public AbstractPrinter endIndent() { + indent--; + return this; + } + + public AbstractPrinter print(CharSequence string) { + out.append(string); + currentColumn += string.length(); + return this; + } + + public AbstractPrinter space() { + return print(" "); + } + + public AbstractPrinter removeLastChar() { + out.deleteCharAt(out.length() - 1); + currentColumn--; + return this; + } + + public AbstractPrinter removeLastChars(int count) { + if (count > 0) { + out.delete(out.length() - count, out.length()); + } + currentColumn -= count; + return this; + } + + public AbstractPrinter removeLastIndent() { + removeLastChars(INDENT.length()); + return this; + } + + public AbstractPrinter println() { + out.append("\n"); + currentLine++; + currentColumn = 0; + return this; + } + + public String getResult() { + return out.toString(); + } + + public int getCurrentLine() { + return currentLine; + } + + public int getCurrentColumn() { + return currentColumn; + } + + public AbstractPrinter printAnnotations(Declaration declaration) { + CharSequence annos = annotationsToString(declaration); + if (!isBlank(annos)) { + print(annos); + } + return this; + } + + public CharSequence annotationsToString(Declaration declaration) { + StringBuilder annosDecls = new StringBuilder(); + for (Annotation annotation : declaration.getAnnotations()) { + annosDecls.append(getIndent()); + annosDecls.append(Util.toString(annotation) + "\n"); + } + if (declaration.getStringAnnotations() != null) { + for (String annotation : declaration.getStringAnnotations()) { + annosDecls.append(getIndent()); + annosDecls.append("@" + annotation + "\n"); + } + } + + return annosDecls; + } +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/AbstractTypedDeclaration.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/AbstractTypedDeclaration.java new file mode 100644 index 00000000..effb7fde --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/AbstractTypedDeclaration.java @@ -0,0 +1,29 @@ +package org.jsweet.input.typescriptdef.ast; + +public abstract class AbstractTypedDeclaration extends AbstractDeclaration implements TypedDeclaration { + + private TypeReference type; + + public AbstractTypedDeclaration(Token token, String name, TypeReference type) { + super(token, name); + if (type == null) { + this.type = new TypeReference(null, "any", null); + } else { + this.type = type; + } + } + + @Override + public String toString() { + return super.toString() + ":" + type; + } + + public TypeReference getType() { + return type; + } + + public void setType(TypeReference type) { + this.type = type; + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/ArrayTypeReference.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/ArrayTypeReference.java new file mode 100644 index 00000000..1204a04a --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/ArrayTypeReference.java @@ -0,0 +1,87 @@ +package org.jsweet.input.typescriptdef.ast; + +public class ArrayTypeReference extends TypeReference { + + TypeReference componentType; + boolean disableArray = false; + + public ArrayTypeReference(Token token, TypeReference componentType) { + super(token, (String) null, null); + this.componentType = componentType; + } + + @Override + public String toString() { + if (componentType == null) { + return "any[]"; + } + return componentType.toString() + "[]"; + } + + @Override + public void accept(Visitor visitor) { + visitor.visitArrayTypeReference(this); + } + + public TypeReference getComponentType() { + return componentType; + } + + public void setComponentType(TypeReference componentType) { + this.componentType = componentType; + } + + @Override + public boolean equals(Object obj) { + if (!obj.getClass().equals(getClass())) { + return false; + } + ArrayTypeReference tr = (ArrayTypeReference) obj; + return tr.getComponentType().equals(getComponentType()); + } + + public boolean isDisableArray() { + return disableArray; + } + + public void setDisableArray(boolean disableArray) { + this.disableArray = disableArray; + } + + @Override + public ArrayTypeReference copy(boolean copyDeclarations) { + ArrayTypeReference copy = new ArrayTypeReference(null, + getComponentType() == null ? null : getComponentType().copy(copyDeclarations)); + copy.disableArray = disableArray; + return copy; + } + + @Override + public ArrayTypeReference copy() { + return copy(false); + } + + @Override + public boolean isArray() { + return true && !disableArray; + } + + @Override + public boolean isSubtypeOf(TypeReference type) { + if (type.isArray()) { + return componentType.isSubtypeOf(type.getComponentType()); + } else { + return false; + } + } + + @Override + public boolean substituteTypeReference(TypeReference targetType, TypeReference newType) { + if (componentType == targetType) { + componentType = newType; + return true; + } + return false; + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/AstNode.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/AstNode.java new file mode 100644 index 00000000..0c417b75 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/AstNode.java @@ -0,0 +1,23 @@ +package org.jsweet.input.typescriptdef.ast; + +public interface AstNode extends Visitable { + + static String toString2() { + return null; + } + + /** + * Returns the corresponding parser token. + */ + Token getToken(); + + /** + * Returns the location in the parsed file. + */ + String getLocation(); + + // String toString(); + + boolean equals(Object object); + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/CompilationUnit.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/CompilationUnit.java new file mode 100644 index 00000000..6ef401b0 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/CompilationUnit.java @@ -0,0 +1,195 @@ +package org.jsweet.input.typescriptdef.ast; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import org.jsweet.JSweetDefTranslatorConfig; + +public class CompilationUnit implements Visitable, DeclarationContainer { + + protected List references = new ArrayList(); + + protected File file; + + protected Declaration[] declarations; + + private boolean hidden = false; + + private ModuleDeclaration mainModule; + + private boolean external = false; + + public CompilationUnit(File file) { + super(); + this.file = file; + } + + public File getFile() { + return file; + } + + public void setFile(File file) { + this.file = file; + } + + public Declaration[] getDeclarations() { + return declarations; + } + + public void setDeclarations(Declaration[] declarations) { + this.declarations = declarations; + } + + @Override + public void accept(Visitor visitor) { + visitor.visitCompilationUnit(this); + } + + @Override + public String toString() { + return file.toString(); + } + + @Override + public Declaration[] getMembers() { + return getDeclarations(); + } + + @Override + public void addMember(Declaration declaration) { + declarations = DeclarationHelper.addMember(this, declaration); + } + + @Override + public void removeMember(Declaration declaration) { + declarations = DeclarationHelper.removeMember(this, declaration); + } + + @Override + public void replaceMember(Declaration existingDeclaration, Declaration withNewDeclaration) { + declarations = DeclarationHelper.replaceMember(this, existingDeclaration, withNewDeclaration); + } + + @Override + public void clearMembers() { + declarations = new Declaration[0]; + } + + @Override + public boolean isHidden() { + return hidden; + } + + @Override + public void setHidden(boolean hidden) { + this.hidden = hidden; + } + + @Override + public FunctionDeclaration findFirstFunction(String name) { + return DeclarationHelper.findFirstFunction(this, name); + } + + @Override + public List findFunctions(String name) { + return DeclarationHelper.findFunctions(this, name); + } + + @Override + public VariableDeclaration findVariable(String name) { + return DeclarationHelper.findVariable(this, name); + } + + @Override + public VariableDeclaration findVariableIgnoreCase(String name) { + return DeclarationHelper.findVariableIgnoreCase(this, name); + } + + @Override + public TypeDeclaration findType(String name) { + TypeDeclaration typeDecl = DeclarationHelper.findType(this, name); + if (typeDecl == null) { + typeDecl = getMainModule().findType(name); + } + + return typeDecl; + } + + @Override + public TypeDeclaration findTypeIgnoreCase(String name) { + TypeDeclaration typeDecl = DeclarationHelper.findTypeIgnoreCase(this, name); + if (typeDecl == null) { + typeDecl = getMainModule().findTypeIgnoreCase(name); + } + + return typeDecl; + } + + @Override + public Declaration findDeclaration(String name) { + Declaration declaration = DeclarationHelper.findDeclaration(this, name); + if (declaration == null) { + ModuleDeclaration mainModule = getMainModule(); + if (mainModule != null) { + declaration = mainModule.findDeclaration(name); + } + } + + return declaration; + } + + public ModuleDeclaration getMainModule() { + if (mainModule == null) { + for (Declaration decl : declarations) { + if (decl instanceof ModuleDeclaration && (JSweetDefTranslatorConfig.isLibPath(decl.getName()) + || JSweetDefTranslatorConfig.isJSweetPath(decl.getName()))) { + mainModule = (ModuleDeclaration) decl; + break; + } + } + } + return mainModule; + } + + @Override + public void addMembers(Declaration[] declarations) { + DeclarationHelper.addMembers(this, declarations); + } + + @Override + public Declaration findDeclaration(Declaration declaration) { + return DeclarationHelper.findDeclaration(this, declaration); + } + + public void addReference(String reference) { + references.add(reference.replace('\r', ' ').replace('\n', ' ').trim()); + } + + public List getReferences() { + return references; + } + + @Override + public int hashCode() { + return file.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof CompilationUnit)) { + return false; + } else { + return file.equals(((CompilationUnit) obj).file); + } + } + + public boolean isExternal() { + return external; + } + + public void setExternal(boolean external) { + this.external = external; + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Context.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Context.java new file mode 100644 index 00000000..4c310bfc --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Context.java @@ -0,0 +1,615 @@ +package org.jsweet.input.typescriptdef.ast; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.regex.Pattern; + +import org.apache.log4j.Logger; +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.util.DeclarationFinder; +import org.jsweet.input.typescriptdef.util.DirectedGraph; + +public class Context { + + private final static Logger logger = Logger.getLogger(Context.class); + + private List dependenciesDefinitions; + private List librariesDefinitions; + + // contructor type -> target type + public Map mergedContructors = new HashMap(); + + public Context(List libraries, List dependencies, boolean fetchJavadoc) { + this.librariesDefinitions = libraries; + this.dependenciesDefinitions = dependencies; + this.fetchJavadoc = fetchJavadoc; + initCoreTypes(); + } + + public boolean verbose; + + public File cacheDir = new File("cache"); + + public List compilationUnits = new ArrayList(); + + public DirectedGraph dependencyGraph; + + public List libModules = new ArrayList(); + + public Map libModulesCompilationUnits = new HashMap<>(); + + /** + * Lib module names -> Mixin declaration. + */ + public Map> mixins = new HashMap<>(); + + public Map moduleDocumentations = new HashMap<>(); + + private Map types = new HashMap(); + + private Set clashingWithModulesTypes = new HashSet(); + + private Map typeNames = new HashMap(); + + private Map moduleNames = new HashMap(); + + public Map> generatedObjectTypes = new HashMap<>(); + + /** + * Holds the (fully qualified module names -> original name) that are + * external (can be imported with require). + */ + public Map externalModules = new HashMap<>(); + + public List arrayTypes = new ArrayList(); + + public Map overrides = new HashMap(); + public Map overridens = new HashMap(); + public List> duplicates = new ArrayList>(); + + private List errors = new ArrayList<>(); + private List warnings = new ArrayList<>(); + + public final boolean fetchJavadoc; + + public void reportError(String errorMessage) { + errors.add(errorMessage); + logger.error(errorMessage, new Exception()); + } + + public void reportError(String errorMessage, Throwable cause) { + errors.add(errorMessage); + logger.error(errorMessage, cause); + } + + public void reportWarning(String errorMessage) { + warnings.add(errorMessage); + logger.warn(errorMessage); + } + + public int getErrorCount() { + return errors.size(); + } + + public int getWarningCount() { + return warnings.size(); + } + + public List getErrors() { + return errors; + } + + public List getWarnings() { + return warnings; + } + + public void registerType(String name, TypeDeclaration declaration) { + typeNames.put(declaration, name); + // first type wins (duplicate declarations will merge to the first + // one, see TypeMerger) + if (!types.containsKey(name)) { + types.put(name, declaration); + } + } + + public void unregisterType(TypeDeclaration declaration) { + String typeName = getTypeName(declaration); + if (declaration == types.get(typeName)) { + types.remove(typeName); + } + typeNames.remove(declaration); + } + + public List getTranslatedCompilationUnits() { + List compUnits = new LinkedList<>(); + for (CompilationUnit candidate : compilationUnits) { + if (!isDependency(candidate)) { + compUnits.add(candidate); + } + } + + return compUnits; + } + + public TypeDeclaration getTypeDeclaration(String name) { + return types.get(name); + } + + public boolean setTypeClashingWithModule(String typeName) { + return clashingWithModulesTypes.add(typeName); + } + + public boolean isTypeClashingWithModule(String typeName) { + return clashingWithModulesTypes.contains(typeName); + } + + public String getTypeName(TypeDeclaration typeDeclaration) { + return typeNames.get(typeDeclaration); + } + + public String getModuleName(ModuleDeclaration moduleDeclaration) { + return moduleNames.get(moduleDeclaration); + } + + public String getTypeModule(TypeDeclaration typeDeclaration) { + String name = typeNames.get(typeDeclaration); + if (name == null) { + return null; + } + int i = name.lastIndexOf('.'); + return i > 0 ? name.substring(0, i) : null; + } + + /** + * Checks that all modules and types are registered in the context + */ + public void checkConsistency() { + logger.info("context consistency check"); + for (QualifiedDeclaration m : findDeclarations(ModuleDeclaration.class, "*")) { + if (getModuleName(m.getDeclaration()) == null) { + reportError("unregistered module: " + m); + } + } + for (QualifiedDeclaration t : findDeclarations(TypeDeclaration.class, "*")) { + if (!t.getDeclaration().isAnonymous() && getTypeName(t.getDeclaration()) == null) { + reportError("unregistered type: " + t + " at " + t.getDeclaration().getLocation()); + } + } + } + + public void dump(Logger logger) { + List> modules = findDeclarations(ModuleDeclaration.class, "*"); + logger.info(modules.size() + " module" + (modules.size() > 1 ? "s" : "") + " and " + types.size() + " type" + + (types.size() > 1 ? "s" : "") + " found."); + logger.info("modules: "); + for (QualifiedDeclaration m : modules) { + logger.info(" * " + getModuleName(m.getDeclaration())); + } + // logger.info("types: "); + // for (TypeDeclaration t : findDeclarations(TypeDeclaration.class, + // "*")) { + // if (!t.isAnonymous()) { + // logger.info(" * " + getTypeName(t)); + // } + // } + // logger.info("registered types: "); + // for (TypeDeclaration t : types.values()) { + // logger.info(" * " + getTypeName(t)); + // } + } + + public void calculateArrayTypes() { + for (TypeDeclaration t : types.values()) { + if (t.getTypeParameters() == null || t.getTypeParameters().length != 1) { + continue; + } + Declaration length = t.findDeclaration("length"); + if (length == null) { + continue; + } + Declaration get = t.findDeclaration(JSweetDefTranslatorConfig.INDEXED_GET_FUCTION_NAME); + if (get == null || !(get instanceof FunctionDeclaration)) { + continue; + } + FunctionDeclaration getFunction = (FunctionDeclaration) get; + if (getFunction.getParameters().length == 1 + && "number".equals(getFunction.getParameters()[0].getType().getName())) { + if (t.getTypeParameters()[0].getName() != null + && t.getTypeParameters()[0].getName().equals(getFunction.getType().getName())) { + // System.out.println("found array type: " + getTypeName(t) + // + " - " + Arrays.asList(t.getMembers())); + arrayTypes.add(t); + } + } + } + } + + protected void initCoreTypes() { + if (JSweetDefTranslatorConfig.isJDKReplacementMode()) { + registerType("java.util.function.Function", TypeDeclaration.createExternalTypeDeclaration("Function")); + registerType("java.util.function.BiFunction", TypeDeclaration.createExternalTypeDeclaration("BiFunction")); + registerType("java.util.function.TriFunction", + TypeDeclaration.createExternalTypeDeclaration("TriFunction")); + registerType("java.util.function.Supplier", TypeDeclaration.createExternalTypeDeclaration("Supplier")); + registerType("java.util.function.Consumer", TypeDeclaration.createExternalTypeDeclaration("Consumer")); + registerType("java.util.function.BiConsumer", TypeDeclaration.createExternalTypeDeclaration("BiConsumer")); + registerType("java.util.function.TriConsumer", + TypeDeclaration.createExternalTypeDeclaration("TriConsumer")); + } else { + registerType("java.lang.Object", TypeDeclaration.createExternalTypeDeclaration("Object")); + registerType("java.lang.Boolean", TypeDeclaration.createExternalTypeDeclaration("Boolean")); + registerType("java.lang.String", TypeDeclaration.createExternalTypeDeclaration("String")); + registerType("java.util.function.Function", TypeDeclaration.createExternalTypeDeclaration("Function")); + registerType("java.util.function.BiFunction", TypeDeclaration.createExternalTypeDeclaration("BiFunction")); + registerType("jsweet.util.function.TriFunction", + TypeDeclaration.createExternalTypeDeclaration("TriFunction")); + registerType("java.util.function.Supplier", TypeDeclaration.createExternalTypeDeclaration("Supplier")); + registerType("java.util.function.Consumer", TypeDeclaration.createExternalTypeDeclaration("Consumer")); + registerType("java.util.function.BiConsumer", TypeDeclaration.createExternalTypeDeclaration("BiConsumer")); + registerType("jsweet.util.function.TriConsumer", + TypeDeclaration.createExternalTypeDeclaration("TriConsumer")); + } + registerType("java.lang.Double", TypeDeclaration.createExternalTypeDeclaration("Double")); + registerType("java.lang.Runnable", TypeDeclaration.createExternalTypeDeclaration("Runnable")); + registerType("java.lang.Void", TypeDeclaration.createExternalTypeDeclaration("Void")); + registerType("double", TypeDeclaration.createExternalTypeDeclaration("double")); + registerType("boolean", TypeDeclaration.createExternalTypeDeclaration("boolean")); + registerType("void", TypeDeclaration.createExternalTypeDeclaration("void")); + registerType("any", TypeDeclaration.createExternalTypeDeclaration("any")); + registerType("string", TypeDeclaration.createExternalTypeDeclaration("string")); + registerType("number", TypeDeclaration.createExternalTypeDeclaration("number")); + registerType("symbol", TypeDeclaration.createExternalTypeDeclaration("symbol")); + registerType(JSweetDefTranslatorConfig.UNION_CLASS_NAME, + TypeDeclaration.createExternalTypeDeclaration("interface", "Union")); + for (int i = 2; i <= 6; i++) { + registerType( + JSweetDefTranslatorConfig.TUPLE_CLASSES_PACKAGE + "." + + JSweetDefTranslatorConfig.TUPLE_CLASSES_PREFIX + i, + TypeDeclaration.createExternalTypeDeclaration(JSweetDefTranslatorConfig.TUPLE_CLASSES_PREFIX + i)); + } + } + + public void addDuplicate(FullFunctionDeclaration function1, FullFunctionDeclaration function2) { + boolean added = false; + for (Set s : duplicates) { + if (s.contains(function1) || s.contains(function2)) { + s.add(function1); + s.add(function2); + added = true; + break; + } + } + if (!added) { + Set s = new HashSet(); + s.add(function1); + s.add(function2); + duplicates.add(s); + } + } + + public void addOverride(FullFunctionDeclaration override, FullFunctionDeclaration overridden) { + overrides.put(override, overridden); + overridens.put(overridden, override); + } + + public String getFullTypeNameNoErasure(TypeReference t) { + if (t.isArray()) { + return getFullTypeNameNoErasure(t.getComponentType()) + "[]"; + } else { + Type type = t.getDeclaration(); + if (type instanceof TypeDeclaration) { + StringBuilder sb = new StringBuilder(); + sb.append(((TypeDeclaration) type).getName()); + if (t.getTypeArguments() != null) { + sb.append("<"); + for (int i = 0; i < t.getTypeArguments().length; i++) { + sb.append(getFullTypeNameNoErasure(t.getTypeArguments()[i])); + if (i < t.getTypeArguments().length) { + sb.append(","); + } + } + if (t.getTypeArguments().length > 0) { + sb.deleteCharAt(sb.length() - 1); + } + sb.append(">"); + } + return sb.toString(); + } else if (type instanceof TypeParameterDeclaration) { + return type.getName(); + } else { + return t.getWrappingTypeName(); + } + } + } + + public String getShortTypeNameNoErasure(TypeReference t) { + if (t.isArray()) { + return getShortTypeNameNoErasure(t.getComponentType()) + "[]"; + } else { + Type type = t.getDeclaration(); + if (type instanceof TypeDeclaration) { + StringBuilder sb = new StringBuilder(); + String s = ((TypeDeclaration) type).getName(); + // todo: wrap type (no primitive types) + sb.append(s); + if (t.getTypeArguments() != null) { + sb.append("<"); + for (int i = 0; i < t.getTypeArguments().length; i++) { + sb.append(getShortTypeNameNoErasure(t.getTypeArguments()[i])); + if (i < t.getTypeArguments().length) { + sb.append(","); + } + } + if (t.getTypeArguments().length > 0) { + sb.deleteCharAt(sb.length() - 1); + } + sb.append(">"); + } + return sb.toString(); + } else if (type instanceof TypeParameterDeclaration) { + return type.getName(); + } else { + return t.getWrappingTypeName(); + } + } + } + + public String getShortTypeNameErased(TypeReference t) { + if (t.isArray()) { + return getShortTypeNameErased(t.getComponentType()) + "[]"; + } else { + Type type = t.getDeclaration(); + if (type instanceof TypeDeclaration) { + // todo: wrap type (no primitive types) + return ((TypeDeclaration) type).getName(); + } else if (type instanceof TypeParameterDeclaration) { + return type.getName(); + } else { + return t.getWrappingTypeName(); + } + } + } + + public String getTypeNameErased(TypeReference t) { + if (t.isArray()) { + return getTypeNameErased(t.getComponentType()) + "[]"; + } + if (t instanceof FunctionalTypeReference) { + throw new RuntimeException("invalid functional type" + t); + } + if ("any".equals(t.getName())) { + return "java.lang.Object"; + } + Type type = t.getDeclaration(); + if (type instanceof TypeDeclaration) { + return getTypeName((TypeDeclaration) type); + } else if (type instanceof TypeParameterDeclaration) { + TypeParameterDeclaration tpd = (TypeParameterDeclaration) type; + if (tpd.getUpperBound() == null) { + return "java.lang.Object"; + } else { + return getTypeNameErased(tpd.getUpperBound()); + } + } else { + return t.getWrappingTypeName(); + // Token token = getCurrentToken(); + // System.err.println("ERROR: invalid type "+t.getName() + (token == + // null ? "" : " at " + token.getLocation())); + // throw new RuntimeException("invalid type"); + } + } + + public String getSignature(FunctionDeclaration function) { + StringBuilder sb = new StringBuilder(); + sb.append(function.getName()); + sb.append("("); + for (ParameterDeclaration p : function.getParameters()) { + sb.append(getFullTypeNameNoErasure(p.getType())); + sb.append(","); + } + if (function.getParameters().length > 0) { + sb.deleteCharAt(sb.length() - 1); + } + sb.append(")"); + return sb.toString(); + } + + public List getDependenciesDefinitions() { + return dependenciesDefinitions; + } + + public List getLibrariesDefinitions() { + return librariesDefinitions; + } + + public List getAllDefinitions() { + List allFiles = new LinkedList<>(getDependenciesDefinitions()); + allFiles.addAll(getLibrariesDefinitions()); + + return allFiles; + } + + public boolean isDependency(CompilationUnit compilationUnit) { + String currentLibPath = compilationUnit.getFile().getAbsolutePath(); + for (File dependencyFile : getLibrariesDefinitions()) { + if (currentLibPath.equals(dependencyFile.getAbsolutePath())) { + return false; + } + } + return true; + } + + public void registerModule(String name, ModuleDeclaration moduleDeclaration) { + moduleNames.put(moduleDeclaration, name); + } + + /** + * Gets the module that contains the belonging Javascript library definition + * from a fully qualified name. If the given name does not belong to any + * library, returns null. + * + * @param qualifiedName + * ex: def.xxx + */ + public String getLibModule(String qualifiedName) { + if (libModules.contains(qualifiedName)) { + return qualifiedName; + } + // TODO: we need a faster way + for (String m : libModules) { + if (qualifiedName.startsWith(m + ".")) { + return m; + } + } + return null; + } + + public String getLibRelativePath(String qualifiedName) { + if (JSweetDefTranslatorConfig.isLibPath(qualifiedName)) { + String m = getLibModule(qualifiedName); + if (m != null) { + if (qualifiedName.length() > m.length()) { + return qualifiedName.substring(m.length() + 1); + } + } + } + return qualifiedName; + } + + /** + * Finds in the AST all the declarations for a given type and matching the + * given full name. + * + *

+ * A declaration expression supports the * wildcard to allow any path in the + * expression. Examples of declaration expressions: + *

    + *
  • "a.d.c": matches all declarations having this exact full name
  • + *
  • "*.c": matches all the declarations named "c"
  • + *
  • "a.*": matches all the declarations in the "a" container
  • + *
  • "a.*.c": matches all the declarations named "c" in the "a" container, + * with any path between "a" and "c"
  • + *
+ * + * @param type + * the declarations type + * @param declExpression + * an expression to match the full name, supporting wildcards + * @param compilationUnits + * the compilation unit(s) to search in (search in all available + * compilation units if omitted) + * @return the list of all matching declarations by match order + */ + public List> findDeclarations(Class type, String declFullName, + CompilationUnit... compilationUnits) { + + final Pattern pattern = declFullName.contains("*") + ? Pattern.compile(declFullName.replace(".", "\\.").replace("*", ".*")) : null; + + DeclarationFinder finder = new DeclarationFinder<>(this, new DeclarationFinder.Matcher() { + @Override + public void matches(DeclarationFinder scanner, Visitable node) { + String declarationName = scanner.getCurrentDeclarationName(); + if (pattern != null) { + if (type.isInstance(node) && pattern.matcher(declarationName).matches()) { + scanner.setMatchState(true, true); + } else { + scanner.setMatchState(false, true); + } + } else { + if (declFullName.equals(declarationName)) { + if (type.isInstance(node)) { + scanner.setMatchState(true, false); + } else { + scanner.setMatchState(false, false); + } + } else if (declFullName.startsWith(declarationName)) { + scanner.setMatchState(false, true); + } else { + scanner.setMatchState(false, false); + } + } + } + + }); + + finder.scan(compilationUnits.length == 0 ? this.compilationUnits : Arrays.asList(compilationUnits)); + return finder.getMatches(); + } + + /** + * Finds in the AST the first declaration for a given type and matching the + * given full name. + * + *

+ * A declaration expression supports the * wildcard to allow any path in the + * expression. Examples of declaration expressions: + *

    + *
  • "a.d.c": matches all declarations having this exact full name
  • + *
  • "*.c": matches all the declarations named "c"
  • + *
  • "a.*": matches all the declarations in the "a" container
  • + *
  • "a.*.c": matches all the declarations named "c" in the "a" container, + * with any path between "a" and "c"
  • + *
+ * + * @param type + * the declarations type + * @param declExpression + * an expression to match the full name, supporting wildcards + * @param compilationUnits + * the compilation unit(s) to search in (search in all available + * compilation units if omitted) + * @return the first matching declaration + */ + public QualifiedDeclaration findFirstDeclaration(Class type, String declFullName, + CompilationUnit... compilationUnits) { + List> matches = findDeclarations(type, declFullName, compilationUnits); + if (matches.isEmpty()) { + return null; + } else { + return matches.get(0); + } + } + + /** + * Registers a mixin (type declaration) for a given lib. Registered mixins + * will be reflected in the @Root annotation of the lib. + */ + public void resiterMixin(String libModule, TypeDeclaration typeDeclaration) { + List mixinsForLib = mixins.get(libModule); + if (mixinsForLib == null) { + mixinsForLib = new ArrayList<>(); + mixins.put(libModule, mixinsForLib); + } + mixinsForLib.add(typeDeclaration); + } + + /** + * Returns the registered mixins for the given lib. + */ + public List getMixins(String libModule) { + return mixins.get(libModule); + } + + public CompilationUnit getCompilationUnit(File tsDefFile) { + for (CompilationUnit compilUnit : compilationUnits) { + if (tsDefFile.equals(compilUnit.file)) { + return compilUnit; + } + } + + return null; + } + + public final Map getTypeNames() { + return typeNames; + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Declaration.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Declaration.java new file mode 100644 index 00000000..9103f8ec --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Declaration.java @@ -0,0 +1,48 @@ +package org.jsweet.input.typescriptdef.ast; + +import java.lang.annotation.Annotation; +import java.lang.reflect.AnnotatedElement; +import java.util.List; +import java.util.Set; + +public interface Declaration extends AstNode, NamedElement, AnnotatedElement { + + String getDocumentation(); + + void setDocumentation(String documentation); + + void addModifier(String modifier); + + void removeModifier(String modifier); + + boolean hasModifier(String modifier); + + Set getModifiers(); + + void setModifiers(Set modifiers); + + Declaration copy(); + + boolean isInputAnnotatedWith(String annotation); + + void addAnnotation(Annotation annotation); + + T removeAnnotation(Class annotationClass); + + void addStringAnnotation(String annotation); + + void removeStringAnnotation(String annotation); + + List getStringAnnotations(); + + void setStringAnnotations(List stringAnnotations); + + boolean hasStringAnnotation(String annotation); + + String getStringAnnotation(String annotation); + + boolean isQuotedName(); + + void setQuotedName(boolean quotedName); + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/DeclarationContainer.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/DeclarationContainer.java new file mode 100644 index 00000000..06afc25f --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/DeclarationContainer.java @@ -0,0 +1,35 @@ +package org.jsweet.input.typescriptdef.ast; + +import java.util.List; + + +public interface DeclarationContainer extends Visitable { + + Declaration[] getMembers(); + + void addMember(Declaration declaration); + + void replaceMember(Declaration existingDeclaration, Declaration withNewDeclaration); + + void removeMember(Declaration declaration); + + void clearMembers(); + + FunctionDeclaration findFirstFunction(String name); + + List findFunctions(String name); + + VariableDeclaration findVariable(String name); + + VariableDeclaration findVariableIgnoreCase(String name); + + TypeDeclaration findType(String name); + + TypeDeclaration findTypeIgnoreCase(String name); + + Declaration findDeclaration(String name); + + Declaration findDeclaration(Declaration declaration); + + void addMembers(Declaration[] declarations); +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/DeclarationHelper.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/DeclarationHelper.java new file mode 100644 index 00000000..557ae002 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/DeclarationHelper.java @@ -0,0 +1,411 @@ +package org.jsweet.input.typescriptdef.ast; + +import java.lang.annotation.Annotation; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; +import org.jsweet.JSweetDefTranslatorConfig; + +public abstract class DeclarationHelper { + + public static final Map JAVA_OBJECT_METHODS = new HashMap(); + // public static final Set JAVA_FINAL_OBJECT_METHODS = new + // HashSet(); + // public static final Set JAVA_OBJECT_METHOD_NAMES = new + // HashSet(); + public static final Set JS_OBJECT_METHOD_NAMES = new HashSet(); + public static final Set JS_PRIMITIVE_TYPE_NAMES = new HashSet(); + + static { + JS_OBJECT_METHOD_NAMES.add("toString"); + + JS_PRIMITIVE_TYPE_NAMES.add("boolean"); + JS_PRIMITIVE_TYPE_NAMES.add("number"); + + if (!JSweetDefTranslatorConfig.isJDKReplacementMode()) { + // toString is common to Java and Javascript + // JAVA_OBJECT_METHOD_NAMES.add("finalize"); + // JAVA_OBJECT_METHOD_NAMES.add("clone"); + // JAVA_OBJECT_METHOD_NAMES.add("equals"); + // JAVA_OBJECT_METHOD_NAMES.add("hashCode"); + // JAVA_OBJECT_METHOD_NAMES.add("notify"); + // JAVA_OBJECT_METHOD_NAMES.add("notifyAll"); + // JAVA_OBJECT_METHOD_NAMES.add("getClass"); + + JAVA_OBJECT_METHODS.put("finalize", new int[] { 0 }); + JAVA_OBJECT_METHODS.put("clone", new int[] { 0 }); + JAVA_OBJECT_METHODS.put("equals", new int[] { 1 }); + JAVA_OBJECT_METHODS.put("hashCode", new int[] { 0 }); + JAVA_OBJECT_METHODS.put("notify", new int[] { 0 }); + JAVA_OBJECT_METHODS.put("notifyAll", new int[] { 0 }); + JAVA_OBJECT_METHODS.put("getClass", new int[] { 0 }); + JAVA_OBJECT_METHODS.put("wait", new int[] { 0, 1, 2 }); + + // JAVA_FINAL_OBJECT_METHODS.add("notify():void"); + // JAVA_FINAL_OBJECT_METHODS.add("notifyAll():void"); + // JAVA_FINAL_OBJECT_METHODS.add("wait():void"); + // JAVA_FINAL_OBJECT_METHODS.add("wait(long):void"); + // JAVA_FINAL_OBJECT_METHODS.add("wait(long,int):void"); + // JAVA_FINAL_OBJECT_METHODS.add("getClass():java.lang.Class"); + } + } + + public static boolean isPrimitiveType(String name) { + return JS_PRIMITIVE_TYPE_NAMES.contains(name); + } + + public static String getActualFunctionName(FunctionDeclaration function) { + if (JAVA_OBJECT_METHODS.keySet().contains(function.getName())) { + if (ArrayUtils.contains(JAVA_OBJECT_METHODS.get(function.getName()), function.getParameters().length)) { + return StringUtils.capitalize(function.getName()); + } + } + return function.getName(); + } + + public static String toJavaIdentifier(String identifier) { + if (JSweetDefTranslatorConfig.JAVA_KEYWORDS.contains(identifier)) { + return StringUtils.capitalize(identifier); + } + if (JSweetDefTranslatorConfig.JAVA_TS_KEYWORDS.contains(identifier)) { + return StringUtils.capitalize(identifier); + } + + // TODO: this is not what happens... it must have been transformed + // before + if (Character.isDigit(identifier.charAt(0))) { + return "$$" + identifier.charAt(0) + "$$" + identifier.substring(1); + } + return identifier; + } + + public static Declaration[] addMember(DeclarationContainer container, Declaration declaration) { + return ArrayUtils.add(container.getMembers(), declaration); + } + + public static Declaration[] replaceMember(DeclarationContainer container, Declaration existingDeclaration, + Declaration withNewDeclaration) { + int index = ArrayUtils.indexOf(container.getMembers(), existingDeclaration); + if (index >= 0) { + container.getMembers()[index] = withNewDeclaration; + } + return container.getMembers(); + } + + public static Declaration[] removeMember(DeclarationContainer container, Declaration declaration) { + int index = ArrayUtils.indexOf(container.getMembers(), declaration); + if (index < 0) { + return container.getMembers(); + } + return ArrayUtils.remove(container.getMembers(), index); + } + + public static List findConstructors(TypeDeclaration typeDeclaration) { + if (typeDeclaration.getMembers() == null) { + return null; + } + List constructors = new ArrayList(); + for (Declaration m : typeDeclaration.getMembers()) { + if (m instanceof FunctionDeclaration) { + if (((FunctionDeclaration) m).isConstructor()) { + constructors.add((FunctionDeclaration) m); + } + } + } + return constructors; + } + + public static FunctionDeclaration findFirstConstructor(TypeDeclaration typeDeclaration) { + if (typeDeclaration.getMembers() == null) { + return null; + } + for (Declaration m : typeDeclaration.getMembers()) { + if (m instanceof FunctionDeclaration) { + if (((FunctionDeclaration) m).isConstructor()) { + return (FunctionDeclaration) m; + } + } + } + return null; + } + + public static boolean isStatic(TypeDeclaration typeDeclaration) { + if (typeDeclaration.getMembers() == null) { + return true; + } + if (!typeDeclaration.isInterface()) { + return false; + } + for (Declaration m : typeDeclaration.getMembers()) { + if (!m.hasModifier("static")) { + return false; + } + } + return true; + } + + public static TypeReference[] toTypeArguments(TypeParameterDeclaration[] typeParameterDeclarations) { + if (typeParameterDeclarations == null) { + return null; + } + TypeReference[] args = new TypeReference[typeParameterDeclarations.length]; + for (int i = 0; i < typeParameterDeclarations.length; i++) { + args[i] = new TypeReference(null, typeParameterDeclarations[i].getName(), null); + } + return args; + } + + public static List findFunctions(DeclarationContainer container, String name) { + if (container.getMembers() == null) { + return null; + } + List functions = new ArrayList(); + for (Declaration m : container.getMembers()) { + if (m instanceof FunctionDeclaration) { + if (((FunctionDeclaration) m).getName().equals(name)) { + functions.add((FunctionDeclaration) m); + } + } + } + return functions; + } + + public static FunctionDeclaration findFirstFunction(DeclarationContainer container, String name) { + if (container.getMembers() == null) { + return null; + } + for (Declaration m : container.getMembers()) { + if (m instanceof FunctionDeclaration) { + if (((FunctionDeclaration) m).getName().equals(name)) { + return (FunctionDeclaration) m; + } + } + } + return null; + } + + public static VariableDeclaration findVariable(DeclarationContainer container, String name) { + if (container.getMembers() == null) { + return null; + } + for (Declaration m : container.getMembers()) { + if (m instanceof VariableDeclaration) { + if (((VariableDeclaration) m).getName().equals(name)) { + return (VariableDeclaration) m; + } + } + } + return null; + } + + public static VariableDeclaration findVariableIgnoreCase(DeclarationContainer container, String name) { + if (container.getMembers() == null) { + return null; + } + for (Declaration m : container.getMembers()) { + if (m instanceof VariableDeclaration) { + if (((VariableDeclaration) m).getName().equalsIgnoreCase(name)) { + return (VariableDeclaration) m; + } + } + } + return null; + } + + public static TypeDeclaration findType(DeclarationContainer container, String name) { + if (container.getMembers() == null) { + return null; + } + for (Declaration m : container.getMembers()) { + if (m instanceof TypeDeclaration) { + if (((TypeDeclaration) m).getName().equals(name)) { + return (TypeDeclaration) m; + } + } + } + return null; + } + + public static TypeDeclaration findTypeIgnoreCase(DeclarationContainer container, String name) { + if (container.getMembers() == null) { + return null; + } + for (Declaration m : container.getMembers()) { + if (m instanceof TypeDeclaration) { + if (((TypeDeclaration) m).getName().equalsIgnoreCase(name)) { + return (TypeDeclaration) m; + } + } + } + return null; + } + + public static ModuleDeclaration findModule(DeclarationContainer container, String name) { + if (container.getMembers() == null) { + return null; + } + for (Declaration m : container.getMembers()) { + if (m instanceof ModuleDeclaration) { + if (((ModuleDeclaration) m).getName().equals(name)) { + return (ModuleDeclaration) m; + } + } + } + return null; + } + + public static Declaration findDeclaration(DeclarationContainer container, String name) { + if (container.getMembers() == null) { + return null; + } + for (Declaration d : container.getMembers()) { + if (d.getName().equals(name)) { + return d; + } + } + return null; + } + + public static Declaration findDeclaration(DeclarationContainer container, Declaration declaration) { + if (container.getMembers() == null) { + return null; + } + int i = ArrayUtils.indexOf(container.getMembers(), declaration); + if (i < 0) { + return null; + } else { + return container.getMembers()[i]; + } + } + + public static Declaration[] findAllVisibleDeclarations(DeclarationContainer container, Declaration declaration) { + Declaration[] result = {}; + if (container.getMembers() == null) { + return result; + } + for (Declaration d : container.getMembers()) { + if (!d.isHidden() && d.equals(declaration)) { + result = ArrayUtils.add(result, d); + } + } + return result; + } + + public static void addMembers(DeclarationContainer targetContainer, Declaration[] declarations) { + for (Declaration d : declarations) { + if (findDeclaration(targetContainer, d) == null) { + targetContainer.addMember(d); + } + } + } + + public static boolean areDeclarationsEqual(Declaration[] declarations1, Declaration[] declarations2) { + for (Declaration d : declarations1) { + if (!ArrayUtils.contains(declarations2, d)) { + return false; + } + } + for (Declaration d : declarations2) { + if (!ArrayUtils.contains(declarations1, d)) { + return false; + } + } + return true; + } + + @SuppressWarnings("unchecked") + public static T[] copy(T[] declarations) { + if (declarations == null) { + return null; + } + T[] to = Arrays.copyOf(declarations, declarations.length); + for (int i = 0; i < declarations.length; i++) { + to[i] = (T) declarations[i].copy(); + } + return (T[]) to; + } + + public static T[] copyReferences(T[] references) { + return copyReferences(references, false); + } + + @SuppressWarnings("unchecked") + public static T[] copyReferences(T[] references, boolean copyDeclarations) { + if (references == null) { + return null; + } + T[] to = Arrays.copyOf(references, references.length); + for (int i = 0; i < references.length; i++) { + to[i] = (T) references[i].copy(copyDeclarations); + } + return (T[]) to; + } + + public static TypeReference[] toReferences(T[] types) { + if (types == null) { + return null; + } + TypeReference[] to = new TypeReference[types.length]; + for (int i = 0; i < types.length; i++) { + to[i] = new TypeReference(null, types[i], null); + } + return to; + } + + public static TypeDeclaration createFunctionalType(String name, int parameterCount, boolean hasResult, + boolean disambiguation) { + TypeDeclaration functionalType = null; + TypeParameterDeclaration[] typeParameters = new TypeParameterDeclaration[parameterCount]; + for (int i = 0; i < parameterCount; i++) { + typeParameters[i] = new TypeParameterDeclaration(null, "T" + (i + 1)); + } + TypeParameterDeclaration resultType = new TypeParameterDeclaration(null, "R"); + ParameterDeclaration[] parameters = new ParameterDeclaration[typeParameters.length]; + for (int i = 0; i < typeParameters.length; i++) { + parameters[i] = new ParameterDeclaration(null, "p" + (i + 1), + new TypeReference(null, typeParameters[i], null), false, false); + } + FunctionDeclaration newFunction = new FunctionDeclaration(null, + JSweetDefTranslatorConfig.ANONYMOUS_FUNCTION_NAME, + hasResult ? new TypeReference(null, resultType, null) : new TypeReference(null, "void", null), + parameters, null); + + if (hasResult) { + typeParameters = ArrayUtils.add(typeParameters, resultType); + } + functionalType = new TypeDeclaration(null, "interface", name, typeParameters, null, + new FunctionDeclaration[] { newFunction }); + functionalType.addAnnotation(new FunctionalInterface() { + @Override + public Class annotationType() { + return FunctionalInterface.class; + } + }); + if (disambiguation) { + functionalType.setDocumentation( + "/** This functional interface should be used for disambiguating lambdas in function parameters (by casting to this interface)." + + "

It was automatically generated for functions (taking lambdas) that lead to the same erased signature. */"); + } else { + functionalType.setDocumentation( + "/** This functional interface was automatically generated for allowing lambdas taking " + + parameterCount + " parameters " + (hasResult ? " and returning a result." : ".") + " */"); + } + return functionalType; + } + + public static Type getTypeOrComponentType(TypeReference typeReference) { + if (typeReference.isArray()) { + return getTypeOrComponentType(typeReference.getComponentType()); + } else { + return typeReference.getDeclaration(); + } + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/FullFunctionDeclaration.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/FullFunctionDeclaration.java new file mode 100644 index 00000000..53a2b5a7 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/FullFunctionDeclaration.java @@ -0,0 +1,35 @@ +package org.jsweet.input.typescriptdef.ast; + + +public class FullFunctionDeclaration { + + public FullFunctionDeclaration(ModuleDeclaration declaringModule, TypeDeclaration declaringType, FunctionDeclaration function) { + super(); + this.declaringType = declaringType; + this.function = function; + } + + public TypeDeclaration declaringType; + public ModuleDeclaration declaringModule; + public FunctionDeclaration function; + + @Override + public String toString() { + return (declaringModule == null ? "" : declaringModule.getName() + ".") + (declaringType == null ? "" : declaringType.getName() + ".") + function; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof FullFunctionDeclaration)) { + return false; + } + FullFunctionDeclaration d = (FullFunctionDeclaration) obj; + return this.function == d.function; + } + + @Override + public int hashCode() { + return function.hashCode(); + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/FunctionDeclaration.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/FunctionDeclaration.java new file mode 100644 index 00000000..2531a326 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/FunctionDeclaration.java @@ -0,0 +1,121 @@ +package org.jsweet.input.typescriptdef.ast; + +import java.util.ArrayList; +import java.util.HashSet; + +import org.jsweet.JSweetDefTranslatorConfig; + +public class FunctionDeclaration extends AbstractTypedDeclaration implements TypeParameterizedElement { + + public static final String NEW_FUNCTION_RESERVED_NAME = JSweetDefTranslatorConfig.NEW_FUNCTION_NAME; + public static final String ANONYMOUS_FUNCTION_RESERVED_NAME = JSweetDefTranslatorConfig.ANONYMOUS_FUNCTION_NAME; + public static final String INDEXSIG_RESERVED_NAME = JSweetDefTranslatorConfig.INDEXED_GET_FUCTION_NAME; + + ParameterDeclaration[] parameters; + TypeParameterDeclaration[] typeParameters; + + public FunctionDeclaration(Token token, String name, TypeReference type, ParameterDeclaration[] parameters, + TypeParameterDeclaration[] typeParameters) { + super(token, name, type); + this.parameters = parameters; + this.typeParameters = typeParameters; + + // System.out.println("new " + this); + } + + public boolean isConstructor() { + return "new".equals(name) || "constructor".equals(name) || NEW_FUNCTION_RESERVED_NAME.equals(name); + } + + public boolean isIndexSignature() { + return INDEXSIG_RESERVED_NAME.equals(name); + } + + @Override + public boolean isAnonymous() { + return super.isAnonymous() || ANONYMOUS_FUNCTION_RESERVED_NAME.equals(name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(super.toString()); + sb.append("("); + for (ParameterDeclaration p : parameters) { + sb.append(p.name); + sb.append(":"); + sb.append(p.getType().toString()); + sb.append(","); + } + if (parameters.length > 0) { + sb.deleteCharAt(sb.length() - 1); + } + sb.append(")"); + return sb.toString(); + } + + @Override + public void accept(Visitor v) { + v.visitFunctionDeclaration(this); + } + + public ParameterDeclaration[] getParameters() { + return parameters; + } + + public void setParameters(ParameterDeclaration[] parameters) { + this.parameters = parameters; + } + + @Override + public TypeParameterDeclaration[] getTypeParameters() { + return this.typeParameters; + } + + @Override + public void setTypeParameters(TypeParameterDeclaration[] typeParameters) { + this.typeParameters = typeParameters; + } + + @Override + public boolean equals(Object o) { + if (!o.getClass().equals(getClass())) { + return false; + } + FunctionDeclaration fd = (FunctionDeclaration) o; + String name1 = getName(); + if ("constructor".equals(name1)) { + name1 = "new"; + } + String name2 = fd.getName(); + if ("constructor".equals(name2)) { + name2 = "new"; + } + if (name2 == null && name1 != null) { + return false; + } + if (!name2.equals(name1)) { + return false; + } + if (fd.parameters.length != parameters.length) { + return false; + } + for (int i = 0; i < fd.parameters.length; i++) { + if (!parameters[i].getType().equals(fd.parameters[i].getType())) { + return false; + } + } + return true; + } + + @Override + public FunctionDeclaration copy() { + FunctionDeclaration copy = new FunctionDeclaration(null, name, getType() == null ? null : getType().copy(), + DeclarationHelper.copy(parameters), DeclarationHelper.copy(typeParameters)); + copy.setDocumentation(getDocumentation()); + copy.setModifiers(this.getModifiers() == null ? null : new HashSet(getModifiers())); + copy.setStringAnnotations(this.getStringAnnotations() == null ? null : new ArrayList( + getStringAnnotations())); + return copy; + } +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/FunctionalTypeReference.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/FunctionalTypeReference.java new file mode 100644 index 00000000..9cd7503b --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/FunctionalTypeReference.java @@ -0,0 +1,102 @@ +package org.jsweet.input.typescriptdef.ast; + +import org.apache.commons.lang3.StringUtils; + +public class FunctionalTypeReference extends TypeReference implements TypeParameterizedElement { + + private ParameterDeclaration[] parameters; + private TypeReference returnType; + private boolean constructor; + private TypeParameterDeclaration[] typeParameters; + + public FunctionalTypeReference(Token token, TypeReference returnType, ParameterDeclaration[] parameters, + TypeParameterDeclaration[] typeParameters) { + this(token, false, returnType, parameters, typeParameters); + } + + public FunctionalTypeReference(Token token, boolean constructor, TypeReference returnType, + ParameterDeclaration[] parameters, TypeParameterDeclaration[] typeParameters) { + super(token, (String) null, null); + this.parameters = parameters; + this.returnType = returnType; + this.constructor = constructor; + this.typeParameters = typeParameters; + } + + @Override + public String toString() { + return StringUtils.join(parameters, ",") + "=>" + returnType; + } + + @Override + public void accept(Visitor visitor) { + visitor.visitFunctionalTypeReference(this); + } + + public ParameterDeclaration[] getParameters() { + return parameters; + } + + public void setParameters(ParameterDeclaration[] parameters) { + this.parameters = parameters; + } + + public TypeReference getReturnType() { + return returnType; + } + + public void setReturnType(TypeReference returnType) { + this.returnType = returnType; + } + + @Override + public boolean equals(Object obj) { + if (!obj.getClass().equals(getClass())) { + return false; + } + FunctionalTypeReference ft = (FunctionalTypeReference) obj; + if (!getReturnType().equals(ft.getReturnType())) { + return false; + } + if (parameters.length != ft.parameters.length) { + return false; + } + for (int i = 0; i < ft.parameters.length; i++) { + if (!parameters[i].getType().equals(ft.parameters[i].getType())) { + return false; + } + } + return true; + } + + @Override + public FunctionalTypeReference copy(boolean copyDeclarations) { + FunctionalTypeReference copy = new FunctionalTypeReference(null, isConstructor(), + getReturnType().copy(copyDeclarations), DeclarationHelper.copy(getParameters()), + DeclarationHelper.copy(getTypeParameters())); + return copy; + } + + @Override + public FunctionalTypeReference copy() { + return copy(false); + } + + public boolean isConstructor() { + return constructor; + } + + public void setConstructor(boolean constructor) { + this.constructor = constructor; + } + + @Override + public TypeParameterDeclaration[] getTypeParameters() { + return typeParameters; + } + + @Override + public void setTypeParameters(TypeParameterDeclaration[] typeParameters) { + this.typeParameters = typeParameters; + } +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Literal.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Literal.java new file mode 100644 index 00000000..08ea165d --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Literal.java @@ -0,0 +1,30 @@ +package org.jsweet.input.typescriptdef.ast; + + +public class Literal extends AbstractAstNode { + + public Literal(Token token, String value) { + super(token); + this.value = value; + } + + protected String value; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + @Override + public void accept(Visitor visitor) { + visitor.visitLiteral(this); + } + + public Literal copy() { + return new Literal(null, this.value); + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/ModuleDeclaration.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/ModuleDeclaration.java new file mode 100644 index 00000000..e92b8cdb --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/ModuleDeclaration.java @@ -0,0 +1,117 @@ +package org.jsweet.input.typescriptdef.ast; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; + +public class ModuleDeclaration extends AbstractDeclaration implements DeclarationContainer { + + Declaration[] members; + + public static ModuleDeclaration createQualifiedModuleDeclaration(Token token, String qualifiedName, + Declaration[] members) { + + String[] subNames = qualifiedName.startsWith("\"") ? new String[] { qualifiedName } + : qualifiedName.split("\\."); + ModuleDeclaration module = new ModuleDeclaration(token, subNames[subNames.length - 1], members); + if (subNames.length > 1) { + return createQualifiedModuleDeclaration(token, + StringUtils.join(ArrayUtils.subarray(subNames, 0, subNames.length - 1), "."), + new Declaration[] { module }); + } else { + return module; + } + + } + + public ModuleDeclaration(Token token, String name, Declaration[] members) { + super(token, name); + this.members = members; + // System.out.println("new " + this); + } + + @Override + public void accept(Visitor v) { + v.visitModuleDeclaration(this); + } + + @Override + public Declaration[] getMembers() { + return members; + } + + @Override + public void addMember(Declaration declaration) { + members = DeclarationHelper.addMember(this, declaration); + } + + @Override + public void removeMember(Declaration declaration) { + members = DeclarationHelper.removeMember(this, declaration); + } + + @Override + public void replaceMember(Declaration existingDeclaration, Declaration withNewDeclaration) { + members = DeclarationHelper.replaceMember(this, existingDeclaration, withNewDeclaration); + } + + @Override + public void clearMembers() { + members = new Declaration[0]; + } + + public FunctionDeclaration findFirstFunction(String name) { + return DeclarationHelper.findFirstFunction(this, name); + } + + public List findFunctions(String name) { + return DeclarationHelper.findFunctions(this, name); + } + + public VariableDeclaration findVariable(String name) { + return DeclarationHelper.findVariable(this, name); + } + + @Override + public VariableDeclaration findVariableIgnoreCase(String name) { + return DeclarationHelper.findVariableIgnoreCase(this, name); + } + + @Override + public TypeDeclaration findType(String name) { + return DeclarationHelper.findType(this, name); + } + + @Override + public TypeDeclaration findTypeIgnoreCase(String name) { + return DeclarationHelper.findTypeIgnoreCase(this, name); + } + + @Override + public Declaration findDeclaration(String name) { + return DeclarationHelper.findDeclaration(this, name); + } + + @Override + public void addMembers(Declaration[] declarations) { + DeclarationHelper.addMembers(this, declarations); + } + + @Override + public Declaration findDeclaration(Declaration declaration) { + return DeclarationHelper.findDeclaration(this, declaration); + } + + @Override + public ModuleDeclaration copy() { + ModuleDeclaration copy = new ModuleDeclaration(null, getName(), DeclarationHelper.copy(members)); + copy.setStringAnnotations( + this.getStringAnnotations() == null ? null : new ArrayList(getStringAnnotations())); + copy.quotedName = this.quotedName; + copy.originalName = this.originalName; + return copy; + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/NamedElement.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/NamedElement.java new file mode 100644 index 00000000..0286e2af --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/NamedElement.java @@ -0,0 +1,15 @@ +package org.jsweet.input.typescriptdef.ast; + +public interface NamedElement { + + boolean isAnonymous(); + + String getName(); + + void setName(String name); + + String getOriginalName(); + + void setOriginalName(String name); + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/ParameterDeclaration.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/ParameterDeclaration.java new file mode 100644 index 00000000..9e85f8e3 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/ParameterDeclaration.java @@ -0,0 +1,38 @@ +package org.jsweet.input.typescriptdef.ast; + +import java.util.ArrayList; +import java.util.HashSet; + +public class ParameterDeclaration extends VariableDeclaration { + + private boolean varargs = false; + + public ParameterDeclaration(Token token, String name, TypeReference type, boolean optional, boolean varargs) { + super(token, name, type, optional, false); + this.varargs = varargs; + } + + @Override + public void accept(Visitor v) { + v.visitParameterDeclaration(this); + } + + public boolean isVarargs() { + return varargs; + } + + public void setVarargs(boolean varargs) { + this.varargs = varargs; + } + + @Override + public ParameterDeclaration copy() { + ParameterDeclaration copy = new ParameterDeclaration(null, name, getType().copy(), isOptional(), isVarargs()); + copy.setModifiers(this.getModifiers() == null ? null : new HashSet(this.getModifiers())); + copy.setStringAnnotations(this.getStringAnnotations() == null ? null : new ArrayList( + getStringAnnotations())); + copy.setDocumentation(this.getDocumentation()); + return copy; + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/QualifiedDeclaration.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/QualifiedDeclaration.java new file mode 100644 index 00000000..0401e364 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/QualifiedDeclaration.java @@ -0,0 +1,35 @@ +package org.jsweet.input.typescriptdef.ast; + +import org.jsweet.input.typescriptdef.util.Util; + +public class QualifiedDeclaration { + private T declaration; + private String qualifiedDeclarationName; + + public QualifiedDeclaration(T declaration, String qualifiedDeclarationName) { + this.declaration = declaration; + this.qualifiedDeclarationName = qualifiedDeclarationName; + } + + public T getDeclaration() { + return declaration; + } + + public String getQualifiedDeclarationName() { + return qualifiedDeclarationName; + } + + @Override + public String toString() { + return qualifiedDeclarationName; + } + + public String getQualifier() { + return Util.getQualifier(qualifiedDeclarationName); + } + + public String getSimpleName() { + return Util.getSimpleName(qualifiedDeclarationName); + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/ReferenceDeclaration.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/ReferenceDeclaration.java new file mode 100644 index 00000000..7bc09972 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/ReferenceDeclaration.java @@ -0,0 +1,55 @@ +package org.jsweet.input.typescriptdef.ast; + +import static org.apache.commons.lang3.StringUtils.strip; + +import org.apache.commons.lang3.StringUtils; + +public class ReferenceDeclaration extends AbstractDeclaration { + + private String referencedName; + + public ReferenceDeclaration(Token token, String alias, String referencedName) { + super(token, alias); + + this.referencedName = strip(referencedName, "[\"']"); + } + + @Override + public void accept(Visitor v) { + v.visitReferenceDeclaration(this); + } + + @Override + public Declaration copy() { + ReferenceDeclaration copy = new ReferenceDeclaration(null, name, referencedName); + copy.setDocumentation(getDocumentation()); + copy.name = name; + copy.referencedName = referencedName; + return copy; + } + + public String getReferencedName() { + return referencedName; + } + + public boolean isImport() { + return !isExport(); + } + + public boolean isExport() { + return StringUtils.isBlank(name); + } + + @Override + public String toString() { + if (isExport()) { + return "export = " + referencedName; + } else { + return "import " + name + " = " + referencedName; + } + } + + public void setReferencedName(String referencedName) { + this.referencedName = referencedName; + } +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Scanner.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Scanner.java new file mode 100644 index 00000000..b0b14747 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Scanner.java @@ -0,0 +1,743 @@ +package org.jsweet.input.typescriptdef.ast; + +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import java.util.Stack; +import java.util.function.Predicate; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import org.jsweet.JSweetDefTranslatorConfig; + +public abstract class Scanner implements Visitor { + + private Stack stack = new Stack(); + + protected final Logger logger = Logger.getLogger(getClass()); + + protected Context context; + + public Scanner(Context context) { + this.context = context; + } + + @SuppressWarnings("unchecked") + public Scanner(Scanner parentScanner) { + this.context = parentScanner.context; + this.stack = (Stack) parentScanner.stack.clone(); + } + + public void onScanStart() { + } + + public void onScanEnded() { + } + + protected String getCurrentContainerName() { + return getContainerNameAtIndex(0); + } + + /** + * Gets the container name at the stack.size()-i level. + * + * @param i + * the reversed index (0=top of the stack) + */ + protected String getContainerNameAtIndex(int i) { + List modules = new ArrayList(); + for (int j = 0; j < getStack().size() - i; j++) { + Visitable v = getStack().get(j); + if (v instanceof ModuleDeclaration) { + modules.add(((ModuleDeclaration) v).getName()); + } + if (v instanceof TypeDeclaration && !((TypeDeclaration) v).isAnonymous()) { + modules.add(((TypeDeclaration) v).getName()); + } + } + return StringUtils.join(modules.iterator(), "."); + } + + protected String getCurrentModuleName() { + List modules = new ArrayList(); + for (Visitable v : getStack()) { + if (v instanceof ModuleDeclaration) { + modules.add(((ModuleDeclaration) v).getName()); + } + } + return StringUtils.join(modules.iterator(), "."); + } + + /** + * Tells if the given declaration belongs to the current scanning stack. + */ + protected boolean isInScope(Declaration declaration) { + boolean inScope = false; + for (int i = 0; i < getStack().size(); i++) { + if (getStack().get(i) == declaration) { + inScope = true; + break; + } + } + return inScope; + } + + protected String getCurrentDeclarationName() { + StringBuffer sb = new StringBuffer(); + for (Visitable v : getStack()) { + if (v instanceof Declaration) { + sb.append(((Declaration) v).getName()); + sb.append('.'); + } + } + if (!getStack().isEmpty() && !(sb.length() == 0)) { + sb.deleteCharAt(sb.length() - 1); + } + return sb.toString(); + } + + protected Visitable getRoot() { + if (getStack().isEmpty()) { + return null; + } + + return getStack().get(0); + } + + protected QualifiedDeclaration lookupTypeDeclaration(String name) { + if (name == null) { + return null; + } + // NOTE: it is possible to search using the context find methods... it + // would be nicer but it may be slower, so we do it this way... to be + // thought of + Set possibleNames = new LinkedHashSet(); + String mainModuleName = ""; + if (getRoot() instanceof CompilationUnit) { + mainModuleName = ((CompilationUnit) getRoot()).getMainModule().getName(); + } + + // lookup in current compilation unit + for (int i = 0; i < getStack().size(); i++) { + String containerName = getContainerNameAtIndex(i); + String declFullName = StringUtils.isBlank(containerName) ? name : containerName + "." + name; + if (declFullName.startsWith(mainModuleName)) { + possibleNames.add(declFullName.substring(mainModuleName.length() + 1)); + } + TypeDeclaration match = context.getTypeDeclaration(declFullName); + if (match != null) { + return new QualifiedDeclaration<>(match, declFullName); + } + } + + // lookup in all compilation units + for (CompilationUnit compilUnit : context.compilationUnits) { + for (String rootRelativeName : possibleNames) { + TypeDeclaration match = context + .getTypeDeclaration(compilUnit.getMainModule().getName() + "." + rootRelativeName); + if (match != null) { + return new QualifiedDeclaration<>(match, + compilUnit.getMainModule().getName() + "." + rootRelativeName); + } + } + } + + return null; + } + + protected QualifiedDeclaration lookupModuleDeclaration(String name) { + Set possibleNames = new LinkedHashSet(); + String mainModuleName = ""; + if (getRoot() instanceof CompilationUnit) { + mainModuleName = ((CompilationUnit) getRoot()).getMainModule().getName(); + } + + // lookup in current compilation unit + for (int i = 0; i < getStack().size(); i++) { + String containerName = getContainerNameAtIndex(i); + String declFullName = StringUtils.isBlank(containerName) ? name : containerName + "." + name; + + if (declFullName.startsWith(mainModuleName)) { + possibleNames.add(declFullName.substring(mainModuleName.length() + 1)); + } + List> matches = context.findDeclarations(ModuleDeclaration.class, + declFullName); + for (QualifiedDeclaration m : matches) { + return m; + } + } + + // lookup in all compilation units + for (CompilationUnit compilUnit : context.compilationUnits) { + for (String rootRelativeName : possibleNames) { + List> matches = context.findDeclarations( + ModuleDeclaration.class, compilUnit.getMainModule().getName() + "." + rootRelativeName); + for (QualifiedDeclaration m : matches) { + return m; + } + } + } + + return null; + } + + protected Type lookupType(TypeReference reference) { + return lookupType(reference, null, false, false); + } + + protected Type lookupType(TypeReference reference, String modName) { + return lookupType(reference, modName, false, false); + } + + protected boolean isFunctionalTypeReference(TypeReference typeReference) { + Type t = lookupType(typeReference, null); + if (t == null || !(t instanceof TypeDeclaration)) { + return false; + } + TypeDeclaration td = (TypeDeclaration) t; + if (context.getTypeName(td).startsWith(JSweetDefTranslatorConfig.FUNCTION_CLASSES_PACKAGE) + || context.getTypeName(td).startsWith("java.util.function")) { + return true; + } + if (td.isAnnotationPresent(FunctionalInterface.class)) { + return true; + } + return false; + } + + protected boolean isSuperTypeReference(TypeReference typeReference) { + if (!(getParent() instanceof TypeDeclaration)) { + return false; + } + + TypeDeclaration parentDeclaration = (TypeDeclaration) getParent(); + if (!ArrayUtils.contains(parentDeclaration.getSuperTypes(), typeReference)) { + return false; + } + + return true; + } + + protected boolean isTypeArgumentTypeReference(TypeReference typeReference) { + if (!(getParent() instanceof TypeReference)) { + return false; + } + + TypeReference parentReference = (TypeReference) getParent(); + if (!ArrayUtils.contains(parentReference.typeArguments, typeReference)) { + return false; + } + + return true; + } + + protected TypeDeclaration extraLookup(TypeReference reference, String modName) { + if (reference.getName() == null) { + return null; + } + + QualifiedDeclaration type = context.findFirstDeclaration(TypeDeclaration.class, + reference.getName(), getParent(CompilationUnit.class)); + if (type != null) { + return type.getDeclaration(); + } + type = context.findFirstDeclaration(TypeDeclaration.class, "*." + reference.getName(), + getParent(CompilationUnit.class)); + if (type != null) { + return type.getDeclaration(); + } + return null; + + // return lookupInLibModules(context.getLibModule(modName), + // context.getLibRelativePath(modName), reference); + } + + protected Type lookupType(TypeReference reference, String modName, boolean createIfNotFound, + boolean verboseIfNotFound) { + if (reference.getDeclaration() != null) { + return reference.getDeclaration(); + } + if (reference.isTypeOf()) { + return null; + } + if (reference.isObjectType()) { + reference.setDeclaration(reference.getObjectType()); + return reference.getObjectType(); + } else { + // lookup in the global type repository + if (modName == null) { + modName = getCurrentModuleName(); + } + TypeDeclaration t = context.getTypeDeclaration(modName + "." + reference.getName()); + if (t == null) { + t = context.getTypeDeclaration(reference.getName()); + if (t == null) { + String containerName = getCurrentContainerName(); + t = context.getTypeDeclaration(containerName + "." + reference.getName()); + if (t == null) { + if (!JSweetDefTranslatorConfig.isJDKReplacementMode()) { + t = context.getTypeDeclaration("java.lang." + reference.getName()); + } + if (t == null) { + t = context.getTypeDeclaration( + JSweetDefTranslatorConfig.GLOBALS_PACKAGE_NAME + "." + reference.getName()); + if (t == null) { + t = context.getTypeDeclaration( + JSweetDefTranslatorConfig.LANG_PACKAGE + "." + reference.getName()); + if (t == null) { + t = context.getTypeDeclaration( + JSweetDefTranslatorConfig.DOM_PACKAGE + "." + reference.getName()); + if (t == null) { + String[] subNames = modName.split("\\."); + String partialModName; + for (int i = subNames.length - 1; i > 0; i--) { + String[] a = ArrayUtils.subarray(subNames, 0, i); + partialModName = StringUtils.join(a, "."); + t = context.getTypeDeclaration(partialModName + "." + reference.getName()); + if (t != null) { + break; + } + } + } + } + } + } + } + } + } + // lookup in type parameters + if (t == null) { + TypeParameterizedElement tpe = getParent(TypeParameterizedElement.class, true); + while (tpe != null) { + if (tpe.getTypeParameters() != null) { + for (TypeParameterDeclaration d : tpe.getTypeParameters()) { + if (d.getName() != null && d.getName().equals(reference.getName())) { + reference.setDeclaration(d); + return d; + } + } + } + tpe = getParent(TypeParameterizedElement.class, tpe); + } + } + + if (t == null) { + t = extraLookup(reference, modName); + } + + if (t == null) { + QualifiedDeclaration match = lookupTypeDeclaration(reference.getName()); + if (match != null) { + t = match.getDeclaration(); + } + } + + if (t == null) { + if (createIfNotFound) { + Token token = getCurrentToken(); + System.err.println("WARNING: creating unknown reference " + reference + " at " + + (token == null ? "" : token.getLocation())); + String[] names = reference.getName().split("\\."); + TypeDeclaration type = new TypeDeclaration(null, "class", names[names.length - 1], null, null, + null); + ModuleDeclaration module; + if (names.length > 1) { + module = new ModuleDeclaration(null, + StringUtils.join(ArrayUtils.subarray(names, 0, names.length - 1), "."), + new Declaration[] { type }); + context.registerModule(module.getName(), module); + } else { + module = new ModuleDeclaration(null, JSweetDefTranslatorConfig.GLOBALS_PACKAGE_NAME, + new Declaration[] { type }); + } + context.compilationUnits.get(0).addMember(module); + context.registerType(module.getName() + "." + type.getName(), type); + } else { + if (verboseIfNotFound) { + Token token = getCurrentToken(); + context.reportError("cannot find reference " + reference + " (" + getCurrentContainerName() + + "." + reference.getName() + ")" + " at " + + (token == null ? "" : token.getLocation())); + } + } + } + + reference.setDeclaration(t); + return t; + } + } + + protected QualifiedDeclaration lookupFunctionDeclaration(String name) { + Set possibleNames = new LinkedHashSet(); + String mainModuleName = ""; + if (getRoot() instanceof CompilationUnit) { + ModuleDeclaration mainModule = ((CompilationUnit) getRoot()).getMainModule(); + if (mainModule != null) { + mainModuleName = mainModule.getName(); + } + } + + // lookup in current compilation unit + for (int i = 0; i < getStack().size(); i++) { + String containerName = getContainerNameAtIndex(i); + String declFullName = StringUtils.isBlank(containerName) ? name : containerName + "." + name; + + if (declFullName.startsWith(mainModuleName)) { + possibleNames.add(declFullName.substring(mainModuleName.length() + 1)); + } + List> matches = context + .findDeclarations(FunctionDeclaration.class, declFullName); + if (matches.size() > 0) { + return matches.get(0); + } + } + + // lookup in all compilation units + for (CompilationUnit compilUnit : context.compilationUnits) { + if (compilUnit.getMainModule() == null) { + continue; + } + for (String rootRelativeName : possibleNames) { + List> matches = context.findDeclarations( + FunctionDeclaration.class, compilUnit.getMainModule().getName() + "." + rootRelativeName); + if (matches.size() > 0) { + return matches.get(0); + } + } + } + + return null; + } + + protected QualifiedDeclaration lookupVariableDeclaration(String name) { + Set possibleNames = new LinkedHashSet(); + String mainModuleName = ""; + if (getRoot() instanceof CompilationUnit) { + ModuleDeclaration mainModule = ((CompilationUnit) getRoot()).getMainModule(); + if (mainModule != null) { + mainModuleName = mainModule.getName(); + } + } + + // lookup in current compilation unit + for (int i = 0; i < getStack().size(); i++) { + String containerName = getContainerNameAtIndex(i); + String declFullName = StringUtils.isBlank(containerName) ? name : containerName + "." + name; + + if (declFullName.startsWith(mainModuleName)) { + possibleNames.add(declFullName.substring(mainModuleName.length() + 1)); + } + List> matches = context + .findDeclarations(VariableDeclaration.class, declFullName); + if (matches.size() > 0) { + return matches.get(0); + } + } + + // lookup in all compilation units + for (CompilationUnit compilUnit : context.compilationUnits) { + if (compilUnit.getMainModule() == null) { + continue; + } + for (String rootRelativeName : possibleNames) { + List> matches = context.findDeclarations( + VariableDeclaration.class, compilUnit.getMainModule().getName() + "." + rootRelativeName); + if (matches.size() > 0) { + return matches.get(0); + } + } + } + + return null; + } + + protected FunctionDeclaration lookupFunctionDeclaration(TypeReference typeReference, String name, + TypeReference... argTypes) { + TypeDeclaration type = (TypeDeclaration) lookupType(typeReference, null); + if (type == null) { + return null; + } + boolean found = false; + for (Declaration d : type.getMembers()) { + if (name.equals(d.getName())) { + if (d instanceof FunctionDeclaration) { + FunctionDeclaration function = (FunctionDeclaration) d; + if (argTypes.length == function.getParameters().length) { + found = true; + for (int i = 0; i < argTypes.length; i++) { + if (!argTypes[i].equals(function.getParameters()[i].getType())) { + found = false; + } + } + if (found) { + return function; + } + } + } + } + } + if (type.getSuperTypes() != null) { + for (TypeReference t : type.getSuperTypes()) { + FunctionDeclaration f = lookupFunctionDeclaration(t, name, argTypes); + if (f != null) { + return f; + } + } + } + return null; + } + + public void printStackTrace(PrintStream out) { + out.println("Dumping scanner stack: " + this.getClass().getSimpleName() + " - " + stack.size()); + for (int i = stack.size() - 1; i >= 0; i--) { + if (stack.get(i) instanceof AstNode) { + AstNode node = (AstNode) stack.get(i); + out.println(" " + node.getClass().getSimpleName() + " - " + + (node.getToken() == null ? "N/A" : node.getToken() + " " + node.getToken().getLocation())); + } + } + } + + public Token getCurrentToken() { + for (int i = stack.size() - 1; i >= 0; i--) { + if (stack.get(i) instanceof AstNode) { + AstNode node = (AstNode) stack.get(i); + if (node.getToken() != null) { + return node.getToken(); + } + } + } + return null; + } + + protected void enter(Visitable element) { + if (!stack.isEmpty() && stack.peek() == element) { + printStackTrace(System.err); + logger.error("FATAL ERROR: duplicate entry: " + element); + throw new RuntimeException("FATAL ERROR: duplicate entry: " + element); + } + stack.push(element); + } + + protected void exit() { + stack.pop(); + } + + public Stack getStack() { + return this.stack; + } + + /** + * Gets the current parent AST node from the stack. + */ + public Visitable getParent() { + return this.stack.get(this.stack.size() - 2); + } + + /** + * Gets the nth level parent AST node from the stack (getParent(1) == + * getParent()). + */ + public Visitable getParent(int level) { + return this.stack.get(this.stack.size() - (level + 1)); + } + + public T getParent(Predicate predicate) { + return getParent(predicate, false); + } + + public T getParent(Class type) { + return getParent(type, false); + } + + @SuppressWarnings("unchecked") + public T getParent(Class type, boolean includeCurrent) { + for (int i = this.stack.size() - (includeCurrent ? 1 : 2); i >= 0; i--) { + if (type.isAssignableFrom(this.stack.get(i).getClass())) { + return (T) this.stack.get(i); + } + } + return null; + } + + public List getParents(Class type) { + List parents = new ArrayList(); + for (int i = this.stack.size() - 1; i >= 0; i--) { + if (type.isAssignableFrom(this.stack.get(i).getClass())) { + @SuppressWarnings("unchecked") + T t = (T) this.stack.get(i); + parents.add(t); + } + } + return parents; + } + + @SuppressWarnings("unchecked") + public List getParents(Predicate predicate) { + List parents = new ArrayList(); + for (int i = this.stack.size() - 1; i >= 0; i--) { + if (predicate.test(this.stack.get(i))) { + T t = (T) this.stack.get(i); + parents.add(t); + } + } + return parents; + } + + @SuppressWarnings("unchecked") + public T getParent(Predicate predicate, boolean includeCurrent) { + for (int i = this.stack.size() - (includeCurrent ? 1 : 2); i >= 0; i--) { + if (predicate.test(this.stack.get(i))) { + return (T) this.stack.get(i); + } + } + return null; + } + + @SuppressWarnings("unchecked") + public T getParent(Class type, Visitable from) { + for (int i = this.stack.size() - 1; i >= 0; i--) { + if (this.stack.get(i) == from) { + for (int j = i - 1; j >= 0; j--) { + if (type.isAssignableFrom(this.stack.get(j).getClass())) { + return (T) this.stack.get(j); + } + } + return null; + } + } + return null; + } + + @SuppressWarnings("unchecked") + public T getParent(Predicate predicate, Visitable from) { + for (int i = this.stack.size() - 1; i >= 0; i--) { + if (this.stack.get(i) == from) { + for (int j = i - 1; j >= 0; j--) { + if (predicate.test(this.stack.get(j))) { + return (T) this.stack.get(j); + } + } + return null; + } + } + return null; + } + + public void scan(Visitable visitable) { + if (visitable != null && !visitable.isHidden()) { + enter(visitable); + try { + visitable.accept(this); + } finally { + exit(); + } + } + } + + public void scan(Visitable[] visitables) { + if (visitables != null) { + for (Visitable visitable : visitables) { + scan(visitable); + } + } + } + + public void scan(List visitables) { + if (visitables != null) { + for (Visitable visitable : visitables) { + scan(visitable); + } + } + } + + @Override + public void visitCompilationUnit(CompilationUnit compilationUnit) { + scan(compilationUnit.getDeclarations()); + } + + @Override + public void visitModuleDeclaration(ModuleDeclaration moduleDeclaration) { + scan(moduleDeclaration.getMembers()); + } + + @Override + public void visitTypeDeclaration(TypeDeclaration typeDeclaration) { + scan(typeDeclaration.getTypeParameters()); + scan(typeDeclaration.getSuperTypes()); + scan(typeDeclaration.getMergedSuperTypes()); + scan(typeDeclaration.getMembers()); + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + scan(functionDeclaration.getTypeParameters()); + scan(functionDeclaration.getType()); + scan(functionDeclaration.getParameters()); + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + scan(variableDeclaration.getType()); + scan(variableDeclaration.getInitializer()); + } + + @Override + public void visitParameterDeclaration(ParameterDeclaration parameterDeclaration) { + scan(parameterDeclaration.getType()); + } + + @Override + public void visitTypeReference(TypeReference typeReference) { + scan(typeReference.getObjectType()); + scan(typeReference.getTypeArguments()); + } + + @Override + public void visitTypeMacro(TypeMacroDeclaration typeMacroDeclaration) { + scan(typeMacroDeclaration.getTypeParameters()); + scan(typeMacroDeclaration.getType()); + } + + @Override + public void visitFunctionalTypeReference(FunctionalTypeReference functionalTypeReference) { + scan(functionalTypeReference.getReturnType()); + scan(functionalTypeReference.getParameters()); + } + + @Override + public void visitArrayTypeReference(ArrayTypeReference arrayTypeReference) { + scan(arrayTypeReference.getComponentType()); + } + + @Override + public void visitUnionTypeReference(UnionTypeReference unionTypeReference) { + switch (unionTypeReference.getSelected()) { + case LEFT: + scan(unionTypeReference.getLeftType()); + break; + case RIGHT: + scan(unionTypeReference.getRightType()); + break; + default: + scan(unionTypeReference.getLeftType()); + scan(unionTypeReference.getRightType()); + } + } + + @Override + public void visitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration) { + scan(typeParameterDeclaration.getUpperBound()); + } + + @Override + public void visitLiteral(Literal literal) { + } + + @Override + public void visitReferenceDeclaration(ReferenceDeclaration referenceDeclaration) { + } +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Token.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Token.java new file mode 100644 index 00000000..92405f43 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Token.java @@ -0,0 +1,80 @@ +package org.jsweet.input.typescriptdef.ast; + +/** + * @author Renaud Pawlak + */ +public class Token { + + public int type; + + /** + * Creates a new token + * + * @param type + * the type as defined in the lexer + * @param fileName + * the name of the file from where the token was extracted + * @param text + * the text of the token + * @param line + * the line number where the token appears in the file + * @param charBegin + * the character where it begins in the file + * @param charEnd + * the character where it ends in the file + */ + public Token(int type, String fileName, String text, int line, + int charBegin, int charEnd) { + + this.type = type; + this.fileName = fileName; + this.text = text; + this.line = line; + this.charBegin = charBegin; + this.charEnd = charEnd; + } + + public String getLocation() { + return "" + fileName + ":" + line + "(" + charBegin + ")"; + } + + String fileName; + String text; + int line; + int charBegin; + int charEnd; + + // public boolean equals(Object o) { + // System.err.println("equals("+this+","+o+")"); + // return text.equals(o.toString()); + // } + + public String toString() { + return text; + } + + public int getCharBegin() { + return charBegin; + } + + public int getCharEnd() { + return charEnd; + } + + public int getLine() { + return line; + } + + public String getText() { + return text; + } + + public String getFileName() { + return fileName; + } + + public int getType() { + return type; + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Type.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Type.java new file mode 100644 index 00000000..51a3aebc --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Type.java @@ -0,0 +1,9 @@ +package org.jsweet.input.typescriptdef.ast; + +public interface Type { + + String getName(); + + boolean isSubtypeOf(Type type); + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypeDeclaration.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypeDeclaration.java new file mode 100644 index 00000000..ccaa3b59 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypeDeclaration.java @@ -0,0 +1,247 @@ +package org.jsweet.input.typescriptdef.ast; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import org.apache.commons.lang3.ArrayUtils; + +public class TypeDeclaration extends AbstractDeclaration + implements Type, TypeParameterizedElement, DeclarationContainer { + + private Declaration[] members; + private TypeReference[] superTypes; + private TypeReference[] mergedSuperTypes; + private TypeParameterDeclaration[] typeParameters; + private String kind; + private String originalKind; + private boolean external = false; + + public static TypeDeclaration createExternalTypeDeclaration(String simpleName) { + return createExternalTypeDeclaration("class", simpleName); + } + + public static TypeDeclaration createExternalTypeDeclaration(String kind, String simpleName) { + TypeDeclaration t = new TypeDeclaration(null, kind, simpleName, null, null, new Declaration[0]); + t.setExternal(true); + return t; + } + + public static TypeDeclaration createTypeDeclaration(String simpleName) { + TypeDeclaration t = new TypeDeclaration(null, "class", simpleName, null, null, new Declaration[0]); + return t; + } + + public TypeDeclaration(Token token, String kind, String name, TypeParameterDeclaration[] typeParameters, + TypeReference[] superTypes, Declaration[] members) { + super(token, name); + this.kind = this.originalKind = kind; + this.typeParameters = typeParameters; + this.setSuperTypes(superTypes); + if (members != null) { + this.members = members; + } else { + this.members = new Declaration[0]; + } + // System.out.println("new TypeDeclaration: " + this); + } + + @Override + public void accept(Visitor v) { + v.visitTypeDeclaration(this); + } + + @Override + public Declaration[] getMembers() { + return members; + } + + @Override + public void addMember(Declaration declaration) { + members = DeclarationHelper.addMember(this, declaration); + } + + @Override + public void removeMember(Declaration declaration) { + members = DeclarationHelper.removeMember(this, declaration); + } + + @Override + public void replaceMember(Declaration existingDeclaration, Declaration withNewDeclaration) { + members = DeclarationHelper.replaceMember(this, existingDeclaration, withNewDeclaration); + } + + @Override + public void clearMembers() { + members = new Declaration[0]; + } + + public TypeReference[] getSuperTypes() { + return superTypes; + } + + public void setSuperTypes(TypeReference[] superTypes) { + this.superTypes = superTypes; + } + + @Override + public TypeParameterDeclaration[] getTypeParameters() { + return this.typeParameters; + } + + @Override + public void setTypeParameters(TypeParameterDeclaration[] typeParameters) { + this.typeParameters = typeParameters; + } + + public FunctionDeclaration findFirstConstructor() { + return DeclarationHelper.findFirstConstructor(this); + } + + public List findConstructors() { + return DeclarationHelper.findConstructors(this); + } + + public boolean isStatic() { + return DeclarationHelper.isStatic(this); + } + + public FunctionDeclaration findFirstFunction(String name) { + return DeclarationHelper.findFirstFunction(this, name); + } + + public List findFunctions(String name) { + return DeclarationHelper.findFunctions(this, name); + } + + public VariableDeclaration findVariable(String name) { + return DeclarationHelper.findVariable(this, name); + } + + @Override + public VariableDeclaration findVariableIgnoreCase(String name) { + return DeclarationHelper.findVariableIgnoreCase(this, name); + } + + @Override + public TypeDeclaration findType(String name) { + return DeclarationHelper.findType(this, name); + } + + @Override + public TypeDeclaration findTypeIgnoreCase(String name) { + return DeclarationHelper.findTypeIgnoreCase(this, name); + } + + @Override + public Declaration findDeclaration(String name) { + return DeclarationHelper.findDeclaration(this, name); + } + + @Override + public void addMembers(Declaration[] declarations) { + DeclarationHelper.addMembers(this, declarations); + } + + @Override + public Declaration findDeclaration(Declaration declaration) { + return DeclarationHelper.findDeclaration(this, declaration); + } + + public String getKind() { + return kind; + } + + public void setKind(String kind) { + this.originalKind = this.kind; + this.kind = kind; + } + + @Override + public TypeDeclaration copy() { + TypeDeclaration copy = new TypeDeclaration(null, getKind(), getName(), + DeclarationHelper.copy(getTypeParameters()), DeclarationHelper.copyReferences(superTypes), + DeclarationHelper.copy(members)); + copy.setDocumentation(getDocumentation()); + copy.setModifiers(this.getModifiers() == null ? null : new HashSet(getModifiers())); + copy.setStringAnnotations( + this.getStringAnnotations() == null ? null : new ArrayList(getStringAnnotations())); + copy.originalKind = this.originalKind; + return copy; + } + + public boolean isExternal() { + boolean external = this.external || (getDocumentation() != null && isInputAnnotatedWith("External")); + return external; + } + + public void setExternal(boolean external) { + this.external = external; + } + + @Override + public boolean isSubtypeOf(Type type) { + if (type == null) { + return false; + } + if (getSuperTypes() != null) { + for (TypeReference tref : getSuperTypes()) { + TypeDeclaration t = (TypeDeclaration) tref.getDeclaration(); + if (type == t) { + return true; + } else { + if (t != null) { + return t.isSubtypeOf(type); + } + } + } + } + return false; + + } + + public boolean isInterface() { + return getKind() != null && getKind().equals("interface"); + } + + public boolean isFunctionalInterface() { + return isInterface() && getMembers().length == 1; + } + + @Override + public String toString() { + if (name != null) { + return super.toString(); + } else { + // print inlined toString (probably an object type) + StringBuilder sb = new StringBuilder(); + sb.append("{"); + for (Declaration d : getMembers()) { + sb.append(d.toString()).append(";"); + } + sb.append("}"); + return sb.toString(); + } + } + + public TypeReference[] getMergedSuperTypes() { + return mergedSuperTypes; + } + + public void setMergedSuperTypes(TypeReference[] mergedSuperTypes) { + this.mergedSuperTypes = mergedSuperTypes; + } + + public void addMergedSuperType(TypeReference mergedSuperType) { + if (this.mergedSuperTypes == null) { + this.mergedSuperTypes = new TypeReference[] { mergedSuperType }; + } else { + this.mergedSuperTypes = ArrayUtils.add(mergedSuperTypes, mergedSuperType); + } + } + + public final String getOriginalKind() { + return originalKind; + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypeMacroDeclaration.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypeMacroDeclaration.java new file mode 100644 index 00000000..ff13f68a --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypeMacroDeclaration.java @@ -0,0 +1,45 @@ +package org.jsweet.input.typescriptdef.ast; + +import java.util.HashSet; + +public class TypeMacroDeclaration extends TypeDeclaration implements TypedDeclaration { + + private TypeReference type; + + public TypeMacroDeclaration(Token token, String aliasName, TypeParameterDeclaration[] typeParameters, TypeReference type) { + super(token, "type", aliasName, typeParameters, null, null); + this.type = type; + } + + @Override + public void accept(Visitor v) { + v.visitTypeMacro(this); + } + + @Override + public TypeMacroDeclaration copy() { + TypeMacroDeclaration copy = new TypeMacroDeclaration(null, getName(), getTypeParameters(), getType()); + copy.setDocumentation(getDocumentation()); + copy.setModifiers(this.getModifiers() == null ? null : new HashSet(getModifiers())); + return copy; + } + + @Override + public boolean isSubtypeOf(Type type) { + if (type == null) { + return false; + } + + return type.isSubtypeOf(getType().getDeclaration()); + } + + @Override + public TypeReference getType() { + return type; + } + + @Override + public void setType(TypeReference type) { + this.type = type; + } +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypeParameterDeclaration.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypeParameterDeclaration.java new file mode 100644 index 00000000..b0ac1186 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypeParameterDeclaration.java @@ -0,0 +1,47 @@ +package org.jsweet.input.typescriptdef.ast; + + +public class TypeParameterDeclaration extends AbstractDeclaration implements Type, TypedDeclaration { + + protected TypeReference upperBound; + + public TypeParameterDeclaration(Token token, String name) { + super(token, name); + } + + @Override + public void accept(Visitor visitor) { + visitor.visitTypeParameterDeclaration(this); + } + + public TypeReference getUpperBound() { + return upperBound; + } + + public void setUpperBound(TypeReference upperBound) { + this.upperBound = upperBound; + } + + @Override + public TypeParameterDeclaration copy() { + TypeParameterDeclaration copy = new TypeParameterDeclaration(null, getName()); + copy.upperBound = upperBound == null ? null : upperBound.copy(); + return copy; + } + + @Override + public void setType(TypeReference type) { + upperBound = type; + } + + @Override + public TypeReference getType() { + return upperBound; + } + + @Override + public boolean isSubtypeOf(Type type) { + return false; + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypeParameterizedElement.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypeParameterizedElement.java new file mode 100644 index 00000000..2b76dcd8 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypeParameterizedElement.java @@ -0,0 +1,9 @@ +package org.jsweet.input.typescriptdef.ast; + +public interface TypeParameterizedElement extends AstNode { + + TypeParameterDeclaration[] getTypeParameters(); + + void setTypeParameters(TypeParameterDeclaration[] typeParameters); + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypeReference.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypeReference.java new file mode 100644 index 00000000..74e746b6 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypeReference.java @@ -0,0 +1,231 @@ +package org.jsweet.input.typescriptdef.ast; + +import org.apache.commons.lang3.StringUtils; +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.util.Util; + +public class TypeReference extends AbstractAstNode implements NamedElement { + + protected TypeReference[] typeArguments; + protected String name; + protected TypeDeclaration objectType; + // cache to the declaration + transient private Type declaration; + private boolean typeOf = false; + + public boolean isTypeOf() { + return typeOf; + } + + public void setTypeOf(boolean typeOf) { + this.typeOf = typeOf; + } + + public TypeReference(Token token, String name, TypeReference[] typeArguments) { + super(token); + if ("$tuple$".equals(name)) { + name = JSweetDefTranslatorConfig.TUPLE_CLASSES_PACKAGE + "." + + JSweetDefTranslatorConfig.TUPLE_CLASSES_PREFIX + typeArguments.length; + } + this.name = name; + this.typeArguments = typeArguments; + } + + public TypeReference(Token token, Type type, TypeReference[] typeArguments) { + super(token); + this.name = type.getName(); + this.typeArguments = typeArguments; + this.declaration = type; + } + + public TypeReference(Token token, Declaration[] members) { + super(token); + this.objectType = new TypeDeclaration(token, "object_type", null, null, null, members); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + if (objectType != null) { + sb.append(objectType.toString()); + } else { + sb.append(name); + if (typeArguments != null && typeArguments.length > 0) { + sb.append("<"); + for (TypeReference t : typeArguments) { + sb.append(t); + sb.append(","); + } + sb.deleteCharAt(sb.length() - 1); + sb.append(">"); + } + } + return sb.toString(); + } + + @Override + public void accept(Visitor visitor) { + visitor.visitTypeReference(this); + } + + public TypeReference[] getTypeArguments() { + return this.typeArguments; + } + + public void setTypeArguments(TypeReference[] typeArguments) { + this.typeArguments = typeArguments; + } + + @Override + public String getName() { + return name; + } + + @Override + public void setName(String name) { + this.name = name; + } + + public boolean isObjectType() { + return objectType != null; + } + + public TypeDeclaration getObjectType() { + return objectType; + } + + @Override + public boolean isAnonymous() { + return name == null; + } + + public boolean isStringType() { + return name != null && (name.startsWith("\"") && name.endsWith("\"")); + } + + public boolean isPrimitive() { + return DeclarationHelper.isPrimitiveType(name); + } + + public String getWrappingTypeName() { + if ("any".equals(name)) { + return "java.lang.Object"; + } else if (isPrimitive()) { + return StringUtils.capitalize(name); + } else { + return name; + } + } + + public String getSimpleName() { + return Util.getSimpleName(name); + } + + public String getQualifier() { + return Util.getQualifier(name); + } + + public boolean isQualified() { + return Util.isQualified(name); + } + + @Override + public boolean equals(Object obj) { + if (!obj.getClass().equals(getClass())) { + return false; + } + TypeReference tr = (TypeReference) obj; + if (name == null && tr.name == null) { + if (objectType != null && tr.objectType != null) { + return DeclarationHelper.areDeclarationsEqual(objectType.getMembers(), tr.objectType.getMembers()); + } + return false; + } + + if (name == null && tr.name != null) { + return false; + } + if (!name.equals(tr.name)) { + return false; + } + return true; + } + + public TypeReference copy(boolean copyDeclarations) { + TypeReference copy = new TypeReference(null, getName(), DeclarationHelper.copyReferences(typeArguments, copyDeclarations)); + if (objectType != null) { + copy.objectType = objectType.copy(); + } + if (copyDeclarations) { + copy.declaration = declaration; + } + return copy; + } + + public TypeReference copy() { + return copy(false); + } + + public Type getDeclaration() { + return declaration; + } + + public void setDeclaration(Type type) { + this.declaration = type; + } + + public boolean isArray() { + return false; + } + + public TypeReference getComponentType() { + return this; + } + + public boolean isSubtypeOf(TypeReference type) { + if (declaration == null) { + throw new RuntimeException("unattributed type reference: " + this); + } + if (!type.isArray() && type.declaration == null) { + throw new RuntimeException("unattributed type reference: " + type); + } + return declaration.isSubtypeOf(type.declaration); + } + + /** + * Substitutes a type reference if found in the node. + * + * @param targetType + * the type reference to be substituted, if found in the node + * @param newType + * the new type reference that will be substituted to target type + * @return true if the target type was found and substituted + */ + public boolean substituteTypeReference(TypeReference targetType, TypeReference newType) { + if (typeArguments != null) { + for (int i = 0; i < typeArguments.length; i++) { + if (typeArguments[i] == targetType) { + typeArguments[i] = newType; + return true; + } + } + } + return false; + } + + @Override + public String getOriginalName() { + return name; + } + + @Override + public void setOriginalName(String name) { + this.name = name; + } + + public boolean isTuple() { + return name != null && name.startsWith( + JSweetDefTranslatorConfig.TUPLE_CLASSES_PACKAGE + "." + JSweetDefTranslatorConfig.TUPLE_CLASSES_PREFIX); + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypedDeclaration.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypedDeclaration.java new file mode 100644 index 00000000..03c230f6 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/TypedDeclaration.java @@ -0,0 +1,10 @@ +package org.jsweet.input.typescriptdef.ast; + +public interface TypedDeclaration extends Declaration { + + TypeReference getType(); + + void setType(TypeReference type); + + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/UnionTypeReference.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/UnionTypeReference.java new file mode 100644 index 00000000..dcd9bffd --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/UnionTypeReference.java @@ -0,0 +1,352 @@ +package org.jsweet.input.typescriptdef.ast; + +import java.util.LinkedList; +import java.util.List; + +public class UnionTypeReference extends TypeReference { + + public enum Selected { + NONE, PENDING, LEFT, RIGHT; + public Selected inverse() { + switch (this) { + case LEFT: + return RIGHT; + case RIGHT: + return LEFT; + default: + return NONE; + } + } + } + + private TypeReference leftType; + private TypeReference rightType; + private Selected selected = Selected.NONE; + private boolean intersection = false; + + public UnionTypeReference(Token token, TypeReference leftType, TypeReference rightType) { + this(token, leftType, rightType, false); + } + + public UnionTypeReference(Token token, TypeReference leftType, TypeReference rightType, boolean intersection) { + super(token, intersection ? "&" : "|", null); + setLeftType(leftType); + setRightType(rightType); + } + + @Override + public void accept(Visitor visitor) { + visitor.visitUnionTypeReference(this); + } + + public TypeReference getLeftType() { + return leftType; + } + + public void setLeftType(TypeReference leftType) { + this.leftType = leftType; + if (leftType != null && leftType.getName() != null && leftType.getName().equals("void")) { + selected = Selected.RIGHT; + } + } + + public TypeReference getRightType() { + return rightType; + } + + public void setRightType(TypeReference rightType) { + this.rightType = rightType; + if (rightType != null && rightType.getName() != null && rightType.getName().equals("void")) { + selected = Selected.LEFT; + } + } + + @Override + public UnionTypeReference copy(boolean copyDeclarations) { + UnionTypeReference copy = new UnionTypeReference(null, leftType.copy(copyDeclarations), + rightType.copy(copyDeclarations)); + copy.typeArguments = DeclarationHelper.copyReferences(typeArguments, copyDeclarations); + copy.selected = this.selected; + return copy; + } + + @Override + public UnionTypeReference copy() { + return copy(false); + } + + @Override + public String toString() { + switch (selected) { + case LEFT: + return leftType.toString(); + case RIGHT: + return rightType.toString(); + case PENDING: + return leftType.toString() + " |? " + rightType.toString(); + default: + return leftType.toString() + " | " + rightType.toString(); + } + } + + public Selected getSelected() { + // if (leftT) + + return selected; + } + + public void setSelected(Selected selected) { + this.selected = selected; + } + + public TypeReference getOperand(Selected selected) { + switch (selected) { + case LEFT: + return leftType; + case RIGHT: + return rightType; + default: + return null; + } + } + + public TypeReference getSelectedType() { + switch (selected) { + case LEFT: + return leftType; + case RIGHT: + return rightType; + default: + return null; + } + } + + public List getTypes() { + List types = new LinkedList<>(); + TypeReference selectedType = getSelectedType(); + if (selectedType != null) { + if (selectedType instanceof UnionTypeReference) { + types.addAll(((UnionTypeReference) selectedType).getTypes()); + } else { + types.add(selectedType); + } + } else { + // add both types if union hasn't been resolved + if (leftType instanceof UnionTypeReference) { + types.addAll(((UnionTypeReference) leftType).getTypes()); + } else { + types.add(leftType); + } + + if (rightType instanceof UnionTypeReference) { + types.addAll(((UnionTypeReference) rightType).getTypes()); + } else { + types.add(rightType); + } + } + + return types; + } + + @Override + public Type getDeclaration() { + switch (selected) { + case LEFT: + return leftType.getDeclaration(); + case RIGHT: + return rightType.getDeclaration(); + default: + return super.getDeclaration(); + } + } + + @Override + public String getName() { + switch (selected) { + case LEFT: + return leftType.getName(); + case RIGHT: + return rightType.getName(); + default: + return super.getName(); + } + } + + @Override + public String getSimpleName() { + switch (selected) { + case LEFT: + return leftType.getSimpleName(); + case RIGHT: + return rightType.getSimpleName(); + default: + return super.getSimpleName(); + } + } + + @Override + public TypeDeclaration getObjectType() { + switch (selected) { + case LEFT: + return leftType.getObjectType(); + case RIGHT: + return rightType.getObjectType(); + default: + return super.getObjectType(); + } + } + + @Override + public TypeReference[] getTypeArguments() { + switch (selected) { + case LEFT: + return leftType.getTypeArguments(); + case RIGHT: + return rightType.getTypeArguments(); + default: + return super.getTypeArguments(); + } + } + + @Override + public String getWrappingTypeName() { + switch (selected) { + case LEFT: + return leftType.getWrappingTypeName(); + case RIGHT: + return rightType.getWrappingTypeName(); + default: + return super.getWrappingTypeName(); + } + } + + @Override + public boolean isAnonymous() { + switch (selected) { + case LEFT: + return leftType.isAnonymous(); + case RIGHT: + return rightType.isAnonymous(); + default: + return super.isAnonymous(); + } + } + + @Override + public boolean isHidden() { + switch (selected) { + case LEFT: + return leftType.isHidden(); + case RIGHT: + return rightType.isHidden(); + default: + return super.isHidden(); + } + } + + @Override + public boolean isObjectType() { + switch (selected) { + case LEFT: + return leftType.isObjectType(); + case RIGHT: + return rightType.isObjectType(); + default: + return super.isObjectType(); + } + } + + @Override + public boolean isPrimitive() { + switch (selected) { + case LEFT: + return leftType.isPrimitive(); + case RIGHT: + return rightType.isPrimitive(); + default: + return super.isPrimitive(); + } + } + + @Override + public boolean isStringType() { + switch (selected) { + case LEFT: + return leftType.isStringType(); + case RIGHT: + return rightType.isStringType(); + default: + return super.isStringType(); + } + } + + @Override + public boolean isArray() { + switch (selected) { + case LEFT: + return leftType.isArray(); + case RIGHT: + return rightType.isArray(); + default: + return super.isArray(); + } + } + + @Override + public TypeReference getComponentType() { + switch (selected) { + case LEFT: + return leftType.getComponentType(); + case RIGHT: + return rightType.getComponentType(); + default: + return super.getComponentType(); + } + } + + @Override + public boolean isSubtypeOf(TypeReference type) { + switch (selected) { + case LEFT: + return leftType.isSubtypeOf(type); + case RIGHT: + return rightType.isSubtypeOf(type); + default: + return super.isSubtypeOf(type); + } + } + + @Override + public boolean substituteTypeReference(TypeReference targetType, TypeReference newType) { + if (getLeftType() == targetType) { + setLeftType(newType); + return true; + } + if (getRightType() == targetType) { + setRightType(newType); + return true; + } + return false; + } + + @Override + public boolean equals(Object obj) { + switch (selected) { + case LEFT: + return leftType.equals(obj); + case RIGHT: + return rightType.equals(obj); + default: + return super.equals(obj); + } + } + + public boolean isIntersection() { + return intersection; + } + + public void setIntersection(boolean intersection) { + this.intersection = intersection; + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/VariableDeclaration.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/VariableDeclaration.java new file mode 100644 index 00000000..3a131989 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/VariableDeclaration.java @@ -0,0 +1,59 @@ +package org.jsweet.input.typescriptdef.ast; + +import java.util.ArrayList; +import java.util.HashSet; + +public class VariableDeclaration extends AbstractTypedDeclaration { + + private boolean optional = false; + private boolean readonly = false; + private Literal initializer = null; + + public VariableDeclaration(Token token, String name, TypeReference type, boolean optional, boolean readonly) { + super(token, name, type); + this.optional = optional; + this.readonly = readonly; + // System.out.println("new VariableDeclaration: " + this); + } + + @Override + public void accept(Visitor v) { + v.visitVariableDeclaration(this); + } + + public boolean isOptional() { + return optional; + } + + public void setOptional(boolean optional) { + this.optional = optional; + } + + @Override + public VariableDeclaration copy() { + VariableDeclaration copy = new VariableDeclaration(null, name, getType().copy(), optional, readonly); + copy.setModifiers(this.getModifiers() == null ? null : new HashSet(this.getModifiers())); + copy.setStringAnnotations( + this.getStringAnnotations() == null ? null : new ArrayList(getStringAnnotations())); + copy.setDocumentation(this.getDocumentation()); + copy.setInitializer(initializer == null ? null : initializer.copy()); + return copy; + } + + public Literal getInitializer() { + return initializer; + } + + public void setInitializer(Literal initializer) { + this.initializer = initializer; + } + + public final boolean isReadonly() { + return readonly; + } + + public final void setReadonly(boolean readonly) { + this.readonly = readonly; + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Visitable.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Visitable.java new file mode 100644 index 00000000..21c187f1 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Visitable.java @@ -0,0 +1,12 @@ +package org.jsweet.input.typescriptdef.ast; + + +public interface Visitable { + + void setHidden(boolean hidden); + + boolean isHidden(); + + void accept(Visitor visitor); + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Visitor.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Visitor.java new file mode 100644 index 00000000..791bf044 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/ast/Visitor.java @@ -0,0 +1,33 @@ +package org.jsweet.input.typescriptdef.ast; + + +public interface Visitor { + + void visitCompilationUnit(CompilationUnit compilationUnit); + + void visitModuleDeclaration(ModuleDeclaration moduleDeclaration); + + void visitReferenceDeclaration(ReferenceDeclaration referenceDeclaration); + + void visitTypeDeclaration(TypeDeclaration typeDeclaration); + + void visitFunctionDeclaration(FunctionDeclaration functionDeclaration); + + void visitVariableDeclaration(VariableDeclaration variableDeclaration); + + void visitParameterDeclaration(ParameterDeclaration parameterDeclaration); + + void visitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration); + + void visitTypeReference(TypeReference typeReference); + + void visitFunctionalTypeReference(FunctionalTypeReference functionalTypeReference); + + void visitArrayTypeReference(ArrayTypeReference arrayTypeReference); + + void visitUnionTypeReference(UnionTypeReference unionTypeReference); + + void visitLiteral(Literal literal); + + void visitTypeMacro(TypeMacroDeclaration typeMacroDeclaration); +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/GenParser.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/GenParser.java new file mode 100644 index 00000000..6ea56369 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/GenParser.java @@ -0,0 +1,11 @@ +package org.jsweet.input.typescriptdef.parser; + +public class GenParser { + + public static void main(String[] args) throws Exception { + java_cup.Main.main(new String[] { "-expect", "0", "-package", "org.jsweet.input.typescriptdef.parser", "-expect", "0", "-parser", "TypescriptDefParser", + "typescriptdef.cup" }); + JFlex.Main.main(new String[] { "typescriptdef.lex" }); + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/SyntaxError.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/SyntaxError.java new file mode 100644 index 00000000..867b09c2 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/SyntaxError.java @@ -0,0 +1,34 @@ +package org.jsweet.input.typescriptdef.parser; + +import java.io.PrintStream; + +import org.jsweet.input.typescriptdef.ast.Token; + +public class SyntaxError { + + public Token origin; + public String message; + public Exception exception; + + public SyntaxError(Token origin, String message) { + super(); + this.origin = origin; + this.message = message; + this.exception = new Exception(); + //this.exception.printStackTrace(); + } + + @Override + public String toString() { + return "SYNTAX ERROR" + + ": " + + message + + (origin != null ? " at '" + origin.toString() + "'" + " " + + origin.getLocation() : ""); + } + + public void printStackTrace(PrintStream stream) { + exception.printStackTrace(stream); + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/TestParser.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/TestParser.java new file mode 100644 index 00000000..1f015f11 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/TestParser.java @@ -0,0 +1,11 @@ +package org.jsweet.input.typescriptdef.parser; + +import java.io.File; + +public class TestParser { + + public static void main(String[] args) throws Exception { + TypescriptDefParser.parseFile(new File("test.d.ts")); + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/TypescriptDefParser.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/TypescriptDefParser.java new file mode 100644 index 00000000..caaf7ac0 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/TypescriptDefParser.java @@ -0,0 +1,3291 @@ + +//---------------------------------------------------- +// The following code was generated by CUP v0.10k +// Sun Jul 24 16:44:06 CEST 2016 +//---------------------------------------------------- + +package org.jsweet.input.typescriptdef.parser; + +import java.util.*; +import java.io.*; +import org.apache.commons.lang3.*; +import org.jsweet.input.typescriptdef.ast.*; + +/** CUP v0.10k generated parser. + * @version Sun Jul 24 16:44:06 CEST 2016 + */ +@SuppressWarnings("all") +public class TypescriptDefParser extends java_cup.runtime.lr_parser { + + /** Default constructor. */ + public TypescriptDefParser() {super();} + + /** Constructor which sets the default scanner. */ + public TypescriptDefParser(java_cup.runtime.Scanner s) {super(s);} + + /** Production table. */ + protected static final short _production_table[][] = + unpackFromStrings(new String[] { + "\000\257\000\002\002\004\000\002\003\003\000\002\004" + + "\005\000\002\004\003\000\002\005\005\000\002\005\003" + + "\000\002\006\003\000\002\006\003\000\002\007\003\000" + + "\002\007\003\000\002\010\003\000\002\010\003\000\002" + + "\010\003\000\002\010\003\000\002\010\003\000\002\010" + + "\003\000\002\010\003\000\002\010\003\000\002\021\006" + + "\000\002\021\007\000\002\114\006\000\002\114\003\000" + + "\002\115\003\000\002\115\005\000\002\111\003\000\002" + + "\111\002\000\002\022\005\000\002\065\007\000\002\065" + + "\005\000\002\065\010\000\002\011\010\000\002\011\010" + + "\000\002\012\015\000\002\012\014\000\002\063\003\000" + + "\002\063\002\000\002\113\003\000\002\113\002\000\002" + + "\035\012\000\002\035\013\000\002\037\005\000\002\037" + + "\003\000\002\036\006\000\002\036\003\000\002\036\005" + + "\000\002\036\006\000\002\036\007\000\002\040\003\000" + + "\002\040\003\000\002\041\005\000\002\041\003\000\002" + + "\042\003\000\002\042\005\000\002\110\003\000\002\013" + + "\003\000\002\013\003\000\002\074\004\000\002\074\002" + + "\000\002\075\005\000\002\075\002\000\002\104\006\000" + + "\002\104\003\000\002\030\005\000\002\030\003\000\002" + + "\076\004\000\002\076\003\000\002\101\003\000\002\101" + + "\002\000\002\077\004\000\002\077\003\000\002\077\003" + + "\000\002\100\003\000\002\100\002\000\002\102\004\000" + + "\002\102\003\000\002\102\004\000\002\102\003\000\002" + + "\102\003\000\002\103\003\000\002\103\002\000\002\031" + + "\005\000\002\031\003\000\002\032\003\000\002\032\003" + + "\000\002\033\003\000\002\033\003\000\002\105\005\000" + + "\002\105\004\000\002\106\003\000\002\106\002\000\002" + + "\107\003\000\002\107\002\000\002\034\003\000\002\034" + + "\003\000\002\034\003\000\002\034\003\000\002\015\011" + + "\000\002\015\010\000\002\112\003\000\002\112\003\000" + + "\002\014\010\000\002\014\007\000\002\014\007\000\002" + + "\014\007\000\002\026\003\000\002\026\002\000\002\016" + + "\012\000\002\016\013\000\002\016\012\000\002\017\010" + + "\000\002\017\011\000\002\020\010\000\002\020\011\000" + + "\002\023\005\000\002\023\003\000\002\024\007\000\002" + + "\024\003\000\002\025\012\000\002\027\003\000\002\027" + + "\002\000\002\043\003\000\002\043\002\000\002\044\007" + + "\000\002\045\003\000\002\045\003\000\002\045\003\000" + + "\002\045\003\000\002\045\003\000\002\045\003\000\002" + + "\045\003\000\002\045\003\000\002\045\003\000\002\047" + + "\006\000\002\047\005\000\002\050\006\000\002\050\005" + + "\000\002\054\004\000\002\060\005\000\002\051\004\000" + + "\002\051\004\000\002\051\004\000\002\051\006\000\002" + + "\051\004\000\002\051\006\000\002\052\010\000\002\052" + + "\011\000\002\052\005\000\002\055\005\000\002\055\005" + + "\000\002\056\004\000\002\056\006\000\002\057\005\000" + + "\002\057\007\000\002\061\003\000\002\061\003\000\002" + + "\061\003\000\002\061\003\000\002\061\003\000\002\061" + + "\004\000\002\061\004\000\002\061\003\000\002\061\004" + + "\000\002\061\002\000\002\064\003\000\002\064\005\000" + + "\002\071\005\000\002\071\002\000\002\072\005\000\002" + + "\072\003\000\002\066\005\000\002\066\002\000\002\067" + + "\005\000\002\067\003\000\002\070\003\000\002\070\005" + + "" }); + + /** Access to production table. */ + public short[][] production_table() {return _production_table;} + + /** Parse-action table. */ + protected static final short[][] _action_table = + unpackFromStrings(new String[] { + "\000\u015c\000\066\002\uffbe\003\uffbe\036\uffbe\051\uffbe\055" + + "\uffbe\060\uffbe\061\uffbe\062\uffbe\063\uffbe\064\uffbe\065\uffbe" + + "\066\uffbe\067\uffbe\070\uffbe\071\uffbe\072\uffbe\073\uffbe\074" + + "\uffbe\075\uffbe\076\uffbe\077\uffbe\102\uffbe\103\uffbe\105\uffbe" + + "\111\uffbe\112\006\001\002\000\004\002\000\001\002\000" + + "\122\002\uffbf\003\uffbf\004\uffbf\005\uffbf\010\uffbf\011\uffbf" + + "\012\uffbf\013\uffbf\014\uffbf\015\uffbf\016\uffbf\017\uffbf\021" + + "\uffbf\036\uffbf\051\uffbf\055\uffbf\060\uffbf\061\uffbf\062\uffbf" + + "\063\uffbf\064\uffbf\065\uffbf\066\uffbf\067\uffbf\070\uffbf\071" + + "\uffbf\072\uffbf\073\uffbf\074\uffbf\075\uffbf\076\uffbf\077\uffbf" + + "\102\uffbf\103\uffbf\104\uffbf\105\uffbf\111\uffbf\112\250\113" + + "\uffbf\114\uffbf\001\002\000\122\002\uffc0\003\uffc0\004\uffc0" + + "\005\uffc0\010\uffc0\011\uffc0\012\uffc0\013\uffc0\014\uffc0\015" + + "\uffc0\016\uffc0\017\uffc0\021\uffc0\036\uffc0\051\uffc0\055\uffc0" + + "\060\uffc0\061\uffc0\062\uffc0\063\uffc0\064\uffc0\065\uffc0\066" + + "\uffc0\067\uffc0\070\uffc0\071\uffc0\072\uffc0\073\uffc0\074\uffc0" + + "\075\uffc0\076\uffc0\077\uffc0\102\uffc0\103\uffc0\104\uffc0\105" + + "\uffc0\111\uffc0\112\uffc0\113\uffc0\114\uffc0\001\002\000\004" + + "\002\u015e\001\002\000\066\002\ufffe\003\033\015\ufffe\036" + + "\015\051\uff5f\055\uff5f\060\uffe8\061\035\062\uff5f\063\020" + + "\064\031\065\024\066\uff5f\067\041\070\023\071\036\072" + + "\uff5f\073\uff5f\074\032\075\uff5f\076\uff5f\077\uff5f\102\uff5f" + + "\103\026\105\uff5f\111\uff5f\001\002\000\012\002\ufff4\011" + + "\ufff4\015\ufff4\112\ufff4\001\002\000\012\002\ufffb\011\ufffb" + + "\015\ufffb\112\ufffb\001\002\000\004\060\u0150\001\002\000" + + "\012\002\ufff7\011\ufff7\015\ufff7\112\ufff7\001\002\000\012" + + "\002\ufff8\011\ufff8\015\ufff8\112\ufff8\001\002\000\012\002" + + "\ufff5\011\ufff5\015\ufff5\112\ufff5\001\002\000\012\002\ufff6" + + "\011\ufff6\015\ufff6\112\ufff6\001\002\000\042\012\uff65\016" + + "\uff65\021\uff65\051\uff65\055\uff65\062\uff65\066\uff65\072\uff65" + + "\073\uff65\075\uff65\076\uff65\077\uff65\102\uff65\103\u014f\105" + + "\uff65\111\uff65\001\002\000\012\002\ufff9\011\ufff9\015\ufff9" + + "\112\ufff9\001\002\000\012\002\ufff0\011\ufff0\015\ufff0\112" + + "\ufff0\001\002\000\004\055\271\001\002\000\042\012\uff61" + + "\016\uff61\021\uff61\051\uff61\055\uff61\062\uff61\066\uff61\072" + + "\uff61\073\uff61\075\uff61\076\uff61\077\uff61\102\uff61\103\u0149" + + "\105\uff61\111\uff61\001\002\000\012\002\ufff3\011\ufff3\015" + + "\ufff3\112\ufff3\001\002\000\040\012\uff66\016\uff66\021\uff66" + + "\051\uff66\055\uff66\062\uff66\066\uff66\072\uff66\073\uff66\075" + + "\uff66\076\uff66\077\uff66\102\uff66\105\uff66\111\uff66\001\002" + + "\000\012\002\ufff1\011\ufff1\015\ufff1\112\ufff1\001\002\000" + + "\012\002\uffb9\011\u0146\015\uffb9\112\006\001\002\000\042" + + "\012\uff64\016\uff64\021\uff64\051\uff64\055\uff64\062\uff64\066" + + "\uff64\072\uff64\073\uff64\075\uff64\076\uff64\077\uff64\102\uff64" + + "\103\u0142\105\uff64\111\uff64\001\002\000\004\055\u013d\001" + + "\002\000\012\002\ufffa\011\ufffa\015\ufffa\112\ufffa\001\002" + + "\000\012\002\ufff2\011\ufff2\015\ufff2\112\ufff2\001\002\000" + + "\042\014\u012a\025\u012c\051\uff68\055\uff68\060\uffe9\062\uff68" + + "\066\uff68\072\uff68\073\uff68\074\u012b\075\uff68\076\uff68\077" + + "\uff68\102\uff68\105\uff68\111\uff68\001\002\000\004\055\u0123" + + "\001\002\000\032\051\043\055\052\062\053\066\044\072" + + "\054\073\045\075\uffdc\076\uffdc\077\051\102\046\105\055" + + "\111\uffde\001\002\000\012\002\ufffc\011\ufffc\015\ufffc\112" + + "\ufffc\001\002\000\040\012\uff67\016\uff67\021\uff67\051\uff67" + + "\055\uff67\062\uff67\066\uff67\072\uff67\073\uff67\075\uff67\076" + + "\uff67\077\uff67\102\uff67\105\uff67\111\uff67\001\002\000\004" + + "\111\u011c\001\002\000\020\002\uff98\004\uff98\005\uff98\011" + + "\uff98\015\uff98\056\143\112\uff98\001\002\000\006\075\uffdd" + + "\076\uffdd\001\002\000\004\055\373\001\002\000\016\002" + + "\uff98\004\uff98\011\uff98\015\uff98\056\143\112\uff98\001\002" + + "\000\006\075\360\076\361\001\002\000\004\055\354\001" + + "\002\000\004\055\uff9f\001\002\000\024\002\uff98\004\uff98" + + "\011\uff98\012\uff98\015\uff98\021\uff98\055\271\056\143\112" + + "\uff98\001\002\000\004\055\340\001\002\000\004\055\056" + + "\001\002\000\006\055\uff9e\111\uffdf\001\002\000\014\014" + + "\uff57\021\057\100\uff57\101\uff57\112\uff57\001\002\000\022" + + "\012\072\014\105\016\110\021\057\055\070\102\103\104" + + "\076\113\uff57\001\002\000\012\014\uffc8\100\061\101\uffc8" + + "\112\uffc8\001\002\000\022\012\072\014\105\016\110\021" + + "\057\055\070\102\103\104\076\113\uff57\001\002\000\010" + + "\014\uffc6\101\064\112\uffc6\001\002\000\006\014\uffbe\112" + + "\006\001\002\000\024\012\uffbe\014\uffbe\016\uffbe\021\uffbe" + + "\055\uffbe\102\uffbe\104\uffbe\112\006\113\uffbe\001\002\000" + + "\022\012\072\014\105\016\110\021\057\055\070\102\103" + + "\104\076\113\uff57\001\002\000\040\002\uff85\005\uff85\011" + + "\uff85\013\uff85\014\uff85\015\uff85\017\uff85\024\uff85\036\uff85" + + "\042\uff85\044\uff85\100\uff85\101\uff85\112\uff85\114\uff85\001" + + "\002\000\020\005\uffc4\014\uffc4\017\uffc4\042\116\044\117" + + "\101\uffc4\112\uffc4\001\002\000\050\002\uff5e\005\uff5e\006" + + "\272\011\uff5e\013\uff5e\014\uff5e\015\uff5e\017\uff5e\020\uff5e" + + "\021\uff5e\024\uff5e\036\uff5e\042\uff5e\044\uff5e\100\uff5e\101" + + "\uff5e\106\321\112\uff5e\114\uff5e\001\002\000\042\002\uff7e" + + "\005\uff7e\011\uff7e\013\uff7e\014\uff7e\015\uff7e\017\uff7e\020" + + "\320\024\uff7e\036\uff7e\042\uff7e\044\uff7e\100\uff7e\101\uff7e" + + "\112\uff7e\114\uff7e\001\002\000\022\012\072\014\105\016" + + "\110\021\057\055\277\102\103\104\302\113\uff57\001\002" + + "\000\042\002\uff81\005\uff81\011\uff81\013\uff81\014\uff81\015" + + "\uff81\017\uff81\020\275\024\uff81\036\uff81\042\uff81\044\uff81" + + "\100\uff81\101\uff81\112\uff81\114\uff81\001\002\000\040\002" + + "\uff86\005\uff86\011\uff86\013\uff86\014\uff86\015\uff86\017\uff86" + + "\024\uff86\036\uff86\042\uff86\044\uff86\100\uff86\101\uff86\112" + + "\uff86\114\uff86\001\002\000\042\002\uff7f\005\uff7f\011\uff7f" + + "\013\uff7f\014\uff7f\015\uff7f\017\uff7f\020\274\024\uff7f\036" + + "\uff7f\042\uff7f\044\uff7f\100\uff7f\101\uff7f\112\uff7f\114\uff7f" + + "\001\002\000\004\055\271\001\002\000\040\002\uff82\005" + + "\uff82\011\uff82\013\uff82\014\uff82\015\uff82\017\uff82\024\uff82" + + "\036\uff82\042\uff82\044\uff82\100\uff82\101\uff82\112\uff82\114" + + "\uff82\001\002\000\040\002\uff84\005\uff84\011\uff84\013\uff84" + + "\014\uff84\015\uff84\017\uff84\024\uff84\036\uff84\042\uff84\044" + + "\uff84\100\uff84\101\uff84\112\uff84\114\uff84\001\002\000\044" + + "\002\uff5b\005\uff5b\011\uff5b\013\uff5b\014\uff5b\015\uff5b\017" + + "\uff5b\020\uff5b\021\261\024\uff5b\036\uff5b\042\uff5b\044\uff5b" + + "\100\uff5b\101\uff5b\112\uff5b\114\uff5b\001\002\000\010\005" + + "\112\014\uffc7\112\uffc7\001\002\000\006\021\057\113\uff57" + + "\001\002\000\040\002\uff83\005\uff83\011\uff83\013\uff83\014" + + "\uff83\015\uff83\017\uff83\024\uff83\036\uff83\042\uff83\044\uff83" + + "\100\uff83\101\uff83\112\uff83\114\uff83\001\002\000\052\003" + + "\uffbe\012\uffbe\015\uffbe\016\uffbe\021\uffbe\036\uffbe\051\uffbe" + + "\055\uffbe\061\uffbe\062\uffbe\063\uffbe\064\uffbe\065\uffbe\067" + + "\uffbe\071\uffbe\077\uffbe\102\uffbe\103\uffbe\105\uffbe\112\006" + + "\001\002\000\042\002\uff80\005\uff80\011\uff80\013\uff80\014" + + "\uff80\015\uff80\017\uff80\020\161\024\uff80\036\uff80\042\uff80" + + "\044\uff80\100\uff80\101\uff80\112\uff80\114\uff80\001\002\000" + + "\004\113\124\001\002\000\022\012\072\014\105\016\110" + + "\021\057\055\070\102\103\104\076\113\uff57\001\002\000" + + "\006\005\112\017\113\001\002\000\024\012\uffbe\014\uffbe" + + "\016\uffbe\021\uffbe\055\uffbe\102\uffbe\104\uffbe\112\006\113" + + "\uffbe\001\002\000\042\002\uff78\005\uff78\011\uff78\013\uff78" + + "\014\uff78\015\uff78\017\uff78\020\uff78\024\uff78\036\uff78\042" + + "\uff78\044\uff78\100\uff78\101\uff78\112\uff78\114\uff78\001\002" + + "\000\022\012\072\014\105\016\110\021\057\055\070\102" + + "\103\104\076\113\uff57\001\002\000\020\005\uffc5\014\uffc5" + + "\017\uffc5\042\116\044\117\101\uffc5\112\uffc5\001\002\000" + + "\024\012\uffbe\014\uffbe\016\uffbe\021\uffbe\055\uffbe\102\uffbe" + + "\104\uffbe\112\006\113\uffbe\001\002\000\024\012\uffbe\014" + + "\uffbe\016\uffbe\021\uffbe\055\uffbe\102\uffbe\104\uffbe\112\006" + + "\113\uffbe\001\002\000\022\012\072\014\105\016\110\021" + + "\057\055\070\102\103\104\076\113\uff57\001\002\000\040" + + "\002\uff7d\005\uff7d\011\uff7d\013\uff7d\014\uff7d\015\uff7d\017" + + "\uff7d\024\uff7d\036\uff7d\042\uff7d\044\uff7d\100\uff7d\101\uff7d" + + "\112\uff7d\114\uff7d\001\002\000\022\012\072\014\105\016" + + "\110\021\057\055\070\102\103\104\076\113\uff57\001\002" + + "\000\040\002\uff7b\005\uff7b\011\uff7b\013\uff7b\014\uff7b\015" + + "\uff7b\017\uff7b\024\uff7b\036\uff7b\042\uff7b\044\uff7b\100\uff7b" + + "\101\uff7b\112\uff7b\114\uff7b\001\002\000\014\010\uffbe\036" + + "\uffbe\055\uffbe\112\006\114\uffbe\001\002\000\016\010\uffa6" + + "\013\uff8f\036\134\055\uffa6\112\uffa6\114\uff8f\001\002\000" + + "\004\114\127\001\002\000\004\045\130\001\002\000\022" + + "\012\072\014\105\016\110\021\057\055\070\102\103\104" + + "\076\113\uff57\001\002\000\040\002\uff71\005\uff71\011\uff71" + + "\013\uff71\014\uff71\015\uff71\017\uff71\024\uff71\036\uff71\042" + + "\116\044\117\100\uff71\101\uff71\112\uff71\114\uff71\001\002" + + "\000\012\005\uffbe\013\uffbe\112\006\114\uffbe\001\002\000" + + "\010\010\uffbe\055\uffbe\112\006\001\002\000\036\005\uffa7" + + "\010\uffa7\012\uffa7\013\uffa7\014\uffa7\016\uffa7\017\uffa7\021" + + "\uffa7\055\uffa7\102\uffa7\104\uffa7\112\uffa7\113\uffa7\114\uffa7" + + "\001\002\000\012\005\uff8d\013\uff8d\112\uff8d\114\uff8d\001" + + "\002\000\006\010\137\055\uff8a\001\002\000\004\055\uff8b" + + "\001\002\000\004\055\141\001\002\000\022\004\uff98\005" + + "\uff98\013\uff98\017\uff98\036\uff98\056\143\112\uff98\114\uff98" + + "\001\002\000\020\004\144\005\uff88\013\uff88\017\uff88\036" + + "\uff88\112\uff88\114\uff88\001\002\000\032\002\uff99\004\uff99" + + "\005\uff99\011\uff99\012\uff99\013\uff99\015\uff99\017\uff99\021" + + "\uff99\036\uff99\112\uff99\114\uff99\001\002\000\026\012\uffbe" + + "\014\uffbe\016\uffbe\021\uffbe\036\uffbe\055\uffbe\102\uffbe\104" + + "\uffbe\112\006\113\uffbe\001\002\000\016\005\uffa6\013\uffa6" + + "\017\uffa6\036\134\112\uffa6\114\uffa6\001\002\000\024\002" + + "\uff89\005\uff89\011\uff89\013\uff89\015\uff89\017\uff89\036\uff89" + + "\112\uff89\114\uff89\001\002\000\014\005\uffbe\013\uffbe\017" + + "\uffbe\112\006\114\uffbe\001\002\000\014\005\uff8c\013\uff8c" + + "\017\uff8c\112\uff8c\114\uff8c\001\002\000\026\012\uffa6\014" + + "\uffa6\016\uffa6\021\uffa6\036\134\055\uffa6\102\uffa6\104\uffa6" + + "\112\uffa6\113\uffa6\001\002\000\024\012\uffbe\014\uffbe\016" + + "\uffbe\021\uffbe\055\uffbe\102\uffbe\104\uffbe\112\006\113\uffbe" + + "\001\002\000\022\012\072\014\105\016\110\021\057\055" + + "\070\102\103\104\076\113\uff57\001\002\000\030\002\uff87" + + "\005\uff87\011\uff87\013\uff87\015\uff87\017\uff87\036\uff87\042" + + "\116\044\117\112\uff87\114\uff87\001\002\000\010\005\156" + + "\013\uff90\114\uff90\001\002\000\012\010\uffbe\036\uffbe\055" + + "\uffbe\112\006\001\002\000\012\010\uffa6\036\134\055\uffa6" + + "\112\uffa6\001\002\000\012\005\uff8e\013\uff8e\112\uff8e\114" + + "\uff8e\001\002\000\042\002\uff73\005\uff73\011\uff73\013\uff73" + + "\014\uff73\015\uff73\017\uff73\020\uff73\024\uff73\036\uff73\042" + + "\uff73\044\uff73\100\uff73\101\uff73\112\uff73\114\uff73\001\002" + + "\000\004\015\252\001\002\000\050\003\173\012\uff5f\015" + + "\uffc2\016\uff5f\021\uff5f\036\165\051\uff5f\055\uff5f\061\176" + + "\062\uff5f\063\020\064\031\065\024\067\041\071\036\077" + + "\uff5f\102\uff5f\103\026\105\uff5f\001\002\000\012\005\241" + + "\011\243\015\uffb2\112\006\001\002\000\012\005\uffac\011" + + "\uffac\015\uffac\112\uffac\001\002\000\012\005\uffa2\011\uffa2" + + "\015\uffa2\112\uffa2\001\002\000\012\005\uffa3\011\uffa3\015" + + "\uffa3\112\uffa3\001\002\000\012\005\uffaf\011\uffaf\015\uffaf" + + "\112\uffaf\001\002\000\012\005\uffa5\011\uffa5\015\uffa5\112" + + "\uffa5\001\002\000\012\005\uffad\011\uffad\015\uffad\112\uffad" + + "\001\002\000\012\005\uffae\011\uffae\015\uffae\112\uffae\001" + + "\002\000\012\005\uffb0\011\uffb0\015\uffb0\112\uffb0\001\002" + + "\000\012\005\uffa4\011\uffa4\015\uffa4\112\uffa4\001\002\000" + + "\024\012\uff68\016\uff68\021\uff68\051\uff68\055\uff68\062\uff68" + + "\077\uff68\102\uff68\105\uff68\001\002\000\024\012\uff57\016" + + "\uff57\021\057\051\043\055\202\062\053\077\051\102\200" + + "\105\203\001\002\000\022\004\uff98\005\uff98\011\uff98\012" + + "\uff57\015\uff98\021\057\056\143\112\uff98\001\002\000\006" + + "\012\222\016\221\001\002\000\022\004\uff98\005\uff98\011" + + "\uff98\012\uff98\015\uff98\021\uff98\056\143\112\uff98\001\002" + + "\000\010\016\uff57\021\057\055\uff9e\001\002\000\004\016" + + "\205\001\002\000\012\010\uffa6\036\134\055\uffa6\112\uffa6" + + "\001\002\000\004\017\207\001\002\000\014\004\144\005" + + "\uff88\011\uff88\015\uff88\112\uff88\001\002\000\012\005\uff91" + + "\011\uff91\015\uff91\112\uff91\001\002\000\022\002\uffbe\004" + + "\uffbe\005\uffbe\011\uffbe\012\uff57\015\uffbe\021\057\112\006" + + "\001\002\000\004\012\215\001\002\000\016\002\uff88\004" + + "\144\005\uff88\011\uff88\015\uff88\112\uff88\001\002\000\014" + + "\002\uff9c\005\uff9c\011\uff9c\015\uff9c\112\uff9c\001\002\000" + + "\014\010\uffbe\013\uffbe\036\uffbe\055\uffbe\112\006\001\002" + + "\000\004\013\217\001\002\000\016\002\uff88\004\144\005" + + "\uff88\011\uff88\015\uff88\112\uff88\001\002\000\014\002\uff97" + + "\005\uff97\011\uff97\015\uff97\112\uff97\001\002\000\012\010" + + "\uffa6\036\134\055\uffa6\112\uffa6\001\002\000\014\010\uffbe" + + "\013\uffbe\036\uffbe\055\uffbe\112\006\001\002\000\004\013" + + "\224\001\002\000\014\004\144\005\uff88\011\uff88\015\uff88" + + "\112\uff88\001\002\000\012\005\uff94\011\uff94\015\uff94\112" + + "\uff94\001\002\000\004\017\227\001\002\000\014\004\144" + + "\005\uff88\011\uff88\015\uff88\112\uff88\001\002\000\012\005" + + "\uff92\011\uff92\015\uff92\112\uff92\001\002\000\004\012\235" + + "\001\002\000\016\002\uffbe\004\uffbe\005\uffbe\011\uffbe\015" + + "\uffbe\112\006\001\002\000\016\002\uff88\004\144\005\uff88" + + "\011\uff88\015\uff88\112\uff88\001\002\000\014\002\uff9a\005" + + "\uff9a\011\uff9a\015\uff9a\112\uff9a\001\002\000\014\010\uffbe" + + "\013\uffbe\036\uffbe\055\uffbe\112\006\001\002\000\004\013" + + "\237\001\002\000\014\004\144\005\uff88\011\uff88\015\uff88" + + "\112\uff88\001\002\000\012\005\uff93\011\uff93\015\uff93\112" + + "\uff93\001\002\000\052\003\uffb5\012\uffb5\015\uffb5\016\uffb5" + + "\021\uffb5\036\uffb5\051\uffb5\055\uffb5\061\uffb5\062\uffb5\063" + + "\uffb5\064\uffb5\065\uffb5\067\uffb5\071\uffb5\077\uffb5\102\uffb5" + + "\103\uffb5\105\uffb5\112\006\001\002\000\052\003\uffb4\012" + + "\uffb4\015\uffb4\016\uffb4\021\uffb4\036\uffb4\051\uffb4\055\uffb4" + + "\061\uffb4\062\uffb4\063\uffb4\064\uffb4\065\uffb4\067\uffb4\071" + + "\uffb4\077\uffb4\102\uffb4\103\uffb4\105\uffb4\112\250\001\002" + + "\000\052\003\uffb7\012\uffb7\015\uffb7\016\uffb7\021\uffb7\036" + + "\uffb7\051\uffb7\055\uffb7\061\uffb7\062\uffb7\063\uffb7\064\uffb7" + + "\065\uffb7\067\uffb7\071\uffb7\077\uffb7\102\uffb7\103\uffb7\105" + + "\uffb7\112\006\001\002\000\050\003\173\012\uff5f\015\uffb3" + + "\016\uff5f\021\uff5f\036\165\051\uff5f\055\uff5f\061\176\062" + + "\uff5f\063\020\064\031\065\024\067\041\071\036\077\uff5f" + + "\102\uff5f\103\026\105\uff5f\001\002\000\004\015\uffc3\001" + + "\002\000\012\005\uffb1\011\uffb1\015\uffb1\112\uffb1\001\002" + + "\000\052\003\uffb8\012\uffb8\015\uffb8\016\uffb8\021\uffb8\036" + + "\uffb8\051\uffb8\055\uffb8\061\uffb8\062\uffb8\063\uffb8\064\uffb8" + + "\065\uffb8\067\uffb8\071\uffb8\077\uffb8\102\uffb8\103\uffb8\105" + + "\uffb8\112\250\001\002\000\122\002\uffc1\003\uffc1\004\uffc1" + + "\005\uffc1\010\uffc1\011\uffc1\012\uffc1\013\uffc1\014\uffc1\015" + + "\uffc1\016\uffc1\017\uffc1\021\uffc1\036\uffc1\051\uffc1\055\uffc1" + + "\060\uffc1\061\uffc1\062\uffc1\063\uffc1\064\uffc1\065\uffc1\066" + + "\uffc1\067\uffc1\070\uffc1\071\uffc1\072\uffc1\073\uffc1\074\uffc1" + + "\075\uffc1\076\uffc1\077\uffc1\102\uffc1\103\uffc1\104\uffc1\105" + + "\uffc1\111\uffc1\112\uffc1\113\uffc1\114\uffc1\001\002\000\052" + + "\003\uffb6\012\uffb6\015\uffb6\016\uffb6\021\uffb6\036\uffb6\051" + + "\uffb6\055\uffb6\061\uffb6\062\uffb6\063\uffb6\064\uffb6\065\uffb6" + + "\067\uffb6\071\uffb6\077\uffb6\102\uffb6\103\uffb6\105\uffb6\112" + + "\250\001\002\000\042\002\uff6e\005\uff6e\011\uff6e\013\uff6e" + + "\014\uff6e\015\uff6e\017\uff6e\020\uff6e\024\uff6e\036\uff6e\042" + + "\uff6e\044\uff6e\100\uff6e\101\uff6e\112\uff6e\114\uff6e\001\002" + + "\000\004\113\254\001\002\000\014\010\uffbe\036\uffbe\055" + + "\uffbe\112\006\114\uffbe\001\002\000\004\114\256\001\002" + + "\000\004\045\257\001\002\000\022\012\072\014\105\016" + + "\110\021\057\055\070\102\103\104\076\113\uff57\001\002" + + "\000\040\002\uff70\005\uff70\011\uff70\013\uff70\014\uff70\015" + + "\uff70\017\uff70\024\uff70\036\uff70\042\116\044\117\100\uff70" + + "\101\uff70\112\uff70\114\uff70\001\002\000\022\012\072\014" + + "\105\016\110\021\057\055\070\102\103\104\076\113\uff57" + + "\001\002\000\042\002\uff79\005\uff79\011\uff79\013\uff79\014" + + "\uff79\015\uff79\017\uff79\020\uff79\024\uff79\036\uff79\042\uff79" + + "\044\uff79\100\uff79\101\uff79\112\uff79\114\uff79\001\002\000" + + "\012\005\uff59\024\uff59\042\116\044\117\001\002\000\006" + + "\005\265\024\266\001\002\000\022\012\072\014\105\016" + + "\110\021\057\055\070\102\103\104\076\113\uff57\001\002" + + "\000\042\002\uff5c\005\uff5c\011\uff5c\013\uff5c\014\uff5c\015" + + "\uff5c\017\uff5c\020\uff5c\024\uff5c\036\uff5c\042\uff5c\044\uff5c" + + "\100\uff5c\101\uff5c\112\uff5c\114\uff5c\001\002\000\012\005" + + "\uff5a\024\uff5a\042\116\044\117\001\002\000\040\002\uff6c" + + "\005\uff6c\011\uff6c\013\uff6c\014\uff6c\015\uff6c\017\uff6c\024" + + "\uff6c\036\uff6c\042\uff6c\044\uff6c\100\uff6c\101\uff6c\112\uff6c" + + "\114\uff6c\001\002\000\046\002\uff5e\005\uff5e\006\272\011" + + "\uff5e\013\uff5e\014\uff5e\015\uff5e\017\uff5e\020\uff5e\021\uff5e" + + "\024\uff5e\036\uff5e\042\uff5e\044\uff5e\100\uff5e\101\uff5e\112" + + "\uff5e\114\uff5e\001\002\000\004\055\271\001\002\000\044" + + "\002\uff5d\005\uff5d\011\uff5d\013\uff5d\014\uff5d\015\uff5d\017" + + "\uff5d\020\uff5d\021\uff5d\024\uff5d\036\uff5d\042\uff5d\044\uff5d" + + "\100\uff5d\101\uff5d\112\uff5d\114\uff5d\001\002\000\042\002" + + "\uff77\005\uff77\011\uff77\013\uff77\014\uff77\015\uff77\017\uff77" + + "\020\uff77\024\uff77\036\uff77\042\uff77\044\uff77\100\uff77\101" + + "\uff77\112\uff77\114\uff77\001\002\000\042\002\uff76\005\uff76" + + "\011\uff76\013\uff76\014\uff76\015\uff76\017\uff76\020\uff76\024" + + "\uff76\036\uff76\042\uff76\044\uff76\100\uff76\101\uff76\112\uff76" + + "\114\uff76\001\002\000\006\042\116\044\117\001\002\000" + + "\016\006\272\020\uff5e\021\uff5e\042\uff5e\044\uff5e\106\315" + + "\001\002\000\012\013\314\020\275\042\uff81\044\uff81\001" + + "\002\000\010\013\312\042\uff86\044\uff86\001\002\000\004" + + "\055\271\001\002\000\010\013\307\042\uff82\044\uff82\001" + + "\002\000\010\013\305\042\uff83\044\uff83\001\002\000\042" + + "\002\uff7c\005\uff7c\011\uff7c\013\uff7c\014\uff7c\015\uff7c\017" + + "\uff7c\020\306\024\uff7c\036\uff7c\042\uff7c\044\uff7c\100\uff7c" + + "\101\uff7c\112\uff7c\114\uff7c\001\002\000\042\002\uff72\005" + + "\uff72\011\uff72\013\uff72\014\uff72\015\uff72\017\uff72\020\uff72" + + "\024\uff72\036\uff72\042\uff72\044\uff72\100\uff72\101\uff72\112" + + "\uff72\114\uff72\001\002\000\040\002\uff7a\005\uff7a\011\uff7a" + + "\013\uff7a\014\uff7a\015\uff7a\017\uff7a\024\uff7a\036\uff7a\042" + + "\uff7a\044\uff7a\100\uff7a\101\uff7a\112\uff7a\114\uff7a\001\002" + + "\000\010\013\311\042\uff6c\044\uff6c\001\002\000\040\002" + + "\uff6b\005\uff6b\011\uff6b\013\uff6b\014\uff6b\015\uff6b\017\uff6b" + + "\024\uff6b\036\uff6b\042\uff6b\044\uff6b\100\uff6b\101\uff6b\112" + + "\uff6b\114\uff6b\001\002\000\042\002\uff6f\005\uff6f\011\uff6f" + + "\013\uff6f\014\uff6f\015\uff6f\017\uff6f\020\313\024\uff6f\036" + + "\uff6f\042\uff6f\044\uff6f\100\uff6f\101\uff6f\112\uff6f\114\uff6f" + + "\001\002\000\042\002\uff74\005\uff74\011\uff74\013\uff74\014" + + "\uff74\015\uff74\017\uff74\020\uff74\024\uff74\036\uff74\042\uff74" + + "\044\uff74\100\uff74\101\uff74\112\uff74\114\uff74\001\002\000" + + "\042\002\uff6d\005\uff6d\011\uff6d\013\uff6d\014\uff6d\015\uff6d" + + "\017\uff6d\020\uff6d\024\uff6d\036\uff6d\042\uff6d\044\uff6d\100" + + "\uff6d\101\uff6d\112\uff6d\114\uff6d\001\002\000\022\012\072" + + "\014\105\016\110\021\057\055\070\102\103\104\076\113" + + "\uff57\001\002\000\010\013\317\042\116\044\117\001\002" + + "\000\040\002\uff69\005\uff69\011\uff69\013\uff69\014\uff69\015" + + "\uff69\017\uff69\024\uff69\036\uff69\042\uff69\044\uff69\100\uff69" + + "\101\uff69\112\uff69\114\uff69\001\002\000\042\002\uff75\005" + + "\uff75\011\uff75\013\uff75\014\uff75\015\uff75\017\uff75\020\uff75" + + "\024\uff75\036\uff75\042\uff75\044\uff75\100\uff75\101\uff75\112" + + "\uff75\114\uff75\001\002\000\022\012\072\014\105\016\110" + + "\021\057\055\070\102\103\104\076\113\uff57\001\002\000" + + "\040\002\uff6a\005\uff6a\011\uff6a\013\uff6a\014\uff6a\015\uff6a" + + "\017\uff6a\024\uff6a\036\uff6a\042\116\044\117\100\uff6a\101" + + "\uff6a\112\uff6a\114\uff6a\001\002\000\004\014\324\001\002" + + "\000\052\003\uffbe\012\uffbe\015\uffbe\016\uffbe\021\uffbe\036" + + "\uffbe\051\uffbe\055\uffbe\061\uffbe\062\uffbe\063\uffbe\064\uffbe" + + "\065\uffbe\067\uffbe\071\uffbe\077\uffbe\102\uffbe\103\uffbe\105" + + "\uffbe\112\006\001\002\000\004\015\326\001\002\000\012" + + "\002\uffe0\011\uffe0\015\uffe0\112\uffe0\001\002\000\012\005" + + "\112\014\uffc9\101\uffc9\112\uffc9\001\002\000\006\005\335" + + "\024\336\001\002\000\014\005\uff54\024\uff54\042\116\044" + + "\117\100\333\001\002\000\006\005\uff55\024\uff55\001\002" + + "\000\022\012\072\014\105\016\110\021\057\055\070\102" + + "\103\104\076\113\uff57\001\002\000\012\005\uff53\024\uff53" + + "\042\116\044\117\001\002\000\022\012\072\014\105\016" + + "\110\021\057\055\070\102\103\104\076\113\uff57\001\002" + + "\000\022\012\uff58\014\uff58\016\uff58\025\uff58\100\uff58\101" + + "\uff58\112\uff58\113\uff58\001\002\000\006\005\uff56\024\uff56" + + "\001\002\000\010\012\uff98\021\uff98\056\143\001\002\000" + + "\006\012\uff57\021\057\001\002\000\004\012\343\001\002" + + "\000\014\010\uffbe\013\uffbe\036\uffbe\055\uffbe\112\006\001" + + "\002\000\004\013\345\001\002\000\016\002\uff88\004\144" + + "\005\uff88\011\uff88\015\uff88\112\uff88\001\002\000\014\002" + + "\uff96\005\uff96\011\uff96\015\uff96\112\uff96\001\002\000\006" + + "\014\uffbe\112\006\001\002\000\004\014\351\001\002\000" + + "\066\003\uffbe\015\uffbe\036\uffbe\051\uffbe\055\uffbe\060\uffbe" + + "\061\uffbe\062\uffbe\063\uffbe\064\uffbe\065\uffbe\066\uffbe\067" + + "\uffbe\070\uffbe\071\uffbe\072\uffbe\073\uffbe\074\uffbe\075\uffbe" + + "\076\uffbe\077\uffbe\102\uffbe\103\uffbe\105\uffbe\111\uffbe\112" + + "\006\001\002\000\004\015\353\001\002\000\012\002\uffa1" + + "\011\uffa1\015\uffa1\112\uffa1\001\002\000\020\002\uff98\004" + + "\uff98\005\uff98\011\uff98\015\uff98\056\143\112\uff98\001\002" + + "\000\016\002\uffbe\004\uffbe\005\uffbe\011\uffbe\015\uffbe\112" + + "\006\001\002\000\016\002\uff88\004\144\005\uff88\011\uff88" + + "\015\uff88\112\uff88\001\002\000\014\002\uff9d\005\uff9d\011" + + "\uff9d\015\uff9d\112\uff9d\001\002\000\004\055\uffcb\001\002" + + "\000\004\055\uffca\001\002\000\004\055\363\001\002\000" + + "\014\014\uff57\021\057\100\uff57\101\uff57\112\uff57\001\002" + + "\000\012\014\uffc8\100\061\101\uffc8\112\uffc8\001\002\000" + + "\010\014\uffc6\101\064\112\uffc6\001\002\000\006\014\uffbe" + + "\112\006\001\002\000\004\014\370\001\002\000\052\003" + + "\uffbe\012\uffbe\015\uffbe\016\uffbe\021\uffbe\036\uffbe\051\uffbe" + + "\055\uffbe\061\uffbe\062\uffbe\063\uffbe\064\uffbe\065\uffbe\067" + + "\uffbe\071\uffbe\077\uffbe\102\uffbe\103\uffbe\105\uffbe\112\006" + + "\001\002\000\004\015\372\001\002\000\012\002\uffe1\011" + + "\uffe1\015\uffe1\112\uffe1\001\002\000\010\014\uff57\021\057" + + "\112\uff57\001\002\000\006\014\uffbe\112\006\001\002\000" + + "\004\014\376\001\002\000\014\003\uffbe\015\uffbe\036\uffbe" + + "\055\uffbe\112\006\001\002\000\012\003\u0105\015\uffd8\036" + + "\u0107\055\u0108\001\002\000\004\015\u0101\001\002\000\012" + + "\002\uffdb\011\uffdb\015\uffdb\112\uffdb\001\002\000\012\005" + + "\uffcf\015\uffcf\036\uffcf\112\uffcf\001\002\000\012\005\uffd6" + + "\015\uffd6\036\uffd6\112\uffd6\001\002\000\012\005\uffd2\015" + + "\uffd2\036\uffd2\112\uffd2\001\002\000\012\005\uffd1\015\uffd1" + + "\036\uffd1\112\uffd1\001\002\000\012\005\u0111\015\uffbe\036" + + "\uffbe\112\006\001\002\000\014\005\uffbe\015\uffbe\036\uffbe" + + "\055\uffbe\112\006\001\002\000\014\005\uffce\015\uffce\025" + + "\u010c\036\uffce\112\uffce\001\002\000\006\055\uffbe\112\006" + + "\001\002\000\004\055\u0108\001\002\000\012\005\uffd0\015" + + "\uffd0\036\uffd0\112\uffd0\001\002\000\004\051\u010e\001\002" + + "\000\012\005\uffcd\015\uffcd\036\uffcd\112\uffcd\001\002\000" + + "\012\005\uffcc\015\uffcc\036\uffcc\112\uffcc\001\002\000\014" + + "\005\uffaa\015\uffaa\036\u0107\055\uffaa\112\uffaa\001\002\000" + + "\014\005\uffab\015\uffab\036\uffab\055\uffab\112\uffab\001\002" + + "\000\016\003\uffbe\005\uffbe\015\uffbe\036\uffbe\055\uffbe\112" + + "\006\001\002\000\006\015\uffd9\036\u0107\001\002\000\012" + + "\005\uffbe\015\uffbe\036\uffbe\112\006\001\002\000\012\005" + + "\uffd4\015\uffd4\036\uffd4\112\uffd4\001\002\000\016\003\u0105" + + "\005\uffd5\015\uffd5\036\u0107\055\u0108\112\uffd5\001\002\000" + + "\012\005\uffd7\015\uffd7\036\uffd7\112\uffd7\001\002\000\014" + + "\005\uffbe\015\uffbe\036\uffbe\055\uffbe\112\006\001\002\000" + + "\014\005\uffd3\015\uffd3\036\uffd3\055\u0108\112\uffd3\001\002" + + "\000\016\002\uffbe\004\uffbe\005\uffbe\011\uffbe\015\uffbe\112" + + "\006\001\002\000\016\002\uff88\004\144\005\uff88\011\uff88" + + "\015\uff88\112\uff88\001\002\000\014\002\uff9b\005\uff9b\011" + + "\uff9b\015\uff9b\112\uff9b\001\002\000\004\055\u011d\001\002" + + "\000\010\014\uff57\021\057\112\uff57\001\002\000\006\014" + + "\uffbe\112\006\001\002\000\004\014\u0120\001\002\000\014" + + "\003\uffbe\015\uffbe\036\uffbe\055\uffbe\112\006\001\002\000" + + "\004\015\u0122\001\002\000\012\002\uffda\011\uffda\015\uffda" + + "\112\uffda\001\002\000\010\012\uff98\021\uff98\056\143\001" + + "\002\000\006\012\uff57\021\057\001\002\000\004\012\u0126" + + "\001\002\000\014\010\uffbe\013\uffbe\036\uffbe\055\uffbe\112" + + "\006\001\002\000\004\013\u0128\001\002\000\016\002\uff88" + + "\004\144\005\uff88\011\uff88\015\uff88\112\uff88\001\002\000" + + "\014\002\uff95\005\uff95\011\uff95\015\uff95\112\uff95\001\002" + + "\000\004\055\u0134\001\002\000\004\055\u012f\001\002\000" + + "\004\055\u012d\001\002\000\012\002\uffbe\011\uffbe\015\uffbe" + + "\112\006\001\002\000\012\002\uffef\011\uffef\015\uffef\112" + + "\uffef\001\002\000\006\021\057\025\uff57\001\002\000\004" + + "\025\u0131\001\002\000\022\012\072\014\105\016\110\021" + + "\057\055\070\102\103\104\076\113\uff57\001\002\000\016" + + "\002\uffe2\011\uffe2\015\uffe2\042\116\044\117\112\uffe2\001" + + "\002\000\006\005\u0138\015\u0139\001\002\000\010\005\uffeb" + + "\015\uffeb\107\u0136\001\002\000\006\005\uffec\015\uffec\001" + + "\002\000\004\055\u0137\001\002\000\006\005\uffea\015\uffea" + + "\001\002\000\006\055\uffbe\112\006\001\002\000\012\002" + + "\uffbe\011\uffbe\015\uffbe\112\006\001\002\000\012\002\uffee" + + "\011\uffee\015\uffee\112\uffee\001\002\000\004\055\u0134\001" + + "\002\000\006\005\uffed\015\uffed\001\002\000\006\021\057" + + "\025\uff57\001\002\000\004\025\u013f\001\002\000\024\012" + + "\uffbe\014\uffbe\016\uffbe\021\uffbe\055\uffbe\102\uffbe\104\uffbe" + + "\112\006\113\uffbe\001\002\000\022\012\072\014\105\016" + + "\110\021\057\055\070\102\103\104\076\113\uff57\001\002" + + "\000\016\002\uffe3\011\uffe3\015\uffe3\042\116\044\117\112" + + "\uffe3\001\002\000\040\012\uff62\016\uff62\021\uff62\051\uff62" + + "\055\uff62\062\uff62\066\uff62\072\uff62\073\uff62\075\uff62\076" + + "\uff62\077\uff62\102\uff62\105\uff62\111\uff62\001\002\000\066" + + "\002\uffba\003\033\015\uffba\036\015\051\uff5f\055\uff5f\060" + + "\uffe8\061\035\062\uff5f\063\020\064\031\065\024\066\uff5f" + + "\067\041\070\023\071\036\072\uff5f\073\uff5f\074\032\075" + + "\uff5f\076\uff5f\077\uff5f\102\uff5f\103\026\105\uff5f\111\uff5f" + + "\001\002\000\070\002\uffbb\003\uffbb\015\uffbb\036\uffbb\051" + + "\uffbb\055\uffbb\060\uffbb\061\uffbb\062\uffbb\063\uffbb\064\uffbb" + + "\065\uffbb\066\uffbb\067\uffbb\070\uffbb\071\uffbb\072\uffbb\073" + + "\uffbb\074\uffbb\075\uffbb\076\uffbb\077\uffbb\102\uffbb\103\uffbb" + + "\105\uffbb\111\uffbb\112\250\001\002\000\006\002\uffff\015" + + "\uffff\001\002\000\070\002\uffbc\003\uffbc\015\uffbc\036\uffbc" + + "\051\uffbc\055\uffbc\060\uffbc\061\uffbc\062\uffbc\063\uffbc\064" + + "\uffbc\065\uffbc\066\uffbc\067\uffbc\070\uffbc\071\uffbc\072\uffbc" + + "\073\uffbc\074\uffbc\075\uffbc\076\uffbc\077\uffbc\102\uffbc\103" + + "\uffbc\105\uffbc\111\uffbc\112\006\001\002\000\070\002\uffbd" + + "\003\uffbd\015\uffbd\036\uffbd\051\uffbd\055\uffbd\060\uffbd\061" + + "\uffbd\062\uffbd\063\uffbd\064\uffbd\065\uffbd\066\uffbd\067\uffbd" + + "\070\uffbd\071\uffbd\072\uffbd\073\uffbd\074\uffbd\075\uffbd\076" + + "\uffbd\077\uffbd\102\uffbd\103\uffbd\105\uffbd\111\uffbd\112\250" + + "\001\002\000\012\002\ufffd\011\ufffd\015\ufffd\112\ufffd\001" + + "\002\000\040\012\uff60\016\uff60\021\uff60\051\uff60\055\uff60" + + "\062\uff60\066\uff60\072\uff60\073\uff60\075\uff60\076\uff60\077" + + "\uff60\102\uff60\105\uff60\111\uff60\001\002\000\006\014\uffbe" + + "\112\006\001\002\000\004\014\u014c\001\002\000\066\003" + + "\uffbe\015\uffbe\036\uffbe\051\uffbe\055\uffbe\060\uffbe\061\uffbe" + + "\062\uffbe\063\uffbe\064\uffbe\065\uffbe\066\uffbe\067\uffbe\070" + + "\uffbe\071\uffbe\072\uffbe\073\uffbe\074\uffbe\075\uffbe\076\uffbe" + + "\077\uffbe\102\uffbe\103\uffbe\105\uffbe\111\uffbe\112\006\001" + + "\002\000\004\015\u014e\001\002\000\012\002\uffa0\011\uffa0" + + "\015\uffa0\112\uffa0\001\002\000\040\012\uff63\016\uff63\021" + + "\uff63\051\uff63\055\uff63\062\uff63\066\uff63\072\uff63\073\uff63" + + "\075\uff63\076\uff63\077\uff63\102\uff63\105\uff63\111\uff63\001" + + "\002\000\006\030\u0152\055\u0153\001\002\000\012\002\uffe7" + + "\011\uffe7\015\uffe7\112\uffe7\001\002\000\004\107\u015a\001" + + "\002\000\004\025\u0154\001\002\000\004\055\u0156\001\002" + + "\000\012\002\uffe5\011\uffe5\015\uffe5\112\uffe5\001\002\000" + + "\016\002\uff5e\006\272\011\uff5e\012\u0157\015\uff5e\112\uff5e" + + "\001\002\000\004\055\271\001\002\000\004\013\u0159\001" + + "\002\000\012\002\uffe4\011\uffe4\015\uffe4\112\uffe4\001\002" + + "\000\004\055\u015b\001\002\000\004\110\u015c\001\002\000" + + "\004\055\271\001\002\000\012\002\uffe6\011\uffe6\015\uffe6" + + "\112\uffe6\001\002\000\004\002\001\001\002" }); + + /** Access to parse-action table. */ + public short[][] action_table() {return _action_table;} + + /** reduce_goto table. */ + protected static final short[][] _reduce_table = + unpackFromStrings(new String[] { + "\000\u015c\000\012\003\006\004\003\076\004\101\007\001" + + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\036\005\027\006\037\007\011\010" + + "\020\011\013\012\016\014\024\015\010\016\033\021\026" + + "\022\021\035\015\061\036\111\012\001\001\000\002\001" + + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\004" + + "\064\u0149\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\010\076\u0143\077\u0142" + + "\100\u0144\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + + "\001\001\000\010\063\041\112\047\113\046\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\004" + + "\026\u0118\001\001\000\002\001\001\000\002\001\001\000" + + "\004\026\231\001\001\000\004\013\361\001\001\000\002" + + "\001\001\000\002\001\001\000\006\026\210\064\346\001" + + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\004\066\057\001\001\000\036\045\330\047\103\050" + + "\076\051\105\052\073\054\074\055\072\056\065\057\077" + + "\060\070\064\100\066\106\067\327\070\331\001\001\000" + + "\004\074\061\001\001\000\034\045\066\047\103\050\076" + + "\051\105\052\073\054\074\055\072\056\065\057\077\060" + + "\070\064\100\066\106\104\326\001\001\000\004\075\062" + + "\001\001\000\006\076\004\101\322\001\001\000\006\076" + + "\004\101\064\001\001\000\034\045\066\047\103\050\076" + + "\051\105\052\073\054\074\055\072\056\065\057\077\060" + + "\070\064\100\066\106\104\101\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\032\045\275\047\303\050\302\051\105\052\300\054\074" + + "\055\277\056\065\057\077\060\070\064\100\066\106\001" + + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\004\064\267\001\001\000\002\001\001\000\002\001" + + "\001\000\004\071\261\001\001\000\002\001\001\000\004" + + "\066\252\001\001\000\002\001\001\000\010\030\161\076" + + "\004\101\162\001\001\000\002\001\001\000\002\001\001" + + "\000\034\045\066\047\103\050\076\051\105\052\073\054" + + "\074\055\072\056\065\057\077\060\070\064\100\066\106" + + "\104\110\001\001\000\002\001\001\000\006\076\004\101" + + "\113\001\001\000\002\001\001\000\032\045\114\047\103" + + "\050\076\051\105\052\073\054\074\055\072\056\065\057" + + "\077\060\070\064\100\066\106\001\001\000\002\001\001" + + "\000\006\076\004\101\121\001\001\000\006\076\004\101" + + "\117\001\001\000\032\045\120\047\103\050\076\051\105" + + "\052\073\054\074\055\072\056\065\057\077\060\070\064" + + "\100\066\106\001\001\000\002\001\001\000\032\045\122" + + "\047\103\050\076\051\105\052\073\054\074\055\072\056" + + "\065\057\077\060\070\064\100\066\106\001\001\000\002" + + "\001\001\000\010\023\125\076\004\101\124\001\001\000" + + "\010\024\131\025\134\107\132\001\001\000\002\001\001" + + "\000\002\001\001\000\032\045\130\047\103\050\076\051" + + "\105\052\073\054\074\055\072\056\065\057\077\060\070" + + "\064\100\066\106\001\001\000\002\001\001\000\006\076" + + "\004\101\154\001\001\000\006\076\004\101\135\001\001" + + "\000\002\001\001\000\002\001\001\000\004\027\137\001" + + "\001\000\002\001\001\000\002\001\001\000\004\026\141" + + "\001\001\000\006\043\144\044\145\001\001\000\002\001" + + "\001\000\006\076\004\101\150\001\001\000\004\107\146" + + "\001\001\000\002\001\001\000\006\076\004\101\147\001" + + "\001\000\002\001\001\000\004\107\151\001\001\000\006" + + "\076\004\101\152\001\001\000\032\045\153\047\103\050" + + "\076\051\105\052\073\054\074\055\072\056\065\057\077" + + "\060\070\064\100\066\106\001\001\000\002\001\001\000" + + "\002\001\001\000\006\076\004\101\156\001\001\000\006" + + "\025\157\107\132\001\001\000\002\001\001\000\002\001" + + "\001\000\002\001\001\000\024\014\170\016\174\017\165" + + "\020\166\031\163\032\173\033\167\034\171\061\176\001" + + "\001\000\010\076\241\102\243\103\244\001\001\000\002" + + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\006\066\200\112\047\001\001\000\006\026\231\066\230" + + "\001\001\000\002\001\001\000\004\026\210\001\001\000" + + "\004\066\203\001\001\000\002\001\001\000\006\025\205" + + "\107\132\001\001\000\002\001\001\000\006\043\207\044" + + "\145\001\001\000\002\001\001\000\010\066\211\076\004" + + "\101\212\001\001\000\002\001\001\000\006\043\213\044" + + "\145\001\001\000\002\001\001\000\010\023\215\076\004" + + "\101\124\001\001\000\002\001\001\000\006\043\217\044" + + "\145\001\001\000\002\001\001\000\006\025\225\107\132" + + "\001\001\000\010\023\222\076\004\101\124\001\001\000" + + "\002\001\001\000\006\043\224\044\145\001\001\000\002" + + "\001\001\000\002\001\001\000\006\043\227\044\145\001" + + "\001\000\002\001\001\000\002\001\001\000\006\076\004" + + "\101\232\001\001\000\006\043\233\044\145\001\001\000" + + "\002\001\001\000\010\023\235\076\004\101\124\001\001" + + "\000\002\001\001\000\006\043\237\044\145\001\001\000" + + "\002\001\001\000\004\076\250\001\001\000\002\001\001" + + "\000\004\076\246\001\001\000\022\014\170\016\174\017" + + "\165\020\166\032\245\033\167\034\171\061\176\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + + "\001\001\000\010\023\254\076\004\101\124\001\001\000" + + "\002\001\001\000\002\001\001\000\032\045\257\047\103" + + "\050\076\051\105\052\073\054\074\055\072\056\065\057" + + "\077\060\070\064\100\066\106\001\001\000\002\001\001" + + "\000\034\045\262\047\103\050\076\051\105\052\073\054" + + "\074\055\072\056\065\057\077\060\070\064\100\066\106" + + "\072\263\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\032\045\266\047\103\050\076\051\105" + + "\052\073\054\074\055\072\056\065\057\077\060\070\064" + + "\100\066\106\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\004\064\272\001" + + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\004\064\307\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + + "\001\001\000\002\001\001\000\002\001\001\000\032\045" + + "\315\047\103\050\076\051\105\052\073\054\074\055\072" + + "\056\065\057\077\060\070\064\100\066\106\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\032" + + "\045\321\047\103\050\076\051\105\052\073\054\074\055" + + "\072\056\065\057\077\060\070\064\100\066\106\001\001" + + "\000\002\001\001\000\002\001\001\000\010\030\324\076" + + "\004\101\162\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\032\045\333\047\103\050\076\051\105" + + "\052\073\054\074\055\072\056\065\057\077\060\070\064" + + "\100\066\106\001\001\000\002\001\001\000\034\045\330" + + "\047\103\050\076\051\105\052\073\054\074\055\072\056" + + "\065\057\077\060\070\064\100\066\106\070\336\001\001" + + "\000\002\001\001\000\002\001\001\000\004\026\340\001" + + "\001\000\004\066\341\001\001\000\002\001\001\000\010" + + "\023\343\076\004\101\124\001\001\000\002\001\001\000" + + "\006\043\345\044\145\001\001\000\002\001\001\000\006" + + "\076\004\101\347\001\001\000\002\001\001\000\010\004" + + "\351\076\004\101\007\001\001\000\002\001\001\000\002" + + "\001\001\000\004\026\354\001\001\000\006\076\004\101" + + "\355\001\001\000\006\043\356\044\145\001\001\000\002" + + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + + "\001\000\004\066\363\001\001\000\004\074\364\001\001" + + "\000\004\075\365\001\001\000\006\076\004\101\366\001" + + "\001\000\002\001\001\000\010\030\370\076\004\101\162" + + "\001\001\000\002\001\001\000\002\001\001\000\004\066" + + "\373\001\001\000\006\076\004\101\374\001\001\000\002" + + "\001\001\000\010\037\377\076\004\101\376\001\001\000" + + "\014\036\u0105\040\u0102\041\u0103\042\u0101\105\u0108\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\006" + + "\076\004\101\u0111\001\001\000\006\076\004\101\u010e\001" + + "\001\000\002\001\001\000\006\076\004\101\u0109\001\001" + + "\000\004\042\u010a\001\001\000\002\001\001\000\004\110" + + "\u010c\001\001\000\002\001\001\000\002\001\001\000\004" + + "\105\u010f\001\001\000\002\001\001\000\006\076\004\101" + + "\u0114\001\001\000\004\105\u0112\001\001\000\006\076\004" + + "\101\u0113\001\001\000\002\001\001\000\012\040\u0115\041" + + "\u0103\042\u0101\105\u0116\001\001\000\002\001\001\000\006" + + "\076\004\101\u0117\001\001\000\004\042\u010a\001\001\000" + + "\006\076\004\101\u0119\001\001\000\006\043\u011a\044\145" + + "\001\001\000\002\001\001\000\002\001\001\000\004\066" + + "\u011d\001\001\000\006\076\004\101\u011e\001\001\000\002" + + "\001\001\000\010\037\u0120\076\004\101\376\001\001\000" + + "\002\001\001\000\002\001\001\000\004\026\u0123\001\001" + + "\000\004\066\u0124\001\001\000\002\001\001\000\010\023" + + "\u0126\076\004\101\124\001\001\000\002\001\001\000\006" + + "\043\u0128\044\145\001\001\000\002\001\001\000\006\114" + + "\u0132\115\u0134\001\001\000\002\001\001\000\002\001\001" + + "\000\006\076\004\101\u012d\001\001\000\002\001\001\000" + + "\004\066\u012f\001\001\000\002\001\001\000\032\045\u0131" + + "\047\103\050\076\051\105\052\073\054\074\055\072\056" + + "\065\057\077\060\070\064\100\066\106\001\001\000\002" + + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + + "\001\000\002\001\001\000\002\001\001\000\006\076\004" + + "\101\u013a\001\001\000\006\076\004\101\u0139\001\001\000" + + "\002\001\001\000\004\115\u013b\001\001\000\002\001\001" + + "\000\004\066\u013d\001\001\000\002\001\001\000\006\076" + + "\004\101\u013f\001\001\000\032\045\u0140\047\103\050\076" + + "\051\105\052\073\054\074\055\072\056\065\057\077\060" + + "\070\064\100\066\106\001\001\000\002\001\001\000\002" + + "\001\001\000\034\006\u0147\007\011\010\020\011\013\012" + + "\016\014\024\015\010\016\033\021\026\022\021\035\015" + + "\061\036\111\012\001\001\000\002\001\001\000\002\001" + + "\001\000\004\076\u0146\001\001\000\002\001\001\000\002" + + "\001\001\000\002\001\001\000\006\076\004\101\u014a\001" + + "\001\000\002\001\001\000\010\004\u014c\076\004\101\007" + + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + + "\001\000\004\065\u0150\001\001\000\002\001\001\000\002" + + "\001\001\000\002\001\001\000\004\064\u0154\001\001\000" + + "\002\001\001\000\002\001\001\000\004\064\u0157\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\004\064\u015c\001\001\000\002\001\001" + + "\000\002\001\001" }); + + /** Access to reduce_goto table. */ + public short[][] reduce_table() {return _reduce_table;} + + /** Instance of action encapsulation class. */ + protected CUP$TypescriptDefParser$actions action_obj; + + /** Action encapsulation object initializer. */ + protected void init_actions() + { + action_obj = new CUP$TypescriptDefParser$actions(this); + } + + /** Invoke a user supplied parse action. */ + public java_cup.runtime.Symbol do_action( + int act_num, + java_cup.runtime.lr_parser parser, + java.util.Stack stack, + int top) + throws java.lang.Exception + { + /* call code in generated class */ + return action_obj.CUP$TypescriptDefParser$do_action(act_num, parser, stack, top); + } + + /** Indicates start state. */ + public int start_state() {return 0;} + /** Indicates start production. */ + public int start_production() {return 0;} + + /** EOF Symbol index. */ + public int EOF_sym() {return 0;} + + /** error Symbol index. */ + public int error_sym() {return 1;} + + + + + public PrintStream out = System.out; + public PrintStream err = System.err; + public CompilationUnit compilationUnit; + public Stack comments = new Stack(); + + protected static TypescriptDefParser createParser(File file) throws java.io.FileNotFoundException { + TypescriptDefScanner scanner= new TypescriptDefScanner(new java.io.FileReader(file)); + scanner.setFileName(file.getPath()); + TypescriptDefParser parser= new TypescriptDefParser(scanner); + parser.compilationUnit = new CompilationUnit(file); + return parser; + } + + public static TypescriptDefParser parseFile(File file) throws java.io.FileNotFoundException { + TypescriptDefParser parser= createParser(file); + try { + parser.parse(); + } catch(Exception e) { + e.printStackTrace(); + parser.errors.add(new SyntaxError(null, "internal parser error")); + } + return parser; + } + + public List errors = new ArrayList(); + + public void syntax_error(java_cup.runtime.Symbol current) { + //errors.add(new SyntaxError("syntax error: '"+current.value + "' is not expected", at " + (current.left+1)+"("+(current.right+1)+")" ); + SyntaxError e = new SyntaxError((Token)current.value, "'"+current.value + "' is not expected"); + errors.add(e); + System.err.println(e); + } + + public void syntax_error(Token current) { + SyntaxError e = new SyntaxError(current, "'"+current + "' is not expected"); + errors.add(e); + System.err.println(e); + } + + public void unrecovered_syntax_error(java_cup.runtime.Symbol current) { + System.err.println("unable to recover from previous error(s)... giving up!"); + } + + public void printErrors(PrintStream out) { + for (SyntaxError error : errors) { + out.println(error.toString()); + } + } + + public boolean hasErrors() { + return !errors.isEmpty(); + } + + + + +} + +/** Cup generated class to encapsulate user supplied action code.*/ +@SuppressWarnings("all") +class CUP$TypescriptDefParser$actions { + private final TypescriptDefParser parser; + + /** Constructor */ + CUP$TypescriptDefParser$actions(TypescriptDefParser parser) { + this.parser = parser; + } + + /** Method with the actual generated action code. */ + public final java_cup.runtime.Symbol CUP$TypescriptDefParser$do_action( + int CUP$TypescriptDefParser$act_num, + java_cup.runtime.lr_parser CUP$TypescriptDefParser$parser, + java.util.Stack CUP$TypescriptDefParser$stack, + int CUP$TypescriptDefParser$top) + throws java.lang.Exception + { + /* Symbol object for return from actions */ + java_cup.runtime.Symbol CUP$TypescriptDefParser$result; + + /* select the action based on the action number */ + switch (CUP$TypescriptDefParser$act_num) + { + /*. . . . . . . . . . . . . . . . . . . .*/ + case 174: // type_param ::= type EXTENDS type + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int sleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int sright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object s = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + RESULT=new TypeParameterDeclaration(((TypeReference)t).getToken(), ((TypeReference)t).getName()); + ((TypeParameterDeclaration)RESULT).setUpperBound((TypeReference)s); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(54/*type_param*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 173: // type_param ::= type + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + RESULT=new TypeParameterDeclaration(((TypeReference)t).getToken(), ((TypeReference)t).getName()); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(54/*type_param*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 172: // type_param_list ::= type_param + { + Object RESULT = null; + int pleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int pright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object p = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + RESULT=new TypeParameterDeclaration[] { (TypeParameterDeclaration)p }; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(53/*type_param_list*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 171: // type_param_list ::= type_param_list COMMA type_param + { + Object RESULT = null; + int lleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int lright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object l = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int pleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int pright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object p = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + TypeParameterDeclaration[] list = (TypeParameterDeclaration[])l; + RESULT = ArrayUtils.add(list, (TypeParameterDeclaration)p); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(53/*type_param_list*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 170: // type_param_list_opt ::= + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(52/*type_param_list_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 169: // type_param_list_opt ::= LT type_param_list GT + { + Object RESULT = null; + int tparamsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int tparamsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object tparams = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + RESULT = tparams; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(52/*type_param_list_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 168: // type_arg_list ::= type + { + Object RESULT = null; + int pleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int pright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object p = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + RESULT=new TypeReference[] { (TypeReference)p }; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(56/*type_arg_list*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 167: // type_arg_list ::= type_arg_list COMMA type + { + Object RESULT = null; + int lleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int lright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object l = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int pleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int pright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object p = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + TypeReference[] list = (TypeReference[])l; + RESULT = ArrayUtils.add(list, (TypeReference)p); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(56/*type_arg_list*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 166: // type_arg_list_opt ::= + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(55/*type_arg_list_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 165: // type_arg_list_opt ::= LT type_arg_list GT + { + Object RESULT = null; + int tparamsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int tparamsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object tparams = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + RESULT = tparams; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(55/*type_arg_list_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 164: // qual_id ::= IDENTIFIER DOT qual_id + { + Object RESULT = null; + int ileft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int iright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object i = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int qleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int qright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object q = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=i.toString()+"."+q.toString(); + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(50/*qual_id*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 163: // qual_id ::= IDENTIFIER + { + Object RESULT = null; + int ileft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int iright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object i = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=i.toString(); + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(50/*qual_id*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 162: // declare_opt ::= + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(47/*declare_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 161: // declare_opt ::= PUBLIC STATIC + { + Object RESULT = null; + RESULT = "public static"; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(47/*declare_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 160: // declare_opt ::= PUBLIC + { + Object RESULT = null; + RESULT = "public"; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(47/*declare_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 159: // declare_opt ::= PROTECTED STATIC + { + Object RESULT = null; + RESULT = "protected static"; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(47/*declare_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 158: // declare_opt ::= PRIVATE STATIC + { + Object RESULT = null; + RESULT = "private static"; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(47/*declare_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 157: // declare_opt ::= PROTECTED + { + Object RESULT = null; + RESULT = "protected"; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(47/*declare_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 156: // declare_opt ::= PRIVATE + { + Object RESULT = null; + RESULT = "private"; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(47/*declare_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 155: // declare_opt ::= STATIC + { + Object RESULT = null; + RESULT = "static"; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(47/*declare_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 154: // declare_opt ::= DECLARE + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(47/*declare_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 153: // declare_opt ::= EXPORT + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(47/*declare_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 152: // is_type ::= LPAREN IDENTIFIER IS type RPAREN + { + Object RESULT = null; + RESULT=new TypeReference(null, "boolean", null); + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(45/*is_type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 151: // is_type ::= IDENTIFIER IS type + { + Object RESULT = null; + RESULT=new TypeReference(null, "boolean", null); + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(45/*is_type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 150: // typeof_type ::= LPAREN TYPEOF qual_id RPAREN + { + Object RESULT = null; + int nameleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int nameright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object name = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + TypeReference t = new TypeReference(null, (String)name, null); t.setTypeOf(true); RESULT=t; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(44/*typeof_type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 149: // typeof_type ::= TYPEOF qual_id + { + Object RESULT = null; + int nameleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int nameright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object name = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + TypeReference t = new TypeReference(null, (String)name, null); t.setTypeOf(true); RESULT=t; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(44/*typeof_type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 148: // object_type ::= LPAREN object_type RPAREN + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + RESULT=t; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(43/*object_type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 147: // object_type ::= LCPAREN member_list_opt RCPAREN + { + Object RESULT = null; + int tokenleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int tokenright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object token = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int membersleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int membersright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object members = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + RESULT=new TypeReference((Token)token, (Declaration[])members); + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(43/*object_type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 146: // functional_type ::= LPAREN functional_type RPAREN + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + RESULT=t; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(40/*functional_type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 145: // functional_type ::= NEW type_param_list_opt LPAREN_FUNC param_list_opt RPAREN_FUNC IMPLIES type + { + Object RESULT = null; + int ileft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).left; + int iright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).right; + Object i = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).value; + int tparamsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left; + int tparamsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).right; + Object tparams = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).value; + int paramsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left; + int paramsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).right; + Object params = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).value; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + RESULT=new FunctionalTypeReference((Token)i, true, (TypeReference)t, (ParameterDeclaration[])params, (TypeParameterDeclaration[])tparams); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(40/*functional_type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 144: // functional_type ::= type_param_list_opt LPAREN_FUNC param_list_opt RPAREN_FUNC IMPLIES type + { + Object RESULT = null; + int tparamsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left; + int tparamsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).right; + Object tparams = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).value; + int tokenleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left; + int tokenright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).right; + Object token = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).value; + int paramsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left; + int paramsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).right; + Object params = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).value; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + RESULT=new FunctionalTypeReference((Token)token, (TypeReference)t, (ParameterDeclaration[])params, (TypeParameterDeclaration[])tparams); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(40/*functional_type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 143: // array_type ::= LPAREN union_type RPAREN SQUARE + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + RESULT=new ArrayTypeReference(null, (TypeReference)t); + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(39/*array_type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 142: // array_type ::= array_type SQUARE + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + RESULT=new ArrayTypeReference(null, (TypeReference)t); + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(39/*array_type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 141: // array_type ::= LPAREN functional_type RPAREN SQUARE + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + RESULT=new ArrayTypeReference(null, (TypeReference)t); + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(39/*array_type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 140: // array_type ::= tuple_type SQUARE + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + RESULT=new ArrayTypeReference( null, (TypeReference)t); + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(39/*array_type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 139: // array_type ::= object_type SQUARE + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + RESULT=new ArrayTypeReference( null, (TypeReference)t); + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(39/*array_type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 138: // array_type ::= simple_type SQUARE + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + RESULT=new ArrayTypeReference( null, (TypeReference)t); + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(39/*array_type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 137: // tuple_type ::= LSPAREN type_list RSPAREN + { + Object RESULT = null; + int typesleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int typesright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object types = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + RESULT=new TypeReference(null, "$tuple$", (TypeReference[])types); + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(46/*tuple_type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 136: // simple_type ::= qual_id type_arg_list_opt + { + Object RESULT = null; + int qleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int qright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object q = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + int tparamsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tparamsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object tparams = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=new TypeReference(null, (String)q, (TypeReference[])tparams); + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(42/*simple_type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 135: // intersection_type ::= LPAREN intersection_type RPAREN + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + RESULT=t; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(38/*intersection_type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 134: // intersection_type ::= type AND lf_opt type + { + Object RESULT = null; + int t1left = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left; + int t1right = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).right; + Object t1 = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).value; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int t2left = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int t2right = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t2 = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=new UnionTypeReference((Token)t, (TypeReference)t1, (TypeReference)t2, true); + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(38/*intersection_type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 133: // union_type ::= LPAREN union_type RPAREN + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + RESULT=t; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(37/*union_type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 132: // union_type ::= type TUBE lf_opt type + { + Object RESULT = null; + int t1left = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left; + int t1right = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).right; + Object t1 = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).value; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int t2left = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int t2right = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t2 = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=new UnionTypeReference((Token)t, (TypeReference)t1, (TypeReference)t2); + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(37/*union_type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 131: // type ::= tuple_type + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=t; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(35/*type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 130: // type ::= simple_type + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=t; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(35/*type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 129: // type ::= array_type + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=t; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(35/*type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 128: // type ::= object_type + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=t; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(35/*type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 127: // type ::= intersection_type + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=t; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(35/*type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 126: // type ::= union_type + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=t; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(35/*type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 125: // type ::= is_type + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=t; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(35/*type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 124: // type ::= typeof_type + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=t; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(35/*type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 123: // type ::= functional_type + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=t; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(35/*type*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 122: // type_annotation ::= COL lf_opt doc_opt lf_opt type + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=t; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(34/*type_annotation*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 121: // type_annotation_opt ::= + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(33/*type_annotation_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 120: // type_annotation_opt ::= type_annotation + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=t; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(33/*type_annotation_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 119: // varargs_opt ::= + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(21/*varargs_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 118: // varargs_opt ::= DOTDOTDOT + { + Object RESULT = null; + int varargsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int varargsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object varargs = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=varargs; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(21/*varargs_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 117: // param ::= doc_opt lf_opt varargs_opt IDENTIFIER optional_opt type_annotation_opt doc_opt lf_opt + { + Object RESULT = null; + int varargsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left; + int varargsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).right; + Object varargs = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).value; + int ileft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left; + int iright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).right; + Object i = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).value; + int optleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left; + int optright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).right; + Object opt = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).value; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + + RESULT = new ParameterDeclaration( (Token)i, i.toString(), (TypeReference)t, (Boolean)opt, varargs!=null); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(19/*param*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-7)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 116: // param_list ::= param + { + Object RESULT = null; + int pleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int pright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object p = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + RESULT=new ParameterDeclaration[] { (ParameterDeclaration)p }; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(18/*param_list*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 115: // param_list ::= param_list lf_opt COMMA lf_opt param + { + Object RESULT = null; + int lleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left; + int lright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).right; + Object l = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).value; + int pleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int pright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object p = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + ParameterDeclaration[] list = (ParameterDeclaration[])l; + RESULT = ArrayUtils.add(list, (ParameterDeclaration)p); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(18/*param_list*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 114: // param_list_opt ::= lf_opt + { + Object RESULT = null; + RESULT = new ParameterDeclaration[0]; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(17/*param_list_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 113: // param_list_opt ::= lf_opt param_list lf_opt + { + Object RESULT = null; + int lleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int lright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object l = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + RESULT = l; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(17/*param_list_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 112: // index_sig_decl ::= declare_opt CONST type_param_list_opt LSPAREN param RSPAREN type_annotation_opt + { + Object RESULT = null; + int readonlyleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left; + int readonlyright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).right; + Object readonly = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).value; + int tparamsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left; + int tparamsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).right; + Object tparams = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).value; + int tokenleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left; + int tokenright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).right; + Object token = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).value; + int paramleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int paramright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object param = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + RESULT = new FunctionDeclaration((Token)token,FunctionDeclaration.INDEXSIG_RESERVED_NAME,(TypeReference)t, new ParameterDeclaration[] {(ParameterDeclaration)param}, (TypeParameterDeclaration[])tparams); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(14/*index_sig_decl*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 111: // index_sig_decl ::= declare_opt type_param_list_opt LSPAREN param RSPAREN type_annotation_opt + { + Object RESULT = null; + int tparamsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left; + int tparamsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).right; + Object tparams = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).value; + int tokenleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left; + int tokenright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).right; + Object token = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).value; + int paramleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int paramright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object param = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + RESULT = new FunctionDeclaration((Token)token,FunctionDeclaration.INDEXSIG_RESERVED_NAME,(TypeReference)t, new ParameterDeclaration[] {(ParameterDeclaration)param}, (TypeParameterDeclaration[])tparams); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(14/*index_sig_decl*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 110: // constructor_decl ::= declare_opt NEW type_param_list_opt LPAREN param_list_opt RPAREN type_annotation_opt + { + Object RESULT = null; + int modleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).left; + int modright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).right; + Object mod = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).value; + int tparamsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left; + int tparamsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).right; + Object tparams = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).value; + int tokenleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left; + int tokenright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).right; + Object token = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).value; + int paramsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int paramsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object params = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + //System.err.println("5"); + RESULT = new FunctionDeclaration((Token)token,FunctionDeclaration.NEW_FUNCTION_RESERVED_NAME,(TypeReference)t, (ParameterDeclaration[])params, (TypeParameterDeclaration[])tparams); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(13/*constructor_decl*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 109: // constructor_decl ::= declare_opt type_param_list_opt LPAREN param_list_opt RPAREN type_annotation_opt + { + Object RESULT = null; + int modleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left; + int modright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).right; + Object mod = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).value; + int tparamsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left; + int tparamsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).right; + Object tparams = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).value; + int tokenleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left; + int tokenright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).right; + Object token = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).value; + int paramsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int paramsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object params = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + //System.err.println("4"); + RESULT = new FunctionDeclaration((Token)token,FunctionDeclaration.ANONYMOUS_FUNCTION_RESERVED_NAME,(TypeReference)t, (ParameterDeclaration[])params, (TypeParameterDeclaration[])tparams); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(13/*constructor_decl*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 108: // func_decl ::= DECLARE_FUNCTION IDENTIFIER optional_opt type_param_list_opt LPAREN param_list_opt RPAREN type_annotation_opt + { + Object RESULT = null; + int nameleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).left; + int nameright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).right; + Object name = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).value; + int optleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left; + int optright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).right; + Object opt = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).value; + int tparamsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left; + int tparamsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).right; + Object tparams = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).value; + int paramsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int paramsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object params = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + //System.err.println("3"); + RESULT = new FunctionDeclaration((Token)name,name.toString(),(TypeReference)t, (ParameterDeclaration[])params, (TypeParameterDeclaration[])tparams); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(12/*func_decl*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-7)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 107: // func_decl ::= declare_opt FUNCTION IDENTIFIER optional_opt type_param_list_opt LPAREN param_list_opt RPAREN type_annotation_opt + { + Object RESULT = null; + int modleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-8)).left; + int modright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-8)).right; + Object mod = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-8)).value; + int nameleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).left; + int nameright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).right; + Object name = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).value; + int optleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left; + int optright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).right; + Object opt = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).value; + int tparamsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left; + int tparamsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).right; + Object tparams = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).value; + int paramsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int paramsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object params = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + //System.err.println("2"); + FunctionDeclaration func = new FunctionDeclaration((Token)name,name.toString(),(TypeReference)t, (ParameterDeclaration[])params, (TypeParameterDeclaration[])tparams); + if(mod!=null) func.addModifier((String)mod); + func.setHidden(func.hasModifier("private")); + RESULT = func; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(12/*func_decl*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-8)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 106: // func_decl ::= declare_opt IDENTIFIER optional_opt type_param_list_opt LPAREN param_list_opt RPAREN type_annotation_opt + { + Object RESULT = null; + int modleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-7)).left; + int modright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-7)).right; + Object mod = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-7)).value; + int nameleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).left; + int nameright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).right; + Object name = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).value; + int optleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left; + int optright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).right; + Object opt = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).value; + int tparamsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left; + int tparamsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).right; + Object tparams = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).value; + int paramsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int paramsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object params = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + //System.err.println("1"); + FunctionDeclaration func = new FunctionDeclaration((Token)name,name.toString(),(TypeReference)t, (ParameterDeclaration[])params, (TypeParameterDeclaration[])tparams); + if(mod!=null) func.addModifier((String)mod); + func.setHidden(func.hasModifier("private")); + RESULT = func; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(12/*func_decl*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-7)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 105: // optional_opt ::= + { + Object RESULT = null; + RESULT=false; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(20/*optional_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 104: // optional_opt ::= QUESTION + { + Object RESULT = null; + RESULT=true; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(20/*optional_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 103: // var_decl ::= declare_opt NEW optional_opt lf_opt type_annotation_opt + { + Object RESULT = null; + int modleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left; + int modright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).right; + Object mod = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).value; + int nameleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left; + int nameright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).right; + Object name = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).value; + int optleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int optright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object opt = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + VariableDeclaration var = new VariableDeclaration((Token)name,name.toString(),(TypeReference)t, (Boolean)opt, false); + if(mod!=null) var.addModifier((String)mod); + var.setHidden(var.hasModifier("private")); + RESULT = var; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(10/*var_decl*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 102: // var_decl ::= declare_opt INT optional_opt lf_opt type_annotation_opt + { + Object RESULT = null; + int modleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left; + int modright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).right; + Object mod = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).value; + int nameleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left; + int nameright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).right; + Object name = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).value; + int optleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int optright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object opt = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + VariableDeclaration var = new VariableDeclaration((Token)name,name.toString(),(TypeReference)t, (Boolean)opt, false); + if(mod!=null) var.addModifier((String)mod); + var.setHidden(var.hasModifier("private")); + RESULT = var; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(10/*var_decl*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 101: // var_decl ::= declare_opt IDENTIFIER optional_opt lf_opt type_annotation_opt + { + Object RESULT = null; + int modleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left; + int modright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).right; + Object mod = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).value; + int nameleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left; + int nameright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).right; + Object name = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).value; + int optleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int optright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object opt = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + VariableDeclaration var = new VariableDeclaration((Token)name,name.toString(),(TypeReference)t, (Boolean)opt, false); + if(mod!=null) var.addModifier((String)mod); + var.setHidden(var.hasModifier("private")); + RESULT = var; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(10/*var_decl*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 100: // var_decl ::= declare_opt var_or_const IDENTIFIER optional_opt lf_opt type_annotation_opt + { + Object RESULT = null; + int modleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left; + int modright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).right; + Object mod = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).value; + int readonlyleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left; + int readonlyright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).right; + Object readonly = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).value; + int nameleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left; + int nameright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).right; + Object name = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).value; + int optleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int optright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object opt = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + VariableDeclaration var = new VariableDeclaration((Token)name,name.toString(),(TypeReference)t, (Boolean)opt, (Boolean)readonly); + if(mod!=null) var.addModifier((String)mod); + var.setHidden(var.hasModifier("private")); + RESULT = var; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(10/*var_decl*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 99: // var_or_const ::= CONST + { + Object RESULT = null; + RESULT = true; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(72/*var_or_const*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 98: // var_or_const ::= VAR + { + Object RESULT = null; + RESULT=false; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(72/*var_or_const*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 97: // module_decl ::= DECLARE_MODULE qual_id lf_opt LCPAREN declaration_list_opt RCPAREN + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).value; + int nameleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left; + int nameright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).right; + Object name = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).value; + int declarationsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int declarationsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object declarations = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + + RESULT = ModuleDeclaration.createQualifiedModuleDeclaration((Token)t,name.toString(),(Declaration[])declarations); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(11/*module_decl*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 96: // module_decl ::= declare_opt IDENTIFIER qual_id lf_opt LCPAREN declaration_list_opt RCPAREN + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).value; + int nameleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left; + int nameright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).right; + Object name = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).value; + int declarationsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int declarationsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object declarations = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + + if(!(t.toString().equals("module")||t.toString().equals("namespace"))) { + parser.syntax_error((Token)t); + } + RESULT = ModuleDeclaration.createQualifiedModuleDeclaration((Token)t,name.toString(),(Declaration[])declarations); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(11/*module_decl*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 95: // member_elt_nodoc ::= constructor_decl + { + Object RESULT = null; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=d; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(26/*member_elt_nodoc*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 94: // member_elt_nodoc ::= index_sig_decl + { + Object RESULT = null; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=d; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(26/*member_elt_nodoc*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 93: // member_elt_nodoc ::= func_decl + { + Object RESULT = null; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=d; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(26/*member_elt_nodoc*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 92: // member_elt_nodoc ::= var_decl + { + Object RESULT = null; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=d; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(26/*member_elt_nodoc*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 91: // doc_opt ::= + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(69/*doc_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 90: // doc_opt ::= DOC + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(69/*doc_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 89: // doc_list_opt ::= + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(68/*doc_list_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 88: // doc_list_opt ::= doc_list + { + Object RESULT = null; + int lleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int lright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object l = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=l; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(68/*doc_list_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 87: // doc_list ::= DOC lf_opt + { + Object RESULT = null; + int docleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int docright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object doc = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + RESULT=doc; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(67/*doc_list*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 86: // doc_list ::= DOC lf_opt doc_list + { + Object RESULT = null; + int docleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int docright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object doc = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + RESULT=doc; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(67/*doc_list*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 85: // member_elt ::= DOC + { + Object RESULT = null; + int docleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int docright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object doc = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + RESULT=doc; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(25/*member_elt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 84: // member_elt ::= member_elt_nodoc + { + Object RESULT = null; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + RESULT=d; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(25/*member_elt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 83: // member_elt_with_error ::= error + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(24/*member_elt_with_error*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 82: // member_elt_with_error ::= member_elt + { + Object RESULT = null; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=d; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(24/*member_elt_with_error*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 81: // member_list ::= member_elt_with_error + { + Object RESULT = null; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + if(d instanceof Declaration) { + parser.comments.push(new Token[] { null }); + RESULT = new Declaration[] { (Declaration)d }; + } else { + parser.comments.push(new Token[] { (Token)d }); + RESULT = new Declaration[0]; + } + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(23/*member_list*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 80: // member_list ::= member_list semi_or_comma_or_lf member_elt_with_error + { + Object RESULT = null; + int lleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int lright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object l = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + if(d instanceof Declaration) { + Declaration[] list = (Declaration[])l; + Token doc = parser.comments.peek()[0]; + if(doc!=null) { + ((Declaration)d).setDocumentation(doc.toString()); + parser.comments.peek()[0]=null; + } + RESULT = ArrayUtils.add(list, (Declaration)d); + } else { + if(d instanceof Token) { + parser.comments.peek()[0] = (Token)d; + } + RESULT=l; + } + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(23/*member_list*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 79: // semi_or_comma_or_lf_opt ::= + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(65/*semi_or_comma_or_lf_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 78: // semi_or_comma_or_lf_opt ::= semi_or_comma_or_lf + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(65/*semi_or_comma_or_lf_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 77: // semi_or_comma_or_lf ::= lf + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(64/*semi_or_comma_or_lf*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 76: // semi_or_comma_or_lf ::= COMMA + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(64/*semi_or_comma_or_lf*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 75: // semi_or_comma_or_lf ::= COMMA lf + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(64/*semi_or_comma_or_lf*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 74: // semi_or_comma_or_lf ::= SEMI + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(64/*semi_or_comma_or_lf*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 73: // semi_or_comma_or_lf ::= SEMI lf + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(64/*semi_or_comma_or_lf*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 72: // semi_or_lf_opt ::= + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(62/*semi_or_lf_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 71: // semi_or_lf_opt ::= semi_or_lf + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(62/*semi_or_lf_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 70: // semi_or_lf ::= lf + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(61/*semi_or_lf*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 69: // semi_or_lf ::= SEMI + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(61/*semi_or_lf*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 68: // semi_or_lf ::= SEMI lf + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(61/*semi_or_lf*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 67: // lf_opt ::= + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(63/*lf_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 66: // lf_opt ::= lf + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(63/*lf_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 65: // lf ::= LF + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(60/*lf*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 64: // lf ::= lf LF + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(60/*lf*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 63: // member_list_opt ::= lf_opt + { + Object RESULT = null; + RESULT = new Declaration[0]; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(22/*member_list_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 62: // member_list_opt ::= lf_opt member_list semi_or_comma_or_lf_opt + { + Object RESULT = null; + int lleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int lright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object l = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + + parser.comments.pop(); + RESULT = l; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(22/*member_list_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 61: // type_list ::= type + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + RESULT=new TypeReference[] { (TypeReference)t }; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(66/*type_list*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 60: // type_list ::= type_list COMMA lf_opt type + { + Object RESULT = null; + int lleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left; + int lright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).right; + Object l = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).value; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + TypeReference[] list = (TypeReference[])l; + RESULT = ArrayUtils.add(list, (TypeReference)t); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(66/*type_list*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 59: // implements_opt ::= + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(59/*implements_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 58: // implements_opt ::= IMPLEMENTS lf_opt type_list + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT = t; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(59/*implements_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 57: // extends_opt ::= + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(58/*extends_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 56: // extends_opt ::= EXTENDS type_list + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT = t; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(58/*extends_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 55: // type_kind ::= CLASS + { + Object RESULT = null; + int defleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int defright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object def = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=def; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(9/*type_kind*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 54: // type_kind ::= INTERFACE + { + Object RESULT = null; + int defleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int defright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object def = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=def; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(9/*type_kind*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 53: // literal ::= INT + { + Object RESULT = null; + int ileft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int iright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object i = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=i; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(70/*literal*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 52: // enum_member_elt_nodoc ::= IDENTIFIER ASSIGN literal + { + Object RESULT = null; + int nameleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int nameright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object name = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int valueleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int valueright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object value = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + Literal literal = new Literal((Token)value, value.toString()); + VariableDeclaration var = new VariableDeclaration((Token)name, name.toString(), null, false, true); + var.setInitializer(literal); + RESULT = var; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(32/*enum_member_elt_nodoc*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 51: // enum_member_elt_nodoc ::= IDENTIFIER + { + Object RESULT = null; + int nameleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int nameright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object name = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + RESULT = new VariableDeclaration((Token)name, name.toString(), null, false, true); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(32/*enum_member_elt_nodoc*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 50: // enum_member_elt ::= enum_member_elt_nodoc + { + Object RESULT = null; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + RESULT=d; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(31/*enum_member_elt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 49: // enum_member_elt ::= doc_list lf_opt enum_member_elt_nodoc + { + Object RESULT = null; + int docleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int docright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object doc = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + if(d!=null) { + Declaration decl = (Declaration)d; + decl.setDocumentation(doc.toString()); + RESULT=d; + } + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(31/*enum_member_elt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 48: // enum_member_elt_with_error ::= error + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(30/*enum_member_elt_with_error*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 47: // enum_member_elt_with_error ::= enum_member_elt + { + Object RESULT = null; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=d; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(30/*enum_member_elt_with_error*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 46: // enum_member_list ::= enum_member_list COMMA lf_opt doc_list lf_opt + { + Object RESULT = null; + int lleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left; + int lright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).right; + Object l = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).value; + + RESULT=l; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(28/*enum_member_list*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 45: // enum_member_list ::= enum_member_list lf_opt doc_list lf_opt + { + Object RESULT = null; + int lleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left; + int lright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).right; + Object l = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).value; + + RESULT=l; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(28/*enum_member_list*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 44: // enum_member_list ::= enum_member_list COMMA lf_opt + { + Object RESULT = null; + int lleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int lright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object l = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + + RESULT=l; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(28/*enum_member_list*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 43: // enum_member_list ::= enum_member_elt_with_error + { + Object RESULT = null; + int eleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int eright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object e = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + if(e!=null) { + RESULT=new Declaration[] { (Declaration)e }; + } else { + RESULT=new Declaration[0]; + } + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(28/*enum_member_list*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 42: // enum_member_list ::= enum_member_list COMMA lf_opt enum_member_elt_with_error + { + Object RESULT = null; + int lleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left; + int lright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).right; + Object l = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).value; + int eleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int eright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object e = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + if(e!=null) { + Declaration[] list = (Declaration[])l; + RESULT = ArrayUtils.add(list, (Declaration)e); + } else { + RESULT=l; + } + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(28/*enum_member_list*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 41: // enum_member_list_opt ::= lf_opt + { + Object RESULT = null; + RESULT = new Declaration[0]; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(29/*enum_member_list_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 40: // enum_member_list_opt ::= lf_opt enum_member_list lf_opt + { + Object RESULT = null; + int lleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int lright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object l = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + RESULT = l; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(29/*enum_member_list_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 39: // enum_decl ::= declare_opt const_opt ENUM IDENTIFIER type_param_list_opt lf_opt LCPAREN enum_member_list_opt RCPAREN + { + Object RESULT = null; + int nameleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left; + int nameright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).right; + Object name = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).value; + int tparamsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left; + int tparamsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).right; + Object tparams = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).value; + int membersleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int membersright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object members = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + + RESULT = new TypeDeclaration((Token)name,"enum",name.toString(),(TypeParameterDeclaration[])tparams,null,(Declaration[])members); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(27/*enum_decl*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-8)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 38: // enum_decl ::= declare_opt DECLARE_ENUM IDENTIFIER type_param_list_opt lf_opt LCPAREN enum_member_list_opt RCPAREN + { + Object RESULT = null; + int nameleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left; + int nameright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).right; + Object name = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).value; + int tparamsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left; + int tparamsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).right; + Object tparams = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).value; + int membersleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int membersright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object members = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + + RESULT = new TypeDeclaration((Token)name,"enum",name.toString(),(TypeParameterDeclaration[])tparams,null,(Declaration[])members); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(27/*enum_decl*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-7)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 37: // abstract_opt ::= + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(73/*abstract_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 36: // abstract_opt ::= ABSTRACT + { + Object RESULT = null; + RESULT = "abstract"; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(73/*abstract_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 35: // const_opt ::= + { + Object RESULT = null; + RESULT = false; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(49/*const_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 34: // const_opt ::= CONST + { + Object RESULT = null; + RESULT = true; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(49/*const_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 33: // type_decl ::= declare_opt DECLARE_CLASS IDENTIFIER type_param_list_opt extends_opt implements_opt lf_opt LCPAREN member_list_opt RCPAREN + { + Object RESULT = null; + int nameleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-7)).left; + int nameright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-7)).right; + Object name = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-7)).value; + int tparamsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).left; + int tparamsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).right; + Object tparams = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).value; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).value; + int t2left = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left; + int t2right = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).right; + Object t2 = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).value; + int membersleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int membersright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object members = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + + RESULT = new TypeDeclaration((Token)name,"class",name.toString(),(TypeParameterDeclaration[])tparams,t==null?(TypeReference[])t2:ArrayUtils.addAll((TypeReference[])t,(TypeReference[])t2),(Declaration[])members); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(8/*type_decl*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-9)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 32: // type_decl ::= declare_opt abstract_opt type_kind IDENTIFIER type_param_list_opt extends_opt implements_opt lf_opt LCPAREN member_list_opt RCPAREN + { + Object RESULT = null; + int defleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-8)).left; + int defright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-8)).right; + Object def = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-8)).value; + int nameleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-7)).left; + int nameright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-7)).right; + Object name = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-7)).value; + int tparamsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).left; + int tparamsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).right; + Object tparams = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-6)).value; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).value; + int t2left = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left; + int t2right = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).right; + Object t2 = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).value; + int membersleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int membersright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object members = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + + RESULT = new TypeDeclaration((Token)name,def.toString(),name.toString(),(TypeParameterDeclaration[])tparams,t==null?(TypeReference[])t2:ArrayUtils.addAll((TypeReference[])t,(TypeReference[])t2),(Declaration[])members); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(8/*type_decl*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-10)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 31: // type_macro ::= EXPORT TYPE_MACRO IDENTIFIER type_param_list_opt ASSIGN type + { + Object RESULT = null; + int aliasleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left; + int aliasright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).right; + Object alias = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).value; + int tparamsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int tparamsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object tparams = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int typeleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int typeright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object type = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + RESULT = new TypeMacroDeclaration((Token)alias, alias.toString(), (TypeParameterDeclaration[])tparams, (TypeReference)type); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(7/*type_macro*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 30: // type_macro ::= TYPE_MACRO IDENTIFIER type_param_list_opt ASSIGN lf_opt type + { + Object RESULT = null; + int aliasleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left; + int aliasright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).right; + Object alias = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).value; + int tparamsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left; + int tparamsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).right; + Object tparams = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).value; + int typeleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int typeright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object type = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + RESULT = new TypeMacroDeclaration((Token)alias, alias.toString(), (TypeParameterDeclaration[])tparams, (TypeReference)type); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(7/*type_macro*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 29: // import_spec ::= IDENTIFIER ASSIGN IDENTIFIER LPAREN qual_id RPAREN + { + Object RESULT = null; + int aliasleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left; + int aliasright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).right; + Object alias = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).value; + int requireleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left; + int requireright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).right; + Object require = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).value; + int importedleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int importedright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object imported = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + + if(!"require".equals(require.toString())) { + parser.syntax_error((Token)require); + } else { + RESULT = new ReferenceDeclaration((Token)alias, alias.toString(), imported.toString()); + } + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(51/*import_spec*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-5)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 28: // import_spec ::= IDENTIFIER ASSIGN qual_id + { + Object RESULT = null; + int aliasleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int aliasright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object alias = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int importedleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int importedright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object imported = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + RESULT = new ReferenceDeclaration((Token)alias, alias.toString(), imported.toString()); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(51/*import_spec*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 27: // import_spec ::= MULT AS IDENTIFIER FROM qual_id + { + Object RESULT = null; + int aliasleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int aliasright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object alias = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int importedleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int importedright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object imported = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + RESULT = new ReferenceDeclaration((Token)alias, alias.toString(), imported.toString()); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(51/*import_spec*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 26: // import_decl ::= export_opt IMPORT import_spec + { + Object RESULT = null; + int sleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int sright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object s = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + RESULT = s; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(16/*import_decl*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 25: // export_opt ::= + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(71/*export_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 24: // export_opt ::= EXPORT + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(71/*export_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 23: // export_element ::= IDENTIFIER AS IDENTIFIER + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(75/*export_element*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 22: // export_element ::= IDENTIFIER + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(75/*export_element*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 21: // export_element_list ::= export_element + { + Object RESULT = null; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(74/*export_element_list*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 20: // export_element_list ::= export_element_list COMMA lf_opt export_element + { + Object RESULT = null; + int lleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left; + int lright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).right; + Object l = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).value; + int tleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int tright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object t = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(74/*export_element_list*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 19: // export_decl ::= EXPORT LCPAREN export_element_list RCPAREN lf_opt + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(15/*export_decl*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-4)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 18: // export_decl ::= EXPORT ASSIGN IDENTIFIER lf_opt + { + Object RESULT = null; + int exportedIdentifierleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int exportedIdentifierright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object exportedIdentifier = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + + RESULT = new ReferenceDeclaration((Token)exportedIdentifier, null, exportedIdentifier.toString()); + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(15/*export_decl*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-3)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 17: // declaration_nodoc ::= import_decl + { + Object RESULT = null; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=d; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(6/*declaration_nodoc*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 16: // declaration_nodoc ::= export_decl + { + Object RESULT = null; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=d; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(6/*declaration_nodoc*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 15: // declaration_nodoc ::= func_decl + { + Object RESULT = null; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=d; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(6/*declaration_nodoc*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 14: // declaration_nodoc ::= var_decl + { + Object RESULT = null; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=d; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(6/*declaration_nodoc*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 13: // declaration_nodoc ::= module_decl + { + Object RESULT = null; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=d; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(6/*declaration_nodoc*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 12: // declaration_nodoc ::= enum_decl + { + Object RESULT = null; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=d; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(6/*declaration_nodoc*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 11: // declaration_nodoc ::= type_decl + { + Object RESULT = null; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=d; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(6/*declaration_nodoc*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 10: // declaration_nodoc ::= type_macro + { + Object RESULT = null; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=d; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(6/*declaration_nodoc*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 9: // declaration ::= DOC + { + Object RESULT = null; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + RESULT=d; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(5/*declaration*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 8: // declaration ::= declaration_nodoc + { + Object RESULT = null; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=d; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(5/*declaration*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 7: // declaration_with_error ::= error + { + Object RESULT = null; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(4/*declaration_with_error*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 6: // declaration_with_error ::= declaration + { + Object RESULT = null; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + RESULT=d; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(4/*declaration_with_error*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 5: // declaration_list ::= declaration_with_error + { + Object RESULT = null; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + if(d instanceof Declaration) { + parser.comments.push(new Token[] { null }); + RESULT = new Declaration[] { (Declaration)d }; + } else { + parser.comments.push(new Token[] { (Token)d }); + RESULT = new Declaration[0]; + } + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(3/*declaration_list*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 4: // declaration_list ::= declaration_list semi_or_lf declaration_with_error + { + Object RESULT = null; + int lleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left; + int lright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).right; + Object l = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).value; + int dleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int dright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object d = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + + if(d instanceof Declaration) { + Declaration[] list = (Declaration[])l; + Token doc = parser.comments.peek()[0]; + if(doc!=null) { + ((Declaration)d).setDocumentation(doc.toString()); + parser.comments.peek()[0]=null; + } + RESULT = ArrayUtils.add(list, (Declaration)d); + } else { + if(d instanceof Token) { + parser.comments.peek()[0] = (Token)d; + } + RESULT = l; + } + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(3/*declaration_list*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 3: // declaration_list_opt ::= lf_opt + { + Object RESULT = null; + RESULT = new Declaration[0]; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(2/*declaration_list_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 2: // declaration_list_opt ::= lf_opt declaration_list semi_or_lf_opt + { + Object RESULT = null; + int lleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int lright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object l = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + + parser.comments.pop(); + RESULT = l; + + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(2/*declaration_list_opt*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 1: // comp_unit ::= declaration_list_opt + { + Object RESULT = null; + int declsleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left; + int declsright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right; + Object decls = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).value; + parser.compilationUnit.setDeclarations((Declaration[])decls); + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(1/*comp_unit*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + return CUP$TypescriptDefParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 0: // $START ::= comp_unit EOF + { + Object RESULT = null; + int start_valleft = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left; + int start_valright = ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).right; + Object start_val = (Object)((java_cup.runtime.Symbol) CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).value; + RESULT = start_val; + CUP$TypescriptDefParser$result = new java_cup.runtime.Symbol(0/*$START*/, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-1)).left, ((java_cup.runtime.Symbol)CUP$TypescriptDefParser$stack.elementAt(CUP$TypescriptDefParser$top-0)).right, RESULT); + } + /* ACCEPT */ + CUP$TypescriptDefParser$parser.done_parsing(); + return CUP$TypescriptDefParser$result; + + /* . . . . . .*/ + default: + throw new Exception( + "Invalid action number found in internal parse table"); + + } + } +} + diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/TypescriptDefScanner.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/TypescriptDefScanner.java new file mode 100644 index 00000000..cf7da73f --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/TypescriptDefScanner.java @@ -0,0 +1,1329 @@ +/* The following code was generated by JFlex 1.3.5 on 7/24/16 4:44 PM */ + + +/* + * This source code file is the exclusive property of its author. No copy or + * usage of the source code is permitted unless the author contractually + * allows it under the terms of a well-defined agreement. + */ + +package org.jsweet.input.typescriptdef.parser; + +import java_cup.runtime.*; +import org.jsweet.input.typescriptdef.ast.Token; +import java.util.*; + + +/** + * This class is a scanner generated by + * JFlex 1.3.5 + * on 7/24/16 4:44 PM from the specification file + * file:/Users/renaudpawlak/Documents/workspace/jsweet-def-translators/src/org/jsweet/input/typescriptdef/parser/typescriptdef.lex + */ +@SuppressWarnings("all") +class TypescriptDefScanner implements java_cup.runtime.Scanner { + + /** This character denotes the end of file */ + final public static int YYEOF = -1; + + /** initial size of the lookahead buffer */ + final private static int YY_BUFFERSIZE = 16384; + + /** lexical states */ + final public static int EOL_COMMENT = 4; + final public static int STRING = 1; + final public static int YYINITIAL = 0; + final public static int TYPE_MACRO = 3; + final public static int CHAR = 2; + + /** + * Translates characters to character classes + */ + final private static String yycmap_packed = + "\11\0\1\3\1\2\1\0\1\3\1\1\22\0\1\3\1\61\1\5"+ + "\1\0\1\14\1\0\1\65\1\23\1\11\1\10\1\7\1\20\1\60"+ + "\1\21\1\22\1\6\1\15\11\16\1\53\1\54\1\57\1\12\1\13"+ + "\1\64\1\66\6\17\21\14\1\52\2\14\1\24\1\4\1\56\1\0"+ + "\1\14\1\0\1\33\1\47\1\34\1\37\1\30\1\32\2\14\1\25"+ + "\2\14\1\35\1\40\1\26\1\41\1\43\1\14\1\31\1\36\1\27"+ + "\1\42\1\46\1\51\1\45\1\44\1\14\1\50\1\63\1\55\1\62"+ + "\ufe80\0\1\67\u0100\0"; + + /** + * Translates characters to character classes + */ + final private static char [] yycmap = yy_unpack_cmap(yycmap_packed); + + /** + * Translates a state to a row index in the transition table + */ + final private static int yy_rowMap [] = { + 0, 56, 112, 168, 224, 280, 336, 392, 280, 280, + 448, 280, 504, 560, 616, 672, 728, 784, 840, 896, + 952, 1008, 280, 1064, 1120, 1176, 1232, 1288, 1344, 1400, + 1456, 1512, 1568, 1624, 1680, 1736, 1792, 280, 280, 280, + 280, 280, 1848, 280, 1904, 280, 1960, 280, 2016, 280, + 2072, 2128, 280, 2184, 2240, 2296, 2352, 2408, 2464, 2520, + 2576, 280, 392, 2632, 2688, 2744, 2800, 280, 2856, 504, + 2912, 560, 2968, 3024, 280, 280, 280, 3080, 280, 3136, + 280, 280, 3192, 1064, 280, 3248, 3304, 3360, 3416, 3472, + 3528, 3584, 3640, 3696, 3752, 3808, 3864, 3920, 3976, 4032, + 4088, 4144, 4200, 4256, 4312, 280, 280, 4368, 280, 4424, + 280, 280, 280, 280, 280, 280, 280, 280, 4480, 4536, + 4592, 4648, 4704, 4760, 4816, 4872, 4928, 280, 4984, 5040, + 3080, 280, 5096, 5152, 5208, 728, 5264, 5320, 5376, 5432, + 5488, 5544, 5600, 5656, 5712, 5768, 5824, 5880, 5936, 5992, + 6048, 6104, 6160, 6216, 6272, 6328, 6384, 6440, 6496, 6552, + 6608, 6664, 6720, 6776, 6832, 280, 6888, 6944, 280, 7000, + 7056, 7112, 7168, 7224, 7280, 7336, 7392, 7448, 280, 7504, + 7560, 7616, 7672, 7728, 7784, 7840, 7896, 7952, 8008, 280, + 8064, 8120, 8176, 8232, 8288, 280, 8344, 6776, 8400, 8456, + 8512, 8568, 8624, 8680, 8736, 8792, 8848, 8904, 8960, 9016, + 9072, 9128, 9184, 280, 9240, 9296, 9352, 9408, 9464, 9520, + 9576, 9632, 9688, 9744, 280, 9800, 9856, 9912, 9968, 10024, + 10080, 280, 10136, 10192, 10248, 280, 10304, 10360, 10416, 10472, + 10528, 10584, 10640, 10696, 10752, 10808, 280, 10864, 10920, 10976, + 11032, 11088, 280, 11144, 11200, 11256, 11312, 280, 11368, 11424, + 11480, 280, 280, 11536, 11592, 11648, 11704, 11760, 11816, 11872, + 280, 11928, 11984, 280, 12040, 12096, 12152, 280, 12208, 12264, + 12320, 12376, 12432, 12488, 12544, 12600, 12656, 280, 12712, 12768, + 12824, 12880, 12936, 12992, 13048, 13104, 13160, 13216, 13272, 13328, + 280, 13104, 13160, 13216, 13272, 13328, 13384, 13440, 13496, 13552, + 13608, 280, 13664, 13720, 13776, 13832, 13888, 280, 280, 13944, + 14000, 14056, 14112, 14168, 14224, 14280, 14336, 14392, 14448, 14504, + 280, 14560, 14616, 14672, 14728, 14784, 14840, 14896, 14952, 728, + 15008, 15064, 15120, 280, 280, 15176, 280, 15232, 15288, 15344, + 15400, 15456, 728, 15512, 15568, 15624, 280, 15680, 15736, 15792, + 728, 15848, 15904, 280, 15960, 16016, 16072, 16128, 728, 280 + }; + + /** + * The packed transition table of the DFA (part 0) + */ + final private static String yy_packed0 = + "\1\6\1\7\1\10\1\11\1\6\1\12\1\13\1\14"+ + "\1\15\1\16\1\17\1\20\1\21\1\22\1\23\1\21"+ + "\1\24\1\25\1\26\1\27\1\30\1\31\1\32\1\33"+ + "\1\34\1\35\1\36\1\37\1\40\1\41\1\42\1\43"+ + "\3\21\1\44\2\21\1\45\1\21\1\46\2\21\1\47"+ + "\1\50\1\51\1\52\1\53\1\54\1\55\1\56\1\57"+ + "\1\60\1\61\1\62\1\11\1\63\2\6\1\63\1\64"+ + "\1\65\62\63\1\66\2\6\1\66\1\67\16\66\1\65"+ + "\44\66\1\6\2\70\1\71\23\6\1\72\1\73\6\6"+ + "\1\74\30\6\1\11\1\75\1\76\65\11\72\0\1\10"+ + "\1\77\23\0\1\100\1\101\6\0\1\102\13\0\1\47"+ + "\7\0\1\103\7\0\1\77\23\0\1\100\1\101\6\0"+ + "\1\102\13\0\1\47\7\0\1\103\12\0\1\104\1\105"+ + "\63\0\1\106\6\0\1\107\55\0\10\110\1\111\1\112"+ + "\56\110\12\0\1\113\1\114\66\0\1\115\71\0\4\21"+ + "\5\0\23\21\1\0\2\21\31\0\4\21\5\0\20\21"+ + "\1\116\2\21\1\0\1\21\1\116\31\0\1\21\2\23"+ + "\1\21\5\0\23\21\1\0\2\21\32\0\1\117\1\120"+ + "\1\0\1\121\64\0\1\117\1\120\2\0\1\122\70\0"+ + "\1\123\50\0\1\124\52\0\1\125\25\0\4\21\5\0"+ + "\1\21\1\126\7\21\1\127\1\21\1\130\7\21\1\0"+ + "\2\21\31\0\4\21\5\0\3\21\1\131\17\21\1\0"+ + "\2\21\31\0\4\21\5\0\17\21\1\132\3\21\1\0"+ + "\2\21\31\0\4\21\5\0\1\21\1\133\16\21\1\134"+ + "\2\21\1\0\2\21\31\0\4\21\5\0\3\21\1\135"+ + "\17\21\1\0\2\21\31\0\4\21\5\0\4\21\1\136"+ + "\10\21\1\137\5\21\1\0\2\21\31\0\4\21\5\0"+ + "\11\21\1\140\10\21\1\141\1\0\2\21\31\0\4\21"+ + "\5\0\10\21\1\142\3\21\1\143\6\21\1\0\2\21"+ + "\31\0\4\21\5\0\3\21\1\144\17\21\1\0\2\21"+ + "\31\0\4\21\5\0\2\21\1\145\20\21\1\0\2\21"+ + "\31\0\4\21\5\0\3\21\1\146\17\21\1\0\2\21"+ + "\31\0\4\21\5\0\4\21\1\147\10\21\1\150\5\21"+ + "\1\0\2\21\31\0\4\21\5\0\6\21\1\151\14\21"+ + "\1\0\2\21\27\0\1\152\67\0\1\153\56\0\1\154"+ + "\1\155\1\156\57\0\1\157\71\0\1\160\2\0\1\63"+ + "\2\0\1\63\2\0\62\63\4\0\1\161\1\162\20\0"+ + "\1\163\1\164\1\0\1\165\36\0\1\66\2\0\1\66"+ + "\1\0\16\66\1\0\44\66\4\0\1\161\16\0\1\166"+ + "\2\0\1\163\1\164\1\0\1\165\37\0\3\70\2\0"+ + "\1\167\64\0\1\71\130\0\1\170\70\0\1\171\52\0"+ + "\1\172\41\0\1\76\131\0\1\173\70\0\1\174\52\0"+ + "\1\175\40\0\1\154\1\155\1\103\64\0\7\176\1\177"+ + "\60\176\13\0\1\200\57\0\1\111\6\0\1\201\55\0"+ + "\10\112\1\110\1\202\56\112\14\0\1\21\3\203\5\0"+ + "\3\21\1\203\1\21\3\203\2\21\1\203\7\21\1\203"+ + "\1\0\2\21\32\0\2\120\73\0\1\204\61\0\4\21"+ + "\5\0\2\21\1\205\20\21\1\0\2\21\20\0\1\206"+ + "\10\0\4\21\5\0\23\21\1\0\2\21\31\0\4\21"+ + "\5\0\16\21\1\207\4\21\1\0\2\21\31\0\4\21"+ + "\5\0\23\21\1\0\1\210\1\21\31\0\4\21\5\0"+ + "\16\21\1\211\4\21\1\0\2\21\31\0\4\21\5\0"+ + "\15\21\1\212\5\21\1\0\2\21\31\0\4\21\5\0"+ + "\2\21\1\213\13\21\1\214\4\21\1\0\2\21\31\0"+ + "\4\21\5\0\6\21\1\215\14\21\1\0\2\21\31\0"+ + "\4\21\5\0\14\21\1\216\6\21\1\0\2\21\31\0"+ + "\4\21\5\0\1\21\1\217\21\21\1\0\2\21\20\0"+ + "\1\220\10\0\4\21\5\0\23\21\1\0\2\21\31\0"+ + "\4\21\5\0\11\21\1\221\11\21\1\0\2\21\31\0"+ + "\4\21\5\0\6\21\1\222\14\21\1\0\2\21\31\0"+ + "\4\21\5\0\1\21\1\223\21\21\1\0\2\21\31\0"+ + "\4\21\5\0\2\21\1\224\20\21\1\0\2\21\31\0"+ + "\4\21\5\0\6\21\1\225\14\21\1\0\2\21\31\0"+ + "\4\21\5\0\7\21\1\226\13\21\1\0\2\21\31\0"+ + "\4\21\5\0\1\227\13\21\1\230\6\21\1\0\2\21"+ + "\31\0\4\21\5\0\22\21\1\231\1\0\2\21\31\0"+ + "\4\21\5\0\4\21\1\224\16\21\1\0\2\21\17\0"+ + "\1\155\66\0\1\154\1\155\1\156\72\0\1\232\1\233"+ + "\123\0\1\234\67\0\1\235\60\0\1\236\76\0\1\237"+ + "\67\0\1\240\60\0\1\241\33\0\7\176\1\242\60\176"+ + "\6\243\1\244\1\245\60\243\13\0\1\246\54\0\10\202"+ + "\1\112\1\247\56\202\14\0\4\21\5\0\3\21\1\250"+ + "\17\21\1\0\2\21\20\0\1\206\1\0\2\251\5\0"+ + "\4\251\3\0\1\251\1\0\23\251\1\0\2\251\31\0"+ + "\4\21\5\0\10\21\1\252\3\21\1\253\6\21\1\0"+ + "\2\21\31\0\4\21\5\0\3\21\1\254\17\21\1\0"+ + "\2\21\31\0\4\21\5\0\13\21\1\255\7\21\1\0"+ + "\2\21\31\0\4\21\5\0\3\21\1\256\17\21\1\0"+ + "\2\21\31\0\4\21\5\0\14\21\1\257\6\21\1\0"+ + "\2\21\31\0\4\21\5\0\12\21\1\260\10\21\1\0"+ + "\2\21\31\0\4\21\5\0\13\21\1\261\7\21\1\0"+ + "\2\21\31\0\4\21\5\0\7\21\1\262\13\21\1\0"+ + "\2\21\20\0\1\220\1\0\2\263\5\0\4\263\3\0"+ + "\1\263\1\0\23\263\1\0\2\263\31\0\4\21\5\0"+ + "\2\21\1\264\20\21\1\0\2\21\31\0\4\21\5\0"+ + "\11\21\1\265\11\21\1\0\2\21\31\0\4\21\5\0"+ + "\11\21\1\266\11\21\1\0\2\21\20\0\1\267\10\0"+ + "\4\21\5\0\23\21\1\0\2\21\31\0\4\21\5\0"+ + "\2\21\1\270\20\21\1\0\2\21\31\0\4\21\5\0"+ + "\10\21\1\271\12\21\1\0\2\21\31\0\4\21\5\0"+ + "\21\21\1\272\1\21\1\0\2\21\31\0\4\21\5\0"+ + "\2\21\1\273\20\21\1\0\2\21\31\0\4\21\5\0"+ + "\10\21\1\274\12\21\1\0\2\21\15\0\1\232\2\70"+ + "\65\232\7\233\1\275\60\233\30\0\1\276\100\0\1\277"+ + "\63\0\1\300\62\0\1\301\100\0\1\302\63\0\1\303"+ + "\32\0\6\176\1\304\1\242\60\176\7\243\1\305\60\243"+ + "\7\306\1\307\60\306\6\310\1\304\1\245\60\310\10\247"+ + "\1\202\1\0\56\247\14\0\4\21\5\0\4\21\1\311"+ + "\16\21\1\0\2\21\31\0\4\21\5\0\3\21\1\312"+ + "\17\21\1\0\2\21\31\0\4\21\5\0\4\21\1\313"+ + "\16\21\1\0\2\21\31\0\4\21\5\0\14\21\1\314"+ + "\6\21\1\0\2\21\20\0\1\315\10\0\4\21\5\0"+ + "\23\21\1\0\2\21\31\0\4\21\5\0\1\21\1\316"+ + "\21\21\1\0\2\21\31\0\4\21\5\0\4\21\1\317"+ + "\16\21\1\0\2\21\31\0\4\21\5\0\14\21\1\320"+ + "\6\21\1\0\2\21\20\0\1\321\10\0\4\21\5\0"+ + "\23\21\1\0\2\21\31\0\4\21\5\0\2\21\1\322"+ + "\20\21\1\0\2\21\31\0\4\21\5\0\4\21\1\323"+ + "\16\21\1\0\2\21\31\0\4\21\5\0\11\21\1\324"+ + "\11\21\1\0\2\21\31\0\4\21\5\0\2\21\1\325"+ + "\20\21\1\0\2\21\20\0\1\267\1\0\2\326\5\0"+ + "\4\326\3\0\1\326\1\0\23\326\1\0\2\326\31\0"+ + "\4\21\5\0\1\327\22\21\1\0\2\21\31\0\4\21"+ + "\5\0\6\21\1\330\14\21\1\0\2\21\31\0\4\21"+ + "\5\0\6\21\1\331\14\21\1\0\2\21\31\0\4\21"+ + "\5\0\3\21\1\332\17\21\1\0\2\21\31\0\4\21"+ + "\5\0\1\333\22\21\1\0\2\21\15\0\6\233\1\70"+ + "\1\275\60\233\31\0\1\334\71\0\1\335\37\0\1\336"+ + "\115\0\1\337\71\0\1\340\34\0\6\310\1\341\1\245"+ + "\60\310\6\342\1\341\1\343\60\342\7\243\1\245\60\243"+ + "\14\0\4\21\5\0\5\21\1\344\15\21\1\0\2\21"+ + "\31\0\4\21\5\0\13\21\1\345\7\21\1\0\2\21"+ + "\31\0\4\21\5\0\2\21\1\346\20\21\1\0\2\21"+ + "\31\0\4\21\5\0\5\21\1\347\15\21\1\0\2\21"+ + "\20\0\1\315\1\0\2\350\5\0\4\350\3\0\1\350"+ + "\1\0\23\350\1\0\2\350\31\0\4\21\5\0\12\21"+ + "\1\351\10\21\1\0\2\21\31\0\4\21\5\0\2\21"+ + "\1\352\20\21\1\0\2\21\31\0\4\21\5\0\1\21"+ + "\1\353\21\21\1\0\2\21\20\0\1\321\1\0\2\354"+ + "\5\0\4\354\3\0\1\354\1\0\23\354\1\0\2\354"+ + "\31\0\4\21\5\0\1\355\22\21\1\0\2\21\31\0"+ + "\4\21\5\0\6\21\1\356\14\21\1\0\2\21\20\0"+ + "\1\357\10\0\4\21\5\0\23\21\1\0\2\21\20\0"+ + "\1\360\10\0\4\21\5\0\23\21\1\0\2\21\31\0"+ + "\4\21\5\0\7\21\1\361\13\21\1\0\2\21\31\0"+ + "\4\21\5\0\4\21\1\362\16\21\1\0\2\21\31\0"+ + "\4\21\5\0\2\21\1\363\20\21\1\0\2\21\31\0"+ + "\4\21\5\0\7\21\1\364\13\21\1\0\2\21\31\0"+ + "\4\21\5\0\7\21\1\365\13\21\1\0\2\21\44\0"+ + "\1\11\71\0\1\366\41\0\1\336\1\0\2\367\5\0"+ + "\4\367\3\0\1\367\1\0\23\367\1\0\2\367\44\0"+ + "\1\370\71\0\1\371\36\0\7\306\1\343\60\306\6\342"+ + "\1\0\1\343\60\342\14\0\4\21\5\0\6\21\1\372"+ + "\14\21\1\0\2\21\31\0\4\21\5\0\3\21\1\373"+ + "\17\21\1\0\2\21\20\0\1\374\3\0\1\375\4\0"+ + "\4\21\5\0\23\21\1\0\2\21\20\0\1\376\10\0"+ + "\4\21\5\0\23\21\1\0\2\21\31\0\4\21\5\0"+ + "\11\21\1\377\11\21\1\0\2\21\16\0\2\u0100\1\u0101"+ + "\6\0\1\u0102\1\0\4\21\5\0\23\21\1\u0102\2\21"+ + "\31\0\4\21\5\0\10\21\1\u0103\12\21\1\0\2\21"+ + "\31\0\4\21\5\0\14\21\1\u0104\6\21\1\0\2\21"+ + "\31\0\4\21\5\0\7\21\1\u0105\13\21\1\0\2\21"+ + "\20\0\1\357\1\0\2\u0106\5\0\4\u0106\3\0\1\u0106"+ + "\1\0\23\u0106\1\0\2\u0106\20\0\1\360\1\0\2\u0107"+ + "\5\0\4\u0107\3\0\1\u0107\1\0\23\u0107\1\0\2\u0107"+ + "\20\0\1\u0108\10\0\4\21\5\0\23\21\1\0\2\21"+ + "\31\0\4\21\5\0\3\21\1\u0109\17\21\1\0\2\21"+ + "\31\0\4\21\5\0\3\21\1\u010a\17\21\1\0\2\21"+ + "\31\0\4\21\5\0\2\21\1\u010b\20\21\1\0\2\21"+ + "\20\0\1\u010c\10\0\4\21\5\0\23\21\1\0\2\21"+ + "\45\0\1\11\40\0\3\370\23\0\1\100\70\0\1\370"+ + "\53\0\4\21\5\0\7\21\1\u010d\13\21\1\0\2\21"+ + "\31\0\4\21\5\0\1\21\1\u010e\21\21\1\0\2\21"+ + "\20\0\1\374\1\0\3\375\4\0\4\375\3\0\1\375"+ + "\1\0\23\375\1\0\2\375\20\0\1\376\1\0\2\u010f"+ + "\5\0\4\u010f\3\0\1\u010f\1\0\23\u010f\1\0\2\u010f"+ + "\20\0\1\u0110\5\0\1\u0111\2\0\4\21\5\0\23\21"+ + "\1\u0112\2\21\16\0\3\u0100\6\0\1\u0102\35\0\1\u0102"+ + "\20\0\2\u0100\1\u0101\1\0\2\u0102\3\0\1\u0102\1\0"+ + "\4\u0102\3\0\1\u0102\1\0\26\u0102\31\0\4\21\5\0"+ + "\17\21\1\u0113\3\21\1\0\2\21\31\0\4\21\5\0"+ + "\1\21\1\u0114\21\21\1\0\2\21\31\0\4\21\5\0"+ + "\2\21\1\u0115\20\21\1\0\2\21\20\0\1\u0108\1\0"+ + "\2\u0116\5\0\4\u0116\3\0\1\u0116\1\0\23\u0116\1\0"+ + "\2\u0116\16\0\2\u0117\1\u0118\10\0\4\21\5\0\1\21"+ + "\1\u0119\1\21\1\u011a\1\21\1\u011b\1\21\1\u011c\3\21"+ + "\1\u011d\7\21\1\0\2\21\20\0\1\u011e\10\0\4\21"+ + "\5\0\23\21\1\0\2\21\31\0\4\21\5\0\3\21"+ + "\1\u011f\17\21\1\0\2\21\20\0\1\u010c\1\0\2\u0120"+ + "\5\0\4\u0120\3\0\1\u0120\1\0\23\u0120\1\0\2\u0120"+ + "\31\0\4\21\5\0\3\21\1\u0121\17\21\1\0\2\21"+ + "\31\0\4\21\5\0\2\21\1\u0122\20\21\1\0\2\21"+ + "\20\0\1\u0110\1\0\2\u0112\2\0\1\u0111\2\0\4\u0112"+ + "\3\0\1\u0112\1\0\26\u0112\15\0\10\u0111\1\u0123\1\u0124"+ + "\56\u0111\3\0\1\u0125\10\0\4\21\5\0\23\21\1\0"+ + "\2\21\20\0\1\u0126\10\0\4\21\5\0\23\21\1\0"+ + "\2\21\20\0\1\u0127\10\0\4\21\5\0\23\21\1\0"+ + "\2\21\16\0\3\u0117\22\0\1\u0128\1\0\1\u0129\1\0"+ + "\1\u012a\1\0\1\u012b\3\0\1\u012c\30\0\2\u0117\1\u0118"+ + "\1\0\2\u012d\5\0\4\u012d\3\0\1\u012d\1\0\1\u012d"+ + "\1\u012e\1\u012d\1\u012f\1\u012d\1\u0130\1\u012d\1\u0131\3\u012d"+ + "\1\u0132\7\u012d\1\0\2\u012d\31\0\4\21\5\0\6\21"+ + "\1\u0133\14\21\1\0\2\21\31\0\4\21\5\0\1\21"+ + "\1\u0134\21\21\1\0\2\21\31\0\4\21\5\0\15\21"+ + "\1\u0135\5\21\1\0\2\21\31\0\4\21\5\0\10\21"+ + "\1\u0136\12\21\1\0\2\21\31\0\4\21\5\0\14\21"+ + "\1\u0137\6\21\1\0\2\21\20\0\1\u011e\1\0\2\u0138"+ + "\5\0\4\u0138\3\0\1\u0138\1\0\23\u0138\1\0\2\u0138"+ + "\31\0\4\21\5\0\12\21\1\u0139\10\21\1\0\2\21"+ + "\20\0\1\u013a\10\0\4\21\5\0\23\21\1\0\2\21"+ + "\31\0\4\21\5\0\11\21\1\u013b\11\21\1\0\2\21"+ + "\20\0\1\u0123\6\0\1\u013c\55\0\10\u0124\1\u0111\1\u013d"+ + "\56\u0124\3\0\1\u0125\1\0\2\u0107\5\0\4\u0107\3\0"+ + "\25\u0107\1\0\2\u0107\20\0\1\u0126\1\0\2\u013e\5\0"+ + "\4\u013e\3\0\1\u013e\1\0\23\u013e\1\0\2\u013e\20\0"+ + "\1\u0127\1\0\2\u013f\5\0\4\u013f\3\0\1\u013f\1\0"+ + "\23\u013f\1\0\2\u013f\50\0\1\u0140\62\0\1\u0141\103\0"+ + "\1\u0142\62\0\1\u0143\73\0\1\u0144\42\0\4\21\5\0"+ + "\13\21\1\u0145\7\21\1\0\2\21\31\0\4\21\5\0"+ + "\15\21\1\u0146\5\21\1\0\2\21\31\0\4\21\5\0"+ + "\1\21\1\u0147\21\21\1\0\2\21\31\0\4\21\5\0"+ + "\6\21\1\u0148\14\21\1\0\2\21\31\0\4\21\5\0"+ + "\12\21\1\u0149\10\21\1\0\2\21\20\0\1\u014a\10\0"+ + "\4\21\5\0\23\21\1\0\2\21\20\0\1\u013a\1\0"+ + "\2\u014b\5\0\4\u014b\3\0\1\u014b\1\0\23\u014b\1\0"+ + "\2\u014b\20\0\1\u014c\10\0\4\21\5\0\23\21\1\0"+ + "\2\21\30\0\1\u0112\54\0\10\u013d\1\u0124\1\u014d\56\u013d"+ + "\40\0\1\u014e\71\0\1\u014f\53\0\1\u0150\74\0\1\u0151"+ + "\73\0\1\u0152\44\0\4\21\5\0\3\21\1\u0153\17\21"+ + "\1\0\2\21\31\0\4\21\5\0\13\21\1\u0154\7\21"+ + "\1\0\2\21\31\0\4\21\5\0\7\21\1\u0155\13\21"+ + "\1\0\2\21\31\0\4\21\5\0\11\21\1\u0156\11\21"+ + "\1\0\2\21\31\0\4\21\5\0\15\21\1\u0157\5\21"+ + "\1\0\2\21\20\0\1\u014a\1\0\2\u0158\5\0\4\u0158"+ + "\3\0\1\u0158\1\0\23\u0158\1\0\2\u0158\20\0\1\u014c"+ + "\1\0\2\u0159\5\0\4\u0159\3\0\1\u0159\1\0\23\u0159"+ + "\1\0\2\u0159\15\0\10\u014d\1\u013d\1\0\56\u014d\30\0"+ + "\1\u015a\77\0\1\u015b\63\0\1\u015c\71\0\1\u015d\73\0"+ + "\1\u015e\41\0\4\21\5\0\11\21\1\u015f\11\21\1\0"+ + "\2\21\31\0\4\21\5\0\2\21\1\u0160\20\21\1\0"+ + "\2\21\31\0\4\21\5\0\11\21\1\u0161\11\21\1\0"+ + "\2\21\31\0\4\21\5\0\10\21\1\u0162\12\21\1\0"+ + "\2\21\53\0\1\u0163\60\0\1\u0164\76\0\1\u0165\66\0"+ + "\1\u0166\46\0\4\21\5\0\16\21\1\u0167\4\21\1\0"+ + "\2\21\31\0\4\21\5\0\1\u0168\22\21\1\0\2\21"+ + "\31\0\4\21\5\0\3\21\1\u0169\17\21\1\0\2\21"+ + "\60\0\1\u016a\51\0\1\u016b\72\0\1\u016c\53\0\4\21"+ + "\5\0\6\21\1\u016d\14\21\1\0\2\21\31\0\4\21"+ + "\5\0\14\21\1\u016e\6\21\1\0\2\21\50\0\1\u016f"+ + "\75\0\1\u0170\42\0\4\21\5\0\7\21\1\u0162\13\21"+ + "\1\0\2\21\31\0\4\21\5\0\1\21\1\u0171\21\21"+ + "\1\0\2\21\51\0\1\u0166\61\0\1\u0172\41\0"; + + /** + * The transition table of the DFA + */ + final private static int yytrans [] = yy_unpack(); + + + /* error codes */ + final private static int YY_UNKNOWN_ERROR = 0; + final private static int YY_ILLEGAL_STATE = 1; + final private static int YY_NO_MATCH = 2; + final private static int YY_PUSHBACK_2BIG = 3; + + /* error messages for the codes above */ + final private static String YY_ERROR_MSG[] = { + "Unkown internal scanner error", + "Internal error: unknown state", + "Error: could not match input", + "Error: pushback value was too large" + }; + + /** + * YY_ATTRIBUTE[aState] contains the attributes of state aState + */ + private final static byte YY_ATTRIBUTE[] = { + 1, 0, 0, 1, 0, 9, 1, 1, 9, 9, 1, 9, 3, 3, 1, 1, + 1, 1, 1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 1, 9, 1, 9, 1, 9, + 1, 9, 1, 1, 9, 1, 1, 1, 1, 1, 1, 1, 1, 9, 0, 0, + 0, 0, 1, 9, 0, 0, 0, 0, 0, 0, 9, 9, 9, 1, 9, 1, + 9, 9, 1, 0, 9, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 1, 9, 0, 9, 9, + 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, + 0, 0, 1, 9, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 1, 1, 1, 3, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 13, 0, 1, 13, 1, 1, 1, 3, 1, 1, 1, + 3, 1, 13, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 9, 0, 0, + 2, 0, 0, 9, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, + 0, 1, 1, 3, 3, 13, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, + 9, 0, 0, 1, 1, 3, 3, 13, 1, 3, 1, 13, 1, 1, 0, 0, + 3, 1, 1, 1, 3, 0, 13, 0, 0, 1, 1, 0, 13, 0, 3, 0, + 0, 13, 1, 1, 1, 13, 13, 0, 3, 3, 1, 0, 1, 1, 13, 0, + 0, 13, 3, 3, 3, 13, 0, 0, 1, 1, 1, 1, 1, 0, 1, 13, + 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 5, 5, 5, + 5, 5, 1, 1, 1, 1, 1, 13, 3, 0, 3, 0, 0, 13, 13, 0, + 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 13, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 1, 13, 13, 0, 9, 0, 0, 0, 1, 1, + 1, 1, 0, 0, 9, 0, 1, 1, 1, 0, 0, 9, 1, 1, 0, 0, + 1, 9 + }; + + /** the input device */ + private java.io.Reader yy_reader; + + /** the current state of the DFA */ + private int yy_state; + + /** the current lexical state */ + private int yy_lexical_state = YYINITIAL; + + /** this buffer contains the current text to be matched and is + the source of the yytext() string */ + private char yy_buffer[] = new char[YY_BUFFERSIZE]; + + /** the textposition at the last accepting state */ + private int yy_markedPos; + + /** the textposition at the last state to be included in yytext */ + private int yy_pushbackPos; + + /** the current text position in the buffer */ + private int yy_currentPos; + + /** startRead marks the beginning of the yytext() string in the buffer */ + private int yy_startRead; + + /** endRead marks the last character in the buffer, that has been read + from input */ + private int yy_endRead; + + /** number of newlines encountered up to the start of the matched text */ + private int yyline; + + /** the number of characters up to the start of the matched text */ + private int yychar; + + /** + * the number of characters from the last newline up to the start of the + * matched text + */ + private int yycolumn; + + /** + * yy_atBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean yy_atBOL = true; + + /** yy_atEOF == true <=> the scanner is at the EOF */ + private boolean yy_atEOF; + + /** denotes if the user-EOF-code has already been executed */ + private boolean yy_eof_done; + + /* user code: */ + StringBuffer string=new StringBuffer(); + String fileName; + public void setFileName(String name) { + fileName=name; + } + public String getFileName() { + return fileName; + } + private Symbol symbol(int type) { + return new Symbol(type,yyline,yycolumn, + new Token(type,fileName,yytext(), + yyline+1,yycolumn+1, + yycolumn+1+yytext().length())); + } + private Symbol symbol(int type, String value) { + return new Symbol(type,yyline,yycolumn, + new Token(type,fileName,value, + yyline+1,yycolumn+1, + yycolumn+1+yytext().length())); + } + private Stack openParens = new Stack(); + + + /** + * Creates a new scanner + * There is also a java.io.InputStream version of this constructor. + * + * @param in the java.io.Reader to read input from. + */ + TypescriptDefScanner(java.io.Reader in) { + this.yy_reader = in; + } + + /** + * Creates a new scanner. + * There is also java.io.Reader version of this constructor. + * + * @param in the java.io.Inputstream to read input from. + */ + TypescriptDefScanner(java.io.InputStream in) { + this(new java.io.InputStreamReader(in)); + } + + /** + * Unpacks the split, compressed DFA transition table. + * + * @return the unpacked transition table + */ + private static int [] yy_unpack() { + int [] trans = new int[16184]; + int offset = 0; + offset = yy_unpack(yy_packed0, offset, trans); + return trans; + } + + /** + * Unpacks the compressed DFA transition table. + * + * @param packed the packed transition table + * @return the index of the last entry + */ + private static int yy_unpack(String packed, int offset, int [] trans) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + value--; + do trans[j++] = value; while (--count > 0); + } + return j; + } + + /** + * Unpacks the compressed character translation table. + * + * @param packed the packed character translation table + * @return the unpacked character translation table + */ + private static char [] yy_unpack_cmap(String packed) { + char [] map = new char[0x10000]; + int i = 0; /* index in packed string */ + int j = 0; /* index in unpacked array */ + while (i < 146) { + int count = packed.charAt(i++); + char value = packed.charAt(i++); + do map[j++] = value; while (--count > 0); + } + return map; + } + + + /** + * Refills the input buffer. + * + * @return false, iff there was new input. + * + * @exception IOException if any I/O-Error occurs + */ + private boolean yy_refill() throws java.io.IOException { + + /* first: make room (if you can) */ + if (yy_startRead > 0) { + System.arraycopy(yy_buffer, yy_startRead, + yy_buffer, 0, + yy_endRead-yy_startRead); + + /* translate stored positions */ + yy_endRead-= yy_startRead; + yy_currentPos-= yy_startRead; + yy_markedPos-= yy_startRead; + yy_pushbackPos-= yy_startRead; + yy_startRead = 0; + } + + /* is the buffer big enough? */ + if (yy_currentPos >= yy_buffer.length) { + /* if not: blow it up */ + char newBuffer[] = new char[yy_currentPos*2]; + System.arraycopy(yy_buffer, 0, newBuffer, 0, yy_buffer.length); + yy_buffer = newBuffer; + } + + /* finally: fill the buffer with new input */ + int numRead = yy_reader.read(yy_buffer, yy_endRead, + yy_buffer.length-yy_endRead); + + if (numRead < 0) { + return true; + } + else { + yy_endRead+= numRead; + return false; + } + } + + + /** + * Closes the input stream. + */ + final public void yyclose() throws java.io.IOException { + yy_atEOF = true; /* indicate end of file */ + yy_endRead = yy_startRead; /* invalidate buffer */ + + if (yy_reader != null) + yy_reader.close(); + } + + + /** + * Closes the current stream, and resets the + * scanner to read from a new input stream. + * + * All internal variables are reset, the old input stream + * cannot be reused (internal buffer is discarded and lost). + * Lexical state is set to YY_INITIAL. + * + * @param reader the new input stream + */ + final public void yyreset(java.io.Reader reader) throws java.io.IOException { + yyclose(); + yy_reader = reader; + yy_atBOL = true; + yy_atEOF = false; + yy_endRead = yy_startRead = 0; + yy_currentPos = yy_markedPos = yy_pushbackPos = 0; + yyline = yychar = yycolumn = 0; + yy_lexical_state = YYINITIAL; + } + + + /** + * Returns the current lexical state. + */ + final public int yystate() { + return yy_lexical_state; + } + + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + final public void yybegin(int newState) { + yy_lexical_state = newState; + } + + + /** + * Returns the text matched by the current regular expression. + */ + final public String yytext() { + return new String( yy_buffer, yy_startRead, yy_markedPos-yy_startRead ); + } + + + /** + * Returns the character at position pos from the + * matched text. + * + * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. + * A value from 0 to yylength()-1. + * + * @return the character at position pos + */ + final public char yycharat(int pos) { + return yy_buffer[yy_startRead+pos]; + } + + + /** + * Returns the length of the matched text region. + */ + final public int yylength() { + return yy_markedPos-yy_startRead; + } + + + /** + * Reports an error that occured while scanning. + * + * In a wellformed scanner (no or only correct usage of + * yypushback(int) and a match-all fallback rule) this method + * will only be called with things that "Can't Possibly Happen". + * If this method is called, something is seriously wrong + * (e.g. a JFlex bug producing a faulty scanner etc.). + * + * Usual syntax/scanner level error handling should be done + * in error fallback rules. + * + * @param errorCode the code of the errormessage to display + */ + private void yy_ScanError(int errorCode) { + String message; + try { + message = YY_ERROR_MSG[errorCode]; + } + catch (ArrayIndexOutOfBoundsException e) { + message = YY_ERROR_MSG[YY_UNKNOWN_ERROR]; + } + + throw new Error(message); + } + + + /** + * Pushes the specified amount of characters back into the input stream. + * + * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. + * This number must not be greater than yylength()! + */ + private void yypushback(int number) { + if ( number > yylength() ) + yy_ScanError(YY_PUSHBACK_2BIG); + + yy_markedPos -= number; + } + + + /** + * Contains user EOF-code, which will be executed exactly once, + * when the end of file is reached + */ + private void yy_do_eof() throws java.io.IOException { + if (!yy_eof_done) { + yy_eof_done = true; + yyclose(); + } + } + + + /** + * Resumes scanning until the next regular expression is matched, + * the end of input is encountered or an I/O-Error occurs. + * + * @return the next token + * @exception IOException if any I/O-Error occurs + */ + public java_cup.runtime.Symbol next_token() throws java.io.IOException { + int yy_input; + int yy_action; + + // cached fields: + int yy_currentPos_l; + int yy_startRead_l; + int yy_markedPos_l; + int yy_endRead_l = yy_endRead; + char [] yy_buffer_l = yy_buffer; + char [] yycmap_l = yycmap; + + int [] yytrans_l = yytrans; + int [] yy_rowMap_l = yy_rowMap; + byte [] yy_attr_l = YY_ATTRIBUTE; + int yy_pushbackPos_l = yy_pushbackPos = -1; + boolean yy_was_pushback; + + while (true) { + yy_markedPos_l = yy_markedPos; + + boolean yy_r = false; + for (yy_currentPos_l = yy_startRead; yy_currentPos_l < yy_markedPos_l; + yy_currentPos_l++) { + switch (yy_buffer_l[yy_currentPos_l]) { + case '\u000B': + case '\u000C': + case '\u0085': + case '\u2028': + case '\u2029': + yyline++; + yycolumn = 0; + yy_r = false; + break; + case '\r': + yyline++; + yycolumn = 0; + yy_r = true; + break; + case '\n': + if (yy_r) + yy_r = false; + else { + yyline++; + yycolumn = 0; + } + break; + default: + yy_r = false; + yycolumn++; + } + } + + if (yy_r) { + // peek one character ahead if it is \n (if we have counted one line too much) + boolean yy_peek; + if (yy_markedPos_l < yy_endRead_l) + yy_peek = yy_buffer_l[yy_markedPos_l] == '\n'; + else if (yy_atEOF) + yy_peek = false; + else { + boolean eof = yy_refill(); + yy_markedPos_l = yy_markedPos; + yy_buffer_l = yy_buffer; + if (eof) + yy_peek = false; + else + yy_peek = yy_buffer_l[yy_markedPos_l] == '\n'; + } + if (yy_peek) yyline--; + } + yy_action = -1; + + yy_startRead_l = yy_currentPos_l = yy_currentPos = + yy_startRead = yy_markedPos_l; + + yy_state = yy_lexical_state; + + yy_was_pushback = false; + + yy_forAction: { + while (true) { + + if (yy_currentPos_l < yy_endRead_l) + yy_input = yy_buffer_l[yy_currentPos_l++]; + else if (yy_atEOF) { + yy_input = YYEOF; + break yy_forAction; + } + else { + // store back cached positions + yy_currentPos = yy_currentPos_l; + yy_markedPos = yy_markedPos_l; + yy_pushbackPos = yy_pushbackPos_l; + boolean eof = yy_refill(); + // get translated positions and possibly new buffer + yy_currentPos_l = yy_currentPos; + yy_markedPos_l = yy_markedPos; + yy_buffer_l = yy_buffer; + yy_endRead_l = yy_endRead; + yy_pushbackPos_l = yy_pushbackPos; + if (eof) { + yy_input = YYEOF; + break yy_forAction; + } + else { + yy_input = yy_buffer_l[yy_currentPos_l++]; + } + } + int yy_next = yytrans_l[ yy_rowMap_l[yy_state] + yycmap_l[yy_input] ]; + if (yy_next == -1) break yy_forAction; + yy_state = yy_next; + + int yy_attributes = yy_attr_l[yy_state]; + if ( (yy_attributes & 2) == 2 ) + yy_pushbackPos_l = yy_currentPos_l; + + if ( (yy_attributes & 1) == 1 ) { + yy_was_pushback = (yy_attributes & 4) == 4; + yy_action = yy_state; + yy_markedPos_l = yy_currentPos_l; + if ( (yy_attributes & 8) == 8 ) break yy_forAction; + } + + } + } + + // store back cached position + yy_markedPos = yy_markedPos_l; + if (yy_was_pushback) + yy_markedPos = yy_pushbackPos_l; + + switch (yy_action) { + + case 344: + { return symbol(sym.IMPLEMENTS); } + case 371: break; + case 0: + case 16: + case 24: + case 25: + case 26: + case 27: + case 28: + case 29: + case 30: + case 31: + case 32: + case 33: + case 34: + case 35: + case 36: + case 77: + case 85: + case 86: + case 87: + case 88: + case 89: + case 90: + case 91: + case 92: + case 93: + case 94: + case 95: + case 96: + case 97: + case 98: + case 99: + case 100: + case 101: + case 102: + case 103: + case 104: + case 132: + case 134: + case 136: + case 137: + case 138: + case 139: + case 140: + case 141: + case 142: + case 144: + case 145: + case 146: + case 147: + case 148: + case 149: + case 150: + case 151: + case 152: + case 167: + case 169: + case 170: + case 171: + case 172: + case 173: + case 174: + case 175: + case 176: + case 177: + case 179: + case 180: + case 181: + case 183: + case 184: + case 185: + case 186: + case 187: + case 200: + case 201: + case 202: + case 203: + case 205: + case 206: + case 207: + case 209: + case 210: + case 211: + case 212: + case 214: + case 215: + case 216: + case 217: + case 218: + case 227: + case 228: + case 229: + case 230: + case 232: + case 233: + case 234: + case 236: + case 237: + case 240: + case 241: + case 242: + case 243: + case 244: + case 249: + case 250: + case 254: + case 258: + case 259: + case 260: + case 264: + case 265: + case 266: + case 268: + case 269: + case 274: + case 275: + case 276: + case 280: + case 281: + case 282: + case 283: + case 284: + case 286: + case 288: + case 289: + case 306: + case 307: + case 308: + case 309: + case 310: + case 312: + case 314: + case 324: + case 325: + case 326: + case 327: + case 328: + case 338: + case 340: + case 341: + case 342: + case 350: + case 351: + case 353: + case 358: + case 359: + case 364: + case 365: + { return symbol(sym.IDENTIFIER); } + case 372: break; + case 60: + case 61: + { yybegin(YYINITIAL); yypushback(yylength()); } + case 373: break; + case 81: + { return symbol(sym.MINUSMINUS); } + case 374: break; + case 127: + { return symbol(sym.RPAREN_FUNC); } + case 375: break; + case 165: + { return symbol(sym.LPAREN_FUNC); } + case 376: break; + case 343: + { return symbol(sym.PROTECTED); } + case 377: break; + case 330: + { return symbol(sym.INTERFACE); } + case 378: break; + case 318: + { return symbol(sym.ABSTRACT); } + case 379: break; + case 317: + { return symbol(sym.FUNCTION); } + case 380: break; + case 47: + { return symbol(sym.QUESTION); } + case 381: break; + case 80: + { return symbol(sym.PLUSPLUS); } + case 382: break; + case 106: + { return symbol(sym.NOTEQUALS); } + case 383: break; + case 131: + { return symbol(sym.DOTDOTDOT); } + case 384: break; + case 49: + { return symbol(sym.AT); } + case 385: break; + case 48: + { return symbol(sym.AND); } + case 386: break; + case 44: + { return symbol(sym.NOT); } + case 387: break; + case 42: + { return symbol(sym.LT); } + case 388: break; + case 38: + { return symbol(sym.COL); } + case 389: break; + case 10: + { return symbol(sym.DIV); } + case 390: break; + case 8: + { /* ignore */ } + case 391: break; + case 3: + case 56: + { /* ignore */ } + case 392: break; + case 15: + { return symbol(sym.GT); } + case 393: break; + case 17: + case 18: + case 78: + case 79: + { return symbol(sym.INT); } + case 394: break; + case 21: + { return symbol(sym.DOT); } + case 395: break; + case 55: + { return symbol(sym.LF); } + case 396: break; + case 76: + { return symbol(sym.GTE); } + case 397: break; + case 105: + { return symbol(sym.LTE); } + case 398: break; + case 130: + { return symbol(sym.INT); } + case 399: break; + case 135: + { return symbol(sym.NEW); } + case 400: break; + case 168: + { return symbol(sym.IS); } + case 401: break; + case 178: + { return symbol(sym.AS); } + case 402: break; + case 213: + { return symbol(sym.VAR); } + case 403: break; + case 224: + { return symbol(sym.DOC); } + case 404: break; + case 5: + case 57: + case 58: + case 59: + { System.out.println("unmatched:"+yytext()); } + case 405: break; + case 189: + { yybegin(YYINITIAL); return symbol(sym.TYPE_MACRO); } + case 406: break; + case 352: + case 356: + { return symbol(sym.DECLARE_CLASS); } + case 407: break; + case 339: + case 346: + { return symbol(sym.DECLARE_ENUM); } + case 408: break; + case 262: + { return symbol(sym.CONST); } + case 409: break; + case 261: + { return symbol(sym.CLASS); } + case 410: break; + case 46: + { return symbol(sym.TUBE); } + case 411: break; + case 43: + { return symbol(sym.COMMA); } + case 412: break; + case 39: + { return symbol(sym.SEMI); } + case 413: break; + case 11: + { return symbol(sym.MULT); } + case 414: break; + case 19: + { return symbol(sym.PLUS); } + case 415: break; + case 20: + { return symbol(sym.MINUS); } + case 416: break; + case 66: + { return symbol(sym.TUBE); } + case 417: break; + case 107: + case 108: + { return symbol(sym.TUBE); } + case 418: break; + case 110: + { return symbol(sym.OROR); } + case 419: break; + case 231: + { return symbol(sym.ENUM); } + case 420: break; + case 235: + { return symbol(sym.FROM); } + case 421: break; + case 51: + { string.append('\\'); } + case 422: break; + case 54: + { string.append('\\'); } + case 423: break; + case 112: + { string.append('\\'); } + case 424: break; + case 113: + { string.append('\"'); } + case 425: break; + case 114: + { string.append('\n'); } + case 426: break; + case 115: + { string.append('\t'); } + case 427: break; + case 116: + { string.append('\r'); } + case 428: break; + case 117: + { string.append('\''); } + case 429: break; + case 67: + { yybegin(EOL_COMMENT); } + case 430: break; + case 368: + case 369: + { return symbol(sym.DECLARE_FUNCTION); } + case 431: break; + case 52: + { yybegin(YYINITIAL); + return symbol(sym.IDENTIFIER, + "\""+string.toString()+"\""); } + case 432: break; + case 246: + { yypushback(yylength()); yybegin(TYPE_MACRO); } + case 433: break; + case 6: + case 7: + { /*System.err.println("LF");*/ return symbol(sym.LF); } + case 434: break; + case 163: + case 195: + { /*System.err.println("COMMENT: "+yytext());*/ /* ignore */ } + case 435: break; + case 22: + { string.setLength(0); yybegin(CHAR); } + case 436: break; + case 360: + case 363: + { return symbol(sym.DECLARE_MODULE); } + case 437: break; + case 9: + { string.setLength(0); yybegin(STRING); } + case 438: break; + case 311: + { return symbol(sym.PRIVATE); } + case 439: break; + case 300: + case 301: + case 302: + case 303: + case 304: + case 305: + { return symbol(sym.DECLARE); } + case 440: break; + case 287: + { return symbol(sym.PUBLIC); } + case 441: break; + case 277: + { return symbol(sym.STATIC); } + case 442: break; + case 273: + { return symbol(sym.EXTENDS); } + case 443: break; + case 270: + { return symbol(sym.TYPEOF); } + case 444: break; + case 257: + { return symbol(sym.EXPORT); } + case 445: break; + case 252: + { return symbol(sym.IMPORT); } + case 446: break; + case 53: + { string.append( yytext() ); } + case 447: break; + case 50: + { string.append( yytext() ); } + case 448: break; + case 45: + { return symbol(sym.MATCHES); } + case 449: break; + case 41: + { return symbol(sym.RSPAREN); } + case 450: break; + case 40: + { return symbol(sym.RCPAREN); } + case 451: break; + case 37: + { return symbol(sym.LCPAREN); } + case 452: break; + case 23: + { return symbol(sym.LSPAREN); } + case 453: break; + case 12: + { return symbol(sym.RPAREN); } + case 454: break; + case 13: + { return symbol(sym.LPAREN); } + case 455: break; + case 14: + { return symbol(sym.ASSIGN); } + case 456: break; + case 74: + { return symbol(sym.EQUALS); } + case 457: break; + case 75: + { return symbol(sym.IMPLIES); } + case 458: break; + case 82: + { return symbol(sym.DOTDOT); } + case 459: break; + case 84: + { return symbol(sym.SQUARE); } + case 460: break; + case 111: + { return symbol(sym.ANDAND); } + case 461: break; + default: + if (yy_input == YYEOF && yy_startRead == yy_currentPos) { + yy_atEOF = true; + yy_do_eof(); + switch (yy_lexical_state) { + case EOL_COMMENT: + { yybegin(YYINITIAL); } + case 371: break; + default: + { return new java_cup.runtime.Symbol(sym.EOF); } + } + } + else { + yy_ScanError(YY_NO_MATCH); + } + } + } + } + + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/TypescriptDefScanner.java~ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/TypescriptDefScanner.java~ new file mode 100644 index 00000000..08619c37 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/TypescriptDefScanner.java~ @@ -0,0 +1,1258 @@ +/* The following code was generated by JFlex 1.3.5 on 13/11/15 09:56 */ + + +/* + * This source code file is the exclusive property of its author. No copy or + * usage of the source code is permitted unless the author contractually + * allows it under the terms of a well-defined agreement. + */ + +package org.jsweet.input.typescriptdef.parser; + +import java_cup.runtime.*; +import org.jsweet.input.typescriptdef.ast.Token; +import java.util.*; + + +/** + * This class is a scanner generated by + * JFlex 1.3.5 + * on 13/11/15 09:56 from the specification file + * file:/C:/Users/Renaud Pawlak/workspace-jsweet/jsweet-def-translators/src/org/jsweet/input/typescriptdef/parser/typescriptdef.lex + */ +class TypescriptDefScanner implements java_cup.runtime.Scanner { + + /** This character denotes the end of file */ + final public static int YYEOF = -1; + + /** initial size of the lookahead buffer */ + final private static int YY_BUFFERSIZE = 16384; + + /** lexical states */ + final public static int EOL_COMMENT = 4; + final public static int STRING = 1; + final public static int YYINITIAL = 0; + final public static int TYPE_MACRO = 3; + final public static int CHAR = 2; + + /** + * Translates characters to character classes + */ + final private static String yycmap_packed = + "\11\0\1\3\1\2\1\0\1\3\1\1\22\0\1\3\1\61\1\5"+ + "\1\0\1\14\1\0\1\65\1\23\1\11\1\10\1\7\1\20\1\60"+ + "\1\21\1\22\1\6\1\15\11\16\1\52\1\53\1\57\1\12\1\13"+ + "\1\64\1\66\6\17\21\14\1\51\2\14\1\55\1\4\1\56\1\0"+ + "\1\14\1\0\1\32\1\47\1\33\1\36\1\27\1\31\2\14\1\24"+ + "\2\14\1\34\1\40\1\25\1\41\1\43\1\14\1\30\1\35\1\26"+ + "\1\42\1\37\1\50\1\45\1\44\1\14\1\46\1\63\1\54\1\62"+ + "\74\0\1\67\3\0\1\67\57\0\1\67\uff10\0"; + + /** + * Translates characters to character classes + */ + final private static char [] yycmap = yy_unpack_cmap(yycmap_packed); + + /** + * Translates a state to a row index in the transition table + */ + final private static int yy_rowMap [] = { + 0, 56, 112, 168, 224, 280, 336, 392, 280, 280, + 448, 280, 504, 560, 616, 672, 728, 784, 840, 896, + 952, 1008, 280, 1064, 1120, 1176, 1232, 1288, 1344, 1400, + 1456, 1512, 1568, 1624, 280, 280, 280, 280, 1680, 280, + 1736, 280, 1792, 280, 1848, 280, 1904, 280, 1960, 2016, + 280, 2072, 2128, 2184, 2240, 2296, 2352, 2408, 2464, 280, + 392, 2520, 2576, 2632, 2688, 280, 2744, 504, 2800, 560, + 2856, 2912, 280, 280, 280, 2968, 280, 3024, 280, 280, + 3080, 3136, 3192, 3248, 3304, 3360, 3416, 3472, 3528, 3584, + 3640, 3696, 3752, 3808, 3864, 3920, 3976, 4032, 1680, 280, + 280, 280, 4088, 280, 4144, 280, 280, 280, 280, 280, + 280, 280, 280, 4200, 4256, 4312, 4368, 4424, 4480, 4536, + 4592, 4648, 280, 4704, 4760, 2968, 280, 4816, 4872, 4928, + 728, 4984, 5040, 5096, 5152, 5208, 5264, 5320, 5376, 5432, + 5488, 5544, 5600, 5656, 5712, 5768, 5824, 5880, 5936, 5992, + 6048, 6104, 6160, 6216, 6272, 6328, 6384, 280, 6440, 6496, + 280, 6552, 6608, 6664, 6720, 6776, 6832, 6888, 6944, 280, + 7000, 7056, 7112, 7168, 7224, 7280, 7336, 7392, 280, 7448, + 7504, 7560, 7616, 7672, 280, 7728, 6328, 7784, 7840, 7896, + 7952, 8008, 8064, 8120, 8176, 8232, 8288, 8344, 8400, 8456, + 8512, 8568, 280, 8624, 8680, 8736, 8792, 8848, 8904, 8960, + 280, 9016, 9072, 9128, 9184, 9240, 9296, 280, 9352, 9408, + 280, 9464, 9520, 9576, 9632, 9688, 9744, 9800, 9856, 280, + 9912, 9968, 10024, 10080, 10136, 280, 10192, 10248, 10304, 10360, + 280, 10416, 280, 280, 10472, 10528, 10584, 10640, 10696, 10752, + 280, 10808, 10864, 280, 10920, 280, 10976, 11032, 11088, 11144, + 11200, 11256, 11312, 11368, 280, 11424, 11480, 11536, 11592, 11648, + 11704, 11760, 11816, 11872, 11928, 11984, 12040, 12096, 12152, 12208, + 12264, 12320, 280, 12376, 12432, 12488, 12544, 280, 12600, 12656, + 12712, 12768, 12824, 12880, 12936, 12992, 13048, 13104, 728, 13160, + 280, 13216, 13272, 13328, 13384, 13440, 13496, 280, 13552, 13608, + 728, 13664, 13720, 13776, 280, 13832, 280, 13888, 13944, 14000, + 14056, 14112, 728, 14168, 14224, 14280, 280, 14336, 14392, 14448, + 728, 14504, 14560, 280, 14616, 14672, 14728, 14784, 728, 280 + }; + + /** + * The packed transition table of the DFA (part 0) + */ + final private static String yy_packed0 = + "\1\6\1\7\1\10\1\11\1\6\1\12\1\13\1\14"+ + "\1\15\1\16\1\17\1\20\1\21\1\22\1\23\1\21"+ + "\1\24\1\25\1\26\1\27\1\30\1\31\1\32\1\33"+ + "\1\21\1\34\1\35\1\36\1\21\1\37\1\40\1\41"+ + "\3\21\1\42\2\21\1\43\3\21\1\44\1\45\1\46"+ + "\1\47\1\50\1\51\1\52\1\53\1\54\1\55\1\56"+ + "\1\57\1\60\1\11\1\61\2\6\1\61\1\62\1\63"+ + "\62\61\1\64\2\6\1\64\1\65\16\64\1\63\44\64"+ + "\1\6\2\66\1\67\22\6\1\70\1\71\6\6\1\72"+ + "\31\6\1\11\1\73\1\74\65\11\72\0\1\10\1\75"+ + "\22\0\1\76\1\77\6\0\1\100\13\0\1\44\10\0"+ + "\1\101\7\0\1\75\22\0\1\76\1\77\6\0\1\100"+ + "\13\0\1\44\10\0\1\101\12\0\1\102\1\103\63\0"+ + "\1\104\6\0\1\105\55\0\10\106\1\107\1\110\56\106"+ + "\12\0\1\111\1\112\66\0\1\113\71\0\4\21\4\0"+ + "\22\21\1\0\3\21\32\0\4\21\4\0\21\21\1\114"+ + "\1\0\2\21\1\114\32\0\1\21\2\23\1\21\4\0"+ + "\22\21\1\0\3\21\33\0\1\115\1\116\1\0\1\117"+ + "\64\0\1\115\1\116\2\0\1\120\70\0\1\121\61\0"+ + "\4\21\4\0\1\21\1\122\7\21\1\123\2\21\1\124"+ + "\5\21\1\0\3\21\32\0\4\21\4\0\3\21\1\125"+ + "\16\21\1\0\3\21\32\0\4\21\4\0\20\21\1\126"+ + "\1\21\1\0\3\21\32\0\4\21\4\0\1\21\1\127"+ + "\17\21\1\130\1\0\3\21\32\0\4\21\4\0\4\21"+ + "\1\131\11\21\1\132\3\21\1\0\3\21\32\0\4\21"+ + "\4\0\11\21\1\133\10\21\1\0\3\21\32\0\4\21"+ + "\4\0\10\21\1\134\4\21\1\135\4\21\1\0\3\21"+ + "\32\0\4\21\4\0\2\21\1\136\17\21\1\0\3\21"+ + "\32\0\4\21\4\0\3\21\1\137\16\21\1\0\3\21"+ + "\32\0\4\21\4\0\6\21\1\140\13\21\1\0\3\21"+ + "\32\0\4\21\4\0\4\21\1\141\11\21\1\142\3\21"+ + "\1\0\3\21\21\0\1\143\52\0\1\144\23\0\1\145"+ + "\67\0\1\146\56\0\1\147\1\150\1\151\57\0\1\152"+ + "\71\0\1\153\2\0\1\61\2\0\1\61\2\0\62\61"+ + "\4\0\1\154\1\155\17\0\1\156\1\157\1\0\1\160"+ + "\37\0\1\64\2\0\1\64\1\0\16\64\1\0\44\64"+ + "\4\0\1\154\16\0\1\161\1\0\1\156\1\157\1\0"+ + "\1\160\40\0\3\66\2\0\1\162\64\0\1\67\130\0"+ + "\1\163\70\0\1\164\51\0\1\165\42\0\1\74\131\0"+ + "\1\166\70\0\1\167\51\0\1\170\41\0\1\147\1\150"+ + "\1\101\64\0\7\171\1\172\60\171\13\0\1\173\57\0"+ + "\1\107\6\0\1\174\55\0\10\110\1\106\1\175\56\110"+ + "\14\0\1\21\3\176\4\0\3\21\1\176\1\21\3\176"+ + "\2\21\1\176\7\21\1\0\1\176\2\21\33\0\2\116"+ + "\73\0\1\177\61\0\4\21\4\0\2\21\1\200\17\21"+ + "\1\0\3\21\21\0\1\201\10\0\4\21\4\0\22\21"+ + "\1\0\3\21\32\0\4\21\4\0\17\21\1\202\2\21"+ + "\1\0\3\21\32\0\4\21\4\0\22\21\1\0\1\21"+ + "\1\203\1\21\32\0\4\21\4\0\17\21\1\204\2\21"+ + "\1\0\3\21\32\0\4\21\4\0\16\21\1\205\3\21"+ + "\1\0\3\21\32\0\4\21\4\0\2\21\1\206\14\21"+ + "\1\207\2\21\1\0\3\21\32\0\4\21\4\0\15\21"+ + "\1\210\4\21\1\0\3\21\32\0\4\21\4\0\1\21"+ + "\1\211\20\21\1\0\3\21\21\0\1\212\10\0\4\21"+ + "\4\0\22\21\1\0\3\21\32\0\4\21\4\0\6\21"+ + "\1\213\13\21\1\0\3\21\32\0\4\21\4\0\1\21"+ + "\1\214\20\21\1\0\3\21\32\0\4\21\4\0\6\21"+ + "\1\215\13\21\1\0\3\21\32\0\4\21\4\0\7\21"+ + "\1\216\12\21\1\0\3\21\32\0\4\21\4\0\4\21"+ + "\1\217\15\21\1\0\3\21\32\0\4\21\4\0\1\220"+ + "\21\21\1\0\3\21\32\0\4\21\4\0\22\21\1\0"+ + "\1\221\2\21\20\0\1\150\66\0\1\147\1\150\1\151"+ + "\72\0\1\222\1\223\123\0\1\224\67\0\1\225\57\0"+ + "\1\226\77\0\1\227\67\0\1\230\57\0\1\231\34\0"+ + "\7\171\1\232\60\171\6\233\1\234\1\235\60\233\13\0"+ + "\1\236\54\0\10\175\1\110\1\237\56\175\14\0\4\21"+ + "\4\0\3\21\1\240\16\21\1\0\3\21\21\0\1\201"+ + "\1\0\2\241\5\0\4\241\3\0\23\241\1\0\3\241"+ + "\32\0\4\21\4\0\10\21\1\242\4\21\1\243\4\21"+ + "\1\0\3\21\32\0\4\21\4\0\3\21\1\244\16\21"+ + "\1\0\3\21\32\0\4\21\4\0\14\21\1\245\5\21"+ + "\1\0\3\21\32\0\4\21\4\0\3\21\1\246\16\21"+ + "\1\0\3\21\32\0\4\21\4\0\15\21\1\247\4\21"+ + "\1\0\3\21\32\0\4\21\4\0\14\21\1\250\5\21"+ + "\1\0\3\21\32\0\4\21\4\0\7\21\1\251\12\21"+ + "\1\0\3\21\21\0\1\212\1\0\2\252\5\0\4\252"+ + "\3\0\23\252\1\0\3\252\32\0\4\21\4\0\11\21"+ + "\1\253\10\21\1\0\3\21\32\0\4\21\4\0\11\21"+ + "\1\254\10\21\1\0\3\21\32\0\4\21\4\0\2\21"+ + "\1\255\17\21\1\0\3\21\32\0\4\21\4\0\10\21"+ + "\1\256\11\21\1\0\3\21\21\0\1\257\10\0\4\21"+ + "\4\0\22\21\1\0\3\21\32\0\4\21\4\0\13\21"+ + "\1\260\6\21\1\0\3\21\32\0\4\21\4\0\10\21"+ + "\1\261\11\21\1\0\3\21\16\0\1\222\2\66\65\222"+ + "\7\223\1\262\60\223\27\0\1\263\101\0\1\264\62\0"+ + "\1\265\62\0\1\266\101\0\1\267\62\0\1\270\33\0"+ + "\6\171\1\271\1\232\60\171\7\233\1\272\60\233\7\273"+ + "\1\274\60\273\6\275\1\271\1\235\60\275\10\237\1\175"+ + "\1\0\56\237\14\0\4\21\4\0\4\21\1\276\15\21"+ + "\1\0\3\21\32\0\4\21\4\0\3\21\1\277\16\21"+ + "\1\0\3\21\32\0\4\21\4\0\4\21\1\300\15\21"+ + "\1\0\3\21\32\0\4\21\4\0\15\21\1\301\4\21"+ + "\1\0\3\21\21\0\1\302\10\0\4\21\4\0\22\21"+ + "\1\0\3\21\32\0\4\21\4\0\1\21\1\303\20\21"+ + "\1\0\3\21\32\0\4\21\4\0\4\21\1\304\15\21"+ + "\1\0\3\21\21\0\1\305\10\0\4\21\4\0\22\21"+ + "\1\0\3\21\32\0\4\21\4\0\2\21\1\306\17\21"+ + "\1\0\3\21\32\0\4\21\4\0\11\21\1\307\10\21"+ + "\1\0\3\21\32\0\4\21\4\0\2\21\1\310\17\21"+ + "\1\0\3\21\32\0\4\21\4\0\1\311\21\21\1\0"+ + "\3\21\32\0\4\21\4\0\6\21\1\312\13\21\1\0"+ + "\3\21\21\0\1\257\1\0\2\313\5\0\4\313\3\0"+ + "\23\313\1\0\3\313\32\0\4\21\4\0\6\21\1\314"+ + "\13\21\1\0\3\21\32\0\4\21\4\0\1\315\21\21"+ + "\1\0\3\21\16\0\6\223\1\66\1\262\60\223\30\0"+ + "\1\316\71\0\1\317\40\0\1\320\114\0\1\321\71\0"+ + "\1\322\35\0\6\275\1\323\1\235\60\275\6\324\1\323"+ + "\1\325\60\324\7\233\1\235\60\233\14\0\4\21\4\0"+ + "\5\21\1\326\14\21\1\0\3\21\32\0\4\21\4\0"+ + "\14\21\1\327\5\21\1\0\3\21\32\0\4\21\4\0"+ + "\2\21\1\330\17\21\1\0\3\21\32\0\4\21\4\0"+ + "\5\21\1\331\14\21\1\0\3\21\21\0\1\302\1\0"+ + "\2\332\5\0\4\332\3\0\23\332\1\0\3\332\32\0"+ + "\4\21\4\0\12\21\1\333\7\21\1\0\3\21\32\0"+ + "\4\21\4\0\2\21\1\334\17\21\1\0\3\21\21\0"+ + "\1\305\1\0\2\335\5\0\4\335\3\0\23\335\1\0"+ + "\3\335\32\0\4\21\4\0\1\336\21\21\1\0\3\21"+ + "\21\0\1\337\10\0\4\21\4\0\22\21\1\0\3\21"+ + "\21\0\1\340\10\0\4\21\4\0\22\21\1\0\3\21"+ + "\32\0\4\21\4\0\7\21\1\341\12\21\1\0\3\21"+ + "\32\0\4\21\4\0\4\21\1\342\15\21\1\0\3\21"+ + "\32\0\4\21\4\0\2\21\1\343\17\21\1\0\3\21"+ + "\32\0\4\21\4\0\7\21\1\344\12\21\1\0\3\21"+ + "\44\0\1\11\71\0\1\345\42\0\1\320\1\0\2\346"+ + "\5\0\4\346\3\0\23\346\1\0\3\346\44\0\1\347"+ + "\71\0\1\350\37\0\7\273\1\325\60\273\6\324\1\0"+ + "\1\325\60\324\14\0\4\21\4\0\6\21\1\351\13\21"+ + "\1\0\3\21\32\0\4\21\4\0\3\21\1\352\16\21"+ + "\1\0\3\21\21\0\1\353\3\0\1\354\4\0\4\21"+ + "\4\0\22\21\1\0\3\21\21\0\1\355\10\0\4\21"+ + "\4\0\22\21\1\0\3\21\32\0\4\21\4\0\11\21"+ + "\1\356\10\21\1\0\3\21\17\0\2\357\1\360\6\0"+ + "\1\361\1\0\4\21\4\0\22\21\1\0\3\21\32\0"+ + "\4\21\4\0\15\21\1\362\4\21\1\0\3\21\21\0"+ + "\1\337\1\0\2\363\5\0\4\363\3\0\23\363\1\0"+ + "\3\363\21\0\1\340\1\0\2\364\5\0\4\364\3\0"+ + "\23\364\1\0\3\364\21\0\1\365\10\0\4\21\4\0"+ + "\22\21\1\0\3\21\32\0\4\21\4\0\3\21\1\366"+ + "\16\21\1\0\3\21\32\0\4\21\4\0\3\21\1\367"+ + "\16\21\1\0\3\21\21\0\1\370\10\0\4\21\4\0"+ + "\22\21\1\0\3\21\45\0\1\11\41\0\3\347\22\0"+ + "\1\76\70\0\1\347\54\0\4\21\4\0\7\21\1\371"+ + "\12\21\1\0\3\21\32\0\4\21\4\0\1\21\1\372"+ + "\20\21\1\0\3\21\21\0\1\353\1\0\3\354\4\0"+ + "\4\354\3\0\23\354\1\0\3\354\21\0\1\355\1\0"+ + "\2\373\5\0\4\373\3\0\23\373\1\0\3\373\21\0"+ + "\1\374\5\0\1\375\2\0\4\21\4\0\22\21\1\376"+ + "\3\21\17\0\3\357\6\0\1\361\56\0\2\357\1\360"+ + "\1\0\2\361\3\0\1\361\1\0\4\361\3\0\23\361"+ + "\1\0\3\361\32\0\4\21\4\0\1\21\1\377\20\21"+ + "\1\0\3\21\21\0\1\365\1\0\2\u0100\5\0\4\u0100"+ + "\3\0\23\u0100\1\0\3\u0100\17\0\3\u0101\10\0\4\21"+ + "\4\0\1\21\1\u0102\1\21\1\u0103\1\21\1\u0104\1\21"+ + "\1\u0105\3\21\1\u0106\1\u0107\5\21\1\0\3\21\21\0"+ + "\1\u0108\10\0\4\21\4\0\22\21\1\0\3\21\21\0"+ + "\1\370\1\0\2\u0109\5\0\4\u0109\3\0\23\u0109\1\0"+ + "\3\u0109\32\0\4\21\4\0\3\21\1\u010a\16\21\1\0"+ + "\3\21\32\0\4\21\4\0\2\21\1\u010b\17\21\1\0"+ + "\3\21\21\0\1\374\1\0\2\376\2\0\1\375\2\0"+ + "\4\376\3\0\27\376\16\0\10\375\1\u010c\1\u010d\56\375"+ + "\3\0\1\u010e\10\0\4\21\4\0\22\21\1\0\3\21"+ + "\17\0\3\u0101\21\0\1\u010f\1\0\1\u0110\1\0\1\u0111"+ + "\1\0\1\u0112\3\0\1\u0113\1\u0114\43\0\4\21\4\0"+ + "\6\21\1\u0115\13\21\1\0\3\21\32\0\4\21\4\0"+ + "\1\21\1\u0116\20\21\1\0\3\21\32\0\4\21\4\0"+ + "\16\21\1\u0117\3\21\1\0\3\21\32\0\4\21\4\0"+ + "\10\21\1\u0118\11\21\1\0\3\21\32\0\4\21\4\0"+ + "\6\21\1\u0119\13\21\1\0\3\21\32\0\4\21\4\0"+ + "\15\21\1\u011a\4\21\1\0\3\21\21\0\1\u0108\1\0"+ + "\2\u011b\5\0\4\u011b\3\0\23\u011b\1\0\3\u011b\21\0"+ + "\1\u011c\10\0\4\21\4\0\22\21\1\0\3\21\32\0"+ + "\4\21\4\0\11\21\1\u011d\10\21\1\0\3\21\21\0"+ + "\1\u010c\6\0\1\u011e\55\0\10\u010d\1\375\1\u011f\56\u010d"+ + "\3\0\1\u010e\1\0\2\u0120\5\0\4\u0120\3\0\23\u0120"+ + "\1\0\3\u0120\50\0\1\u0121\62\0\1\u0122\104\0\1\u0123"+ + "\61\0\1\u0124\65\0\1\u0125\76\0\1\u0126\42\0\4\21"+ + "\4\0\14\21\1\u0127\5\21\1\0\3\21\32\0\4\21"+ + "\4\0\16\21\1\u0128\3\21\1\0\3\21\32\0\4\21"+ + "\4\0\1\21\1\u0129\20\21\1\0\3\21\32\0\4\21"+ + "\4\0\6\21\1\u012a\13\21\1\0\3\21\32\0\4\21"+ + "\4\0\4\21\1\u012b\15\21\1\0\3\21\32\0\4\21"+ + "\4\0\12\21\1\u012c\7\21\1\0\3\21\21\0\1\u011c"+ + "\1\0\2\u012d\5\0\4\u012d\3\0\23\u012d\1\0\3\u012d"+ + "\21\0\1\u012e\10\0\4\21\4\0\22\21\1\0\3\21"+ + "\31\0\1\376\54\0\10\u011f\1\u010d\1\u012f\56\u011f\40\0"+ + "\1\u0130\71\0\1\u0131\52\0\1\u0132\74\0\1\u0133\65\0"+ + "\1\u0134\75\0\1\u0135\45\0\4\21\4\0\3\21\1\u0136"+ + "\16\21\1\0\3\21\32\0\4\21\4\0\14\21\1\u0137"+ + "\5\21\1\0\3\21\32\0\4\21\4\0\7\21\1\u0138"+ + "\12\21\1\0\3\21\32\0\4\21\4\0\11\21\1\u0139"+ + "\10\21\1\0\3\21\32\0\4\21\4\0\16\21\1\u013a"+ + "\3\21\1\0\3\21\21\0\1\u012e\1\0\2\u013b\5\0"+ + "\4\u013b\3\0\23\u013b\1\0\3\u013b\16\0\10\u012f\1\u011f"+ + "\1\0\56\u012f\27\0\1\u013c\100\0\1\u013d\62\0\1\u013e"+ + "\71\0\1\u013f\74\0\1\u0140\41\0\4\21\4\0\11\21"+ + "\1\u0141\10\21\1\0\3\21\32\0\4\21\4\0\2\21"+ + "\1\u0142\17\21\1\0\3\21\32\0\4\21\4\0\11\21"+ + "\1\u0143\10\21\1\0\3\21\32\0\4\21\4\0\10\21"+ + "\1\u0144\11\21\1\0\3\21\53\0\1\u0145\60\0\1\u0146"+ + "\76\0\1\u0147\66\0\1\u0148\47\0\4\21\4\0\17\21"+ + "\1\u0149\2\21\1\0\3\21\32\0\4\21\4\0\1\u014a"+ + "\21\21\1\0\3\21\32\0\4\21\4\0\3\21\1\u014b"+ + "\16\21\1\0\3\21\61\0\1\u014c\50\0\1\u014d\72\0"+ + "\1\u014e\54\0\4\21\4\0\6\21\1\u014f\13\21\1\0"+ + "\3\21\32\0\4\21\4\0\15\21\1\u0150\4\21\1\0"+ + "\3\21\50\0\1\u0151\76\0\1\u0152\42\0\4\21\4\0"+ + "\7\21\1\u0144\12\21\1\0\3\21\32\0\4\21\4\0"+ + "\1\21\1\u0153\20\21\1\0\3\21\51\0\1\u0148\61\0"+ + "\1\u0154\42\0"; + + /** + * The transition table of the DFA + */ + final private static int yytrans [] = yy_unpack(); + + + /* error codes */ + final private static int YY_UNKNOWN_ERROR = 0; + final private static int YY_ILLEGAL_STATE = 1; + final private static int YY_NO_MATCH = 2; + final private static int YY_PUSHBACK_2BIG = 3; + + /* error messages for the codes above */ + final private static String YY_ERROR_MSG[] = { + "Unkown internal scanner error", + "Internal error: unknown state", + "Error: could not match input", + "Error: pushback value was too large" + }; + + /** + * YY_ATTRIBUTE[aState] contains the attributes of state aState + */ + private final static byte YY_ATTRIBUTE[] = { + 1, 0, 0, 1, 0, 9, 1, 1, 9, 9, 1, 9, 3, 3, 1, 1, + 1, 1, 1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 9, 9, 9, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, + 1, 1, 9, 1, 1, 1, 1, 1, 1, 1, 1, 9, 0, 0, 0, 0, + 1, 9, 0, 0, 0, 0, 0, 0, 9, 9, 9, 1, 9, 1, 9, 9, + 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, + 1, 1, 0, 9, 9, 9, 1, 9, 0, 9, 9, 9, 9, 9, 9, 9, + 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 1, 9, 1, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 3, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 13, 0, 1, + 13, 1, 1, 1, 3, 1, 1, 3, 1, 13, 1, 1, 1, 1, 0, 1, + 1, 0, 9, 0, 0, 2, 0, 0, 9, 0, 0, 0, 0, 1, 1, 1, + 1, 0, 1, 1, 0, 1, 3, 3, 1, 1, 13, 1, 1, 0, 0, 0, + 0, 0, 9, 0, 0, 1, 1, 3, 3, 13, 1, 3, 13, 1, 0, 0, + 3, 1, 1, 3, 0, 13, 0, 0, 1, 1, 0, 13, 0, 3, 0, 0, + 13, 1, 13, 13, 0, 1, 3, 0, 1, 1, 13, 0, 0, 13, 3, 13, + 0, 1, 1, 1, 1, 1, 1, 0, 13, 3, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 13, 0, 3, 0, 0, 13, + 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 13, 0, 0, 0, + 0, 0, 0, 9, 0, 1, 1, 1, 1, 1, 13, 0, 9, 0, 0, 0, + 1, 1, 1, 1, 0, 0, 9, 0, 1, 1, 1, 0, 0, 9, 1, 1, + 0, 0, 1, 9 + }; + + /** the input device */ + private java.io.Reader yy_reader; + + /** the current state of the DFA */ + private int yy_state; + + /** the current lexical state */ + private int yy_lexical_state = YYINITIAL; + + /** this buffer contains the current text to be matched and is + the source of the yytext() string */ + private char yy_buffer[] = new char[YY_BUFFERSIZE]; + + /** the textposition at the last accepting state */ + private int yy_markedPos; + + /** the textposition at the last state to be included in yytext */ + private int yy_pushbackPos; + + /** the current text position in the buffer */ + private int yy_currentPos; + + /** startRead marks the beginning of the yytext() string in the buffer */ + private int yy_startRead; + + /** endRead marks the last character in the buffer, that has been read + from input */ + private int yy_endRead; + + /** number of newlines encountered up to the start of the matched text */ + private int yyline; + + /** the number of characters up to the start of the matched text */ + private int yychar; + + /** + * the number of characters from the last newline up to the start of the + * matched text + */ + private int yycolumn; + + /** + * yy_atBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean yy_atBOL = true; + + /** yy_atEOF == true <=> the scanner is at the EOF */ + private boolean yy_atEOF; + + /** denotes if the user-EOF-code has already been executed */ + private boolean yy_eof_done; + + /* user code: */ + StringBuffer string=new StringBuffer(); + String fileName; + public void setFileName(String name) { + fileName=name; + } + public String getFileName() { + return fileName; + } + private Symbol symbol(int type) { + return new Symbol(type,yyline,yycolumn, + new Token(type,fileName,yytext(), + yyline+1,yycolumn+1, + yycolumn+1+yytext().length())); + } + private Symbol symbol(int type, String value) { + return new Symbol(type,yyline,yycolumn, + new Token(type,fileName,value, + yyline+1,yycolumn+1, + yycolumn+1+yytext().length())); + } + private Stack openParens = new Stack(); + + + /** + * Creates a new scanner + * There is also a java.io.InputStream version of this constructor. + * + * @param in the java.io.Reader to read input from. + */ + TypescriptDefScanner(java.io.Reader in) { + this.yy_reader = in; + } + + /** + * Creates a new scanner. + * There is also java.io.Reader version of this constructor. + * + * @param in the java.io.Inputstream to read input from. + */ + TypescriptDefScanner(java.io.InputStream in) { + this(new java.io.InputStreamReader(in)); + } + + /** + * Unpacks the split, compressed DFA transition table. + * + * @return the unpacked transition table + */ + private static int [] yy_unpack() { + int [] trans = new int[14840]; + int offset = 0; + offset = yy_unpack(yy_packed0, offset, trans); + return trans; + } + + /** + * Unpacks the compressed DFA transition table. + * + * @param packed the packed transition table + * @return the index of the last entry + */ + private static int yy_unpack(String packed, int offset, int [] trans) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + value--; + do trans[j++] = value; while (--count > 0); + } + return j; + } + + /** + * Unpacks the compressed character translation table. + * + * @param packed the packed character translation table + * @return the unpacked character translation table + */ + private static char [] yy_unpack_cmap(String packed) { + char [] map = new char[0x10000]; + int i = 0; /* index in packed string */ + int j = 0; /* index in unpacked array */ + while (i < 154) { + int count = packed.charAt(i++); + char value = packed.charAt(i++); + do map[j++] = value; while (--count > 0); + } + return map; + } + + + /** + * Refills the input buffer. + * + * @return false, iff there was new input. + * + * @exception IOException if any I/O-Error occurs + */ + private boolean yy_refill() throws java.io.IOException { + + /* first: make room (if you can) */ + if (yy_startRead > 0) { + System.arraycopy(yy_buffer, yy_startRead, + yy_buffer, 0, + yy_endRead-yy_startRead); + + /* translate stored positions */ + yy_endRead-= yy_startRead; + yy_currentPos-= yy_startRead; + yy_markedPos-= yy_startRead; + yy_pushbackPos-= yy_startRead; + yy_startRead = 0; + } + + /* is the buffer big enough? */ + if (yy_currentPos >= yy_buffer.length) { + /* if not: blow it up */ + char newBuffer[] = new char[yy_currentPos*2]; + System.arraycopy(yy_buffer, 0, newBuffer, 0, yy_buffer.length); + yy_buffer = newBuffer; + } + + /* finally: fill the buffer with new input */ + int numRead = yy_reader.read(yy_buffer, yy_endRead, + yy_buffer.length-yy_endRead); + + if (numRead < 0) { + return true; + } + else { + yy_endRead+= numRead; + return false; + } + } + + + /** + * Closes the input stream. + */ + final public void yyclose() throws java.io.IOException { + yy_atEOF = true; /* indicate end of file */ + yy_endRead = yy_startRead; /* invalidate buffer */ + + if (yy_reader != null) + yy_reader.close(); + } + + + /** + * Closes the current stream, and resets the + * scanner to read from a new input stream. + * + * All internal variables are reset, the old input stream + * cannot be reused (internal buffer is discarded and lost). + * Lexical state is set to YY_INITIAL. + * + * @param reader the new input stream + */ + final public void yyreset(java.io.Reader reader) throws java.io.IOException { + yyclose(); + yy_reader = reader; + yy_atBOL = true; + yy_atEOF = false; + yy_endRead = yy_startRead = 0; + yy_currentPos = yy_markedPos = yy_pushbackPos = 0; + yyline = yychar = yycolumn = 0; + yy_lexical_state = YYINITIAL; + } + + + /** + * Returns the current lexical state. + */ + final public int yystate() { + return yy_lexical_state; + } + + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + final public void yybegin(int newState) { + yy_lexical_state = newState; + } + + + /** + * Returns the text matched by the current regular expression. + */ + final public String yytext() { + return new String( yy_buffer, yy_startRead, yy_markedPos-yy_startRead ); + } + + + /** + * Returns the character at position pos from the + * matched text. + * + * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. + * A value from 0 to yylength()-1. + * + * @return the character at position pos + */ + final public char yycharat(int pos) { + return yy_buffer[yy_startRead+pos]; + } + + + /** + * Returns the length of the matched text region. + */ + final public int yylength() { + return yy_markedPos-yy_startRead; + } + + + /** + * Reports an error that occured while scanning. + * + * In a wellformed scanner (no or only correct usage of + * yypushback(int) and a match-all fallback rule) this method + * will only be called with things that "Can't Possibly Happen". + * If this method is called, something is seriously wrong + * (e.g. a JFlex bug producing a faulty scanner etc.). + * + * Usual syntax/scanner level error handling should be done + * in error fallback rules. + * + * @param errorCode the code of the errormessage to display + */ + private void yy_ScanError(int errorCode) { + String message; + try { + message = YY_ERROR_MSG[errorCode]; + } + catch (ArrayIndexOutOfBoundsException e) { + message = YY_ERROR_MSG[YY_UNKNOWN_ERROR]; + } + + throw new Error(message); + } + + + /** + * Pushes the specified amount of characters back into the input stream. + * + * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. + * This number must not be greater than yylength()! + */ + private void yypushback(int number) { + if ( number > yylength() ) + yy_ScanError(YY_PUSHBACK_2BIG); + + yy_markedPos -= number; + } + + + /** + * Contains user EOF-code, which will be executed exactly once, + * when the end of file is reached + */ + private void yy_do_eof() throws java.io.IOException { + if (!yy_eof_done) { + yy_eof_done = true; + yyclose(); + } + } + + + /** + * Resumes scanning until the next regular expression is matched, + * the end of input is encountered or an I/O-Error occurs. + * + * @return the next token + * @exception IOException if any I/O-Error occurs + */ + public java_cup.runtime.Symbol next_token() throws java.io.IOException { + int yy_input; + int yy_action; + + // cached fields: + int yy_currentPos_l; + int yy_startRead_l; + int yy_markedPos_l; + int yy_endRead_l = yy_endRead; + char [] yy_buffer_l = yy_buffer; + char [] yycmap_l = yycmap; + + int [] yytrans_l = yytrans; + int [] yy_rowMap_l = yy_rowMap; + byte [] yy_attr_l = YY_ATTRIBUTE; + int yy_pushbackPos_l = yy_pushbackPos = -1; + boolean yy_was_pushback; + + while (true) { + yy_markedPos_l = yy_markedPos; + + boolean yy_r = false; + for (yy_currentPos_l = yy_startRead; yy_currentPos_l < yy_markedPos_l; + yy_currentPos_l++) { + switch (yy_buffer_l[yy_currentPos_l]) { + case '\u000B': + case '\u000C': + case '\u0085': + case '\u2028': + case '\u2029': + yyline++; + yycolumn = 0; + yy_r = false; + break; + case '\r': + yyline++; + yycolumn = 0; + yy_r = true; + break; + case '\n': + if (yy_r) + yy_r = false; + else { + yyline++; + yycolumn = 0; + } + break; + default: + yy_r = false; + yycolumn++; + } + } + + if (yy_r) { + // peek one character ahead if it is \n (if we have counted one line too much) + boolean yy_peek; + if (yy_markedPos_l < yy_endRead_l) + yy_peek = yy_buffer_l[yy_markedPos_l] == '\n'; + else if (yy_atEOF) + yy_peek = false; + else { + boolean eof = yy_refill(); + yy_markedPos_l = yy_markedPos; + yy_buffer_l = yy_buffer; + if (eof) + yy_peek = false; + else + yy_peek = yy_buffer_l[yy_markedPos_l] == '\n'; + } + if (yy_peek) yyline--; + } + yy_action = -1; + + yy_startRead_l = yy_currentPos_l = yy_currentPos = + yy_startRead = yy_markedPos_l; + + yy_state = yy_lexical_state; + + yy_was_pushback = false; + + yy_forAction: { + while (true) { + + if (yy_currentPos_l < yy_endRead_l) + yy_input = yy_buffer_l[yy_currentPos_l++]; + else if (yy_atEOF) { + yy_input = YYEOF; + break yy_forAction; + } + else { + // store back cached positions + yy_currentPos = yy_currentPos_l; + yy_markedPos = yy_markedPos_l; + yy_pushbackPos = yy_pushbackPos_l; + boolean eof = yy_refill(); + // get translated positions and possibly new buffer + yy_currentPos_l = yy_currentPos; + yy_markedPos_l = yy_markedPos; + yy_buffer_l = yy_buffer; + yy_endRead_l = yy_endRead; + yy_pushbackPos_l = yy_pushbackPos; + if (eof) { + yy_input = YYEOF; + break yy_forAction; + } + else { + yy_input = yy_buffer_l[yy_currentPos_l++]; + } + } + int yy_next = yytrans_l[ yy_rowMap_l[yy_state] + yycmap_l[yy_input] ]; + if (yy_next == -1) break yy_forAction; + yy_state = yy_next; + + int yy_attributes = yy_attr_l[yy_state]; + if ( (yy_attributes & 2) == 2 ) + yy_pushbackPos_l = yy_currentPos_l; + + if ( (yy_attributes & 1) == 1 ) { + yy_was_pushback = (yy_attributes & 4) == 4; + yy_action = yy_state; + yy_markedPos_l = yy_currentPos_l; + if ( (yy_attributes & 8) == 8 ) break yy_forAction; + } + + } + } + + // store back cached position + yy_markedPos = yy_markedPos_l; + if (yy_was_pushback) + yy_markedPos = yy_pushbackPos_l; + + switch (yy_action) { + + case 314: + { return symbol(sym.IMPLEMENTS); } + case 341: break; + case 298: + case 307: + { return symbol(sym.DECLARE_VAR); } + case 342: break; + case 0: + case 16: + case 23: + case 24: + case 25: + case 26: + case 27: + case 28: + case 29: + case 30: + case 31: + case 32: + case 33: + case 75: + case 81: + case 82: + case 83: + case 84: + case 85: + case 86: + case 87: + case 88: + case 89: + case 90: + case 91: + case 92: + case 93: + case 94: + case 95: + case 96: + case 97: + case 127: + case 129: + case 131: + case 132: + case 133: + case 134: + case 135: + case 136: + case 138: + case 139: + case 140: + case 141: + case 142: + case 143: + case 144: + case 159: + case 161: + case 162: + case 163: + case 164: + case 165: + case 166: + case 167: + case 168: + case 170: + case 171: + case 172: + case 173: + case 175: + case 176: + case 189: + case 190: + case 191: + case 192: + case 194: + case 195: + case 197: + case 198: + case 199: + case 200: + case 201: + case 203: + case 204: + case 213: + case 214: + case 215: + case 216: + case 218: + case 219: + case 221: + case 224: + case 225: + case 226: + case 227: + case 232: + case 233: + case 237: + case 241: + case 245: + case 246: + case 248: + case 249: + case 254: + case 257: + case 258: + case 259: + case 260: + case 261: + case 262: + case 265: + case 266: + case 276: + case 277: + case 278: + case 279: + case 280: + case 281: + case 284: + case 294: + case 295: + case 296: + case 297: + case 299: + case 309: + case 311: + case 312: + case 313: + case 320: + case 321: + case 323: + case 328: + case 329: + case 334: + case 335: + { return symbol(sym.IDENTIFIER); } + case 343: break; + case 58: + case 59: + { yybegin(YYINITIAL); yypushback(yylength()); } + case 344: break; + case 79: + { return symbol(sym.MINUSMINUS); } + case 345: break; + case 122: + { return symbol(sym.RPAREN_FUNC); } + case 346: break; + case 157: + { return symbol(sym.LPAREN_FUNC); } + case 347: break; + case 300: + { return symbol(sym.INTERFACE); } + case 348: break; + case 287: + { return symbol(sym.FUNCTION); } + case 349: break; + case 45: + { return symbol(sym.QUESTION); } + case 350: break; + case 78: + { return symbol(sym.PLUSPLUS); } + case 351: break; + case 101: + { return symbol(sym.NOTEQUALS); } + case 352: break; + case 126: + { return symbol(sym.DOTDOTDOT); } + case 353: break; + case 47: + { return symbol(sym.AT); } + case 354: break; + case 46: + { return symbol(sym.AND); } + case 355: break; + case 42: + { return symbol(sym.NOT); } + case 356: break; + case 40: + { return symbol(sym.LT); } + case 357: break; + case 35: + { return symbol(sym.COL); } + case 358: break; + case 10: + { return symbol(sym.DIV); } + case 359: break; + case 8: + { /* ignore */ } + case 360: break; + case 3: + case 54: + { /* ignore */ } + case 361: break; + case 15: + { return symbol(sym.GT); } + case 362: break; + case 17: + case 18: + case 76: + case 77: + { return symbol(sym.INT); } + case 363: break; + case 21: + { return symbol(sym.DOT); } + case 364: break; + case 53: + { return symbol(sym.LF); } + case 365: break; + case 74: + { return symbol(sym.GTE); } + case 366: break; + case 100: + { return symbol(sym.LTE); } + case 367: break; + case 125: + { return symbol(sym.INT); } + case 368: break; + case 130: + { return symbol(sym.NEW); } + case 369: break; + case 160: + { return symbol(sym.IS); } + case 370: break; + case 169: + { return symbol(sym.AS); } + case 371: break; + case 202: + { return symbol(sym.VAR); } + case 372: break; + case 210: + { return symbol(sym.DOC); } + case 373: break; + case 5: + case 55: + case 56: + case 57: + { System.out.println("unmatched:"+yytext()); } + case 374: break; + case 178: + { yybegin(YYINITIAL); return symbol(sym.TYPE_MACRO); } + case 375: break; + case 322: + case 326: + { return symbol(sym.DECLARE_CLASS); } + case 376: break; + case 310: + case 316: + { return symbol(sym.DECLARE_ENUM); } + case 377: break; + case 243: + { return symbol(sym.CONST); } + case 378: break; + case 242: + { return symbol(sym.CLASS); } + case 379: break; + case 44: + { return symbol(sym.TUBE); } + case 380: break; + case 41: + { return symbol(sym.COMMA); } + case 381: break; + case 36: + { return symbol(sym.SEMI); } + case 382: break; + case 11: + { return symbol(sym.MULT); } + case 383: break; + case 19: + { return symbol(sym.PLUS); } + case 384: break; + case 20: + { return symbol(sym.MINUS); } + case 385: break; + case 64: + { return symbol(sym.TUBE); } + case 386: break; + case 102: + case 103: + { return symbol(sym.TUBE); } + case 387: break; + case 105: + { return symbol(sym.OROR); } + case 388: break; + case 217: + { return symbol(sym.ENUM); } + case 389: break; + case 220: + { return symbol(sym.FROM); } + case 390: break; + case 49: + { string.append('\\'); } + case 391: break; + case 52: + { string.append('\\'); } + case 392: break; + case 107: + { string.append('\\'); } + case 393: break; + case 108: + { string.append('\"'); } + case 394: break; + case 109: + { string.append('\n'); } + case 395: break; + case 110: + { string.append('\t'); } + case 396: break; + case 111: + { string.append('\r'); } + case 397: break; + case 112: + { string.append('\''); } + case 398: break; + case 65: + { yybegin(EOL_COMMENT); } + case 399: break; + case 338: + case 339: + { return symbol(sym.DECLARE_FUNCTION); } + case 400: break; + case 50: + { yybegin(YYINITIAL); + return symbol(sym.IDENTIFIER, + "\""+string.toString()+"\""); } + case 401: break; + case 229: + { yypushback(yylength()); yybegin(TYPE_MACRO); } + case 402: break; + case 6: + case 7: + { /*System.err.println("LF");*/ return symbol(sym.LF); } + case 403: break; + case 155: + case 184: + { /*System.err.println("COMMENT: "+yytext());*/ /* ignore */ } + case 404: break; + case 22: + { string.setLength(0); yybegin(CHAR); } + case 405: break; + case 330: + case 333: + { return symbol(sym.DECLARE_MODULE); } + case 406: break; + case 9: + { string.setLength(0); yybegin(STRING); } + case 407: break; + case 282: + { return symbol(sym.PRIVATE); } + case 408: break; + case 264: + { return symbol(sym.PUBLIC); } + case 409: break; + case 255: + { return symbol(sym.STATIC); } + case 410: break; + case 253: + { return symbol(sym.EXTENDS); } + case 411: break; + case 250: + { return symbol(sym.TYPEOF); } + case 412: break; + case 240: + { return symbol(sym.EXPORT); } + case 413: break; + case 235: + { return symbol(sym.IMPORT); } + case 414: break; + case 51: + { string.append( yytext() ); } + case 415: break; + case 48: + { string.append( yytext() ); } + case 416: break; + case 43: + { return symbol(sym.MATCHES); } + case 417: break; + case 39: + { return symbol(sym.RSPAREN); } + case 418: break; + case 38: + { return symbol(sym.LSPAREN); } + case 419: break; + case 37: + { return symbol(sym.RCPAREN); } + case 420: break; + case 34: + { return symbol(sym.LCPAREN); } + case 421: break; + case 12: + { return symbol(sym.RPAREN); } + case 422: break; + case 13: + { return symbol(sym.LPAREN); } + case 423: break; + case 14: + { return symbol(sym.ASSIGN); } + case 424: break; + case 72: + { return symbol(sym.EQUALS); } + case 425: break; + case 73: + { return symbol(sym.IMPLIES); } + case 426: break; + case 80: + { return symbol(sym.DOTDOT); } + case 427: break; + case 99: + { return symbol(sym.SQUARE); } + case 428: break; + case 106: + { return symbol(sym.ANDAND); } + case 429: break; + default: + if (yy_input == YYEOF && yy_startRead == yy_currentPos) { + yy_atEOF = true; + yy_do_eof(); + switch (yy_lexical_state) { + case EOL_COMMENT: + { yybegin(YYINITIAL); } + case 341: break; + default: + { return new java_cup.runtime.Symbol(sym.EOF); } + } + } + else { + yy_ScanError(YY_NO_MATCH); + } + } + } + } + + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/sym.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/sym.java new file mode 100644 index 00000000..c32f2431 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/sym.java @@ -0,0 +1,88 @@ + +//---------------------------------------------------- +// The following code was generated by CUP v0.10k +// Sun Jul 24 16:44:06 CEST 2016 +//---------------------------------------------------- + +package org.jsweet.input.typescriptdef.parser; + +/** CUP generated class containing symbol constants. */ +public class sym { + /* terminals */ + public static final int AT = 37; + public static final int AS = 69; + public static final int IDENTIFIER = 43; + public static final int FROM = 70; + public static final int GT = 18; + public static final int TYPEOF = 66; + public static final int IMPLEMENTS = 63; + public static final int CONST = 67; + public static final int EXPORT = 47; + public static final int DECLARE_MODULE = 54; + public static final int SEMI = 7; + public static final int DECLARE_FUNCTION = 55; + public static final int ENUM = 71; + public static final int LPAREN_FUNC = 73; + public static final int SQUARE = 14; + public static final int COMMA = 3; + public static final int RPAREN = 9; + public static final int LT = 15; + public static final int ANDAND = 31; + public static final int OROR = 30; + public static final int DECLARE = 53; + public static final int LPAREN = 8; + public static final int PROTECTED = 50; + public static final int FALSE = 42; + public static final int NOT = 33; + public static final int DOTDOTDOT = 6; + public static final int LF = 72; + public static final int TYPE_MACRO = 58; + public static final int RCPAREN = 11; + public static final int VAR = 61; + public static final int NOTEQUALS = 21; + public static final int LCPAREN = 10; + public static final int DECLARE_ENUM = 57; + public static final int NUM = 40; + public static final int DOLLAR = 45; + public static final int CLASS = 60; + public static final int ABSTRACT = 52; + public static final int TUBE = 34; + public static final int TRUE = 41; + public static final int MATCHES = 36; + public static final int PLUS = 26; + public static final int QUESTION = 44; + public static final int EXTENDS = 62; + public static final int ASSIGN = 19; + public static final int INTERFACE = 59; + public static final int RPAREN_FUNC = 74; + public static final int DIV = 23; + public static final int PUBLIC = 51; + public static final int MULT = 22; + public static final int DOTDOT = 5; + public static final int DOT = 4; + public static final int INT = 39; + public static final int LTE = 16; + public static final int REFERENCE = 29; + public static final int EOF = 0; + public static final int COL = 2; + public static final int FUNCTION = 48; + public static final int DOC = 28; + public static final int IMPORT = 46; + public static final int RSPAREN = 13; + public static final int IS = 68; + public static final int MINUS = 24; + public static final int ARROW_RIGHT = 38; + public static final int error = 1; + public static final int GTE = 17; + public static final int MINUSMINUS = 25; + public static final int LSPAREN = 12; + public static final int PLUSPLUS = 27; + public static final int NEW = 64; + public static final int DECLARE_CLASS = 56; + public static final int AND = 32; + public static final int PRIVATE = 49; + public static final int IMPLIES = 35; + public static final int STATIC = 65; + public static final int EQUALS = 20; +} + diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/test.d.ts b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/test.d.ts new file mode 100644 index 00000000..78122b5d --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/test.d.ts @@ -0,0 +1,108 @@ + +enum StatusEnum { + connected, connecting, + failed, waiting, offline +} + +interface NodeListOf extends NodeList, T, U { + length: { + } + item(index: number /** Buffer **/ ): TNode; + [index: number]: TNode; + static : number; + static: number; + extends: string; + extends : string; + /** + * test + */ +} + +class Model extends ModelBase { + + object(...keyValuePairs: any[][]): T; + + /** + * Do not use, prefer TypeScript's extend functionality. + **/ + private static extend(properties: any, classProperties?: any): any; + + attributes: any; + changed: any[]; + cid: string; + collection: Collection; +} + +module 'm' { + + // test + + type T = string | number; + + /////////////////////////////////////////////////////////////////////////// + // SCEService + // see http://docs.angularjs.org/api/ng.$sce + /////////////////////////////////////////////////////////////////////////// + + /** + * titi + */ + interface ISCEService { + getTrusted(type: string, mayBeTrusted: any): any; + } + + interface Tinytest { + add(name:string, func:Function):any; + addAsync(name:string, func:Function):any; + } + + enum StatusEnum { + connected, + connecting, + failed, + waiting, + offline + } + + export = i; + + /** the * promise of the original server interaction that created this instance. ** **/ + interface I2<{ test: string; }> extends I { + + /** The notify function can either be passed a string or an object. */ + + (translationId: string[], interpolateParams?: any, interpolationId?: string): ng.IPromise<{ [key: string]: string }>; + + var test: string; + + a(b: any, c : number): string; + + b(f : ((n: number) => void )[]) : t.x.y; + + [a : number] : T; + + (b: any, c: number): string; + + a2(b: { p1: P1; f(x:number):string; } [], c : number): string; + + function getLevel(nameOrValue: string): webdriver.logging.Level; + + sendKeys(...var_args: string[]): webdriver.promise.Promise; + } + + module logging { + var Preferences: any; + + class LevelName extends webdriver.logging.LevelName { } + class Type extends webdriver.logging.Type { } + class Level extends webdriver.logging.Level { } + class Entry extends webdriver.logging.Entry { } + + function getLevel(nameOrValue: string): webdriver.logging.Level; + function getLevel(nameOrValue: number): webdriver.logging.Level; + } + + +} + +// TODO: support object_type @tsdef\angular-http-auth\angular-http-auth.d.ts diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/typescriptdef.cup b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/typescriptdef.cup new file mode 100644 index 00000000..969c5da5 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/typescriptdef.cup @@ -0,0 +1,628 @@ + +/* + * This source code file is the exclusive property of its author. No copy or + * usage of the source code is permitted unless the author contractually + * allows it under the terms of a well-defined agreement. + */ + +import java.util.*; +import java.io.*; +import org.apache.commons.lang3.*; +import org.jsweet.input.typescriptdef.ast.*; + +parser code {: + + public PrintStream out = System.out; + public PrintStream err = System.err; + public CompilationUnit compilationUnit; + public Stack comments = new Stack(); + + protected static TypescriptDefParser createParser(File file) throws java.io.FileNotFoundException { + TypescriptDefScanner scanner= new TypescriptDefScanner(new java.io.FileReader(file)); + scanner.setFileName(file.getPath()); + TypescriptDefParser parser= new TypescriptDefParser(scanner); + parser.compilationUnit = new CompilationUnit(file); + return parser; + } + + public static TypescriptDefParser parseFile(File file) throws java.io.FileNotFoundException { + TypescriptDefParser parser= createParser(file); + try { + parser.parse(); + } catch(Exception e) { + e.printStackTrace(); + parser.errors.add(new SyntaxError(null, "internal parser error")); + } + return parser; + } + + public List errors = new ArrayList(); + + public void syntax_error(java_cup.runtime.Symbol current) { + //errors.add(new SyntaxError("syntax error: '"+current.value + "' is not expected", at " + (current.left+1)+"("+(current.right+1)+")" ); + SyntaxError e = new SyntaxError((Token)current.value, "'"+current.value + "' is not expected"); + errors.add(e); + System.err.println(e); + } + + public void syntax_error(Token current) { + SyntaxError e = new SyntaxError(current, "'"+current + "' is not expected"); + errors.add(e); + System.err.println(e); + } + + public void unrecovered_syntax_error(java_cup.runtime.Symbol current) { + System.err.println("unable to recover from previous error(s)... giving up!"); + } + + public void printErrors(PrintStream out) { + for (SyntaxError error : errors) { + out.println(error.toString()); + } + } + + public boolean hasErrors() { + return !errors.isEmpty(); + } + + + +:}; + +terminal COL, COMMA, DOT, DOTDOT, DOTDOTDOT, SEMI; +terminal LPAREN, RPAREN, LCPAREN, RCPAREN, LSPAREN, RSPAREN, SQUARE; +terminal LT, LTE, GTE, GT, ASSIGN, EQUALS, NOTEQUALS, MULT, DIV, MINUS, MINUSMINUS, PLUS, PLUSPLUS; +terminal DOC, REFERENCE; + +terminal OROR, ANDAND, AND, NOT, TUBE, IMPLIES, MATCHES; +terminal AT, ARROW_RIGHT; +terminal INT, NUM, TRUE, FALSE; +terminal IDENTIFIER; +terminal QUESTION, DOLLAR; +// keywords +terminal IMPORT, EXPORT, FUNCTION, PRIVATE, PROTECTED, PUBLIC, ABSTRACT; +terminal DECLARE, /*DECLARE_VAR,*/ DECLARE_MODULE, DECLARE_FUNCTION, DECLARE_CLASS, DECLARE_ENUM, TYPE_MACRO; +terminal INTERFACE, CLASS, VAR, EXTENDS, IMPLEMENTS, NEW; +//terminal MODULE; +terminal STATIC, TYPEOF, CONST, IS, AS, FROM; +terminal ENUM; +terminal LF; +terminal LPAREN_FUNC, RPAREN_FUNC; + +non terminal comp_unit, declaration_list_opt, declaration_list, declaration_with_error, declaration, declaration_nodoc; +non terminal type_macro, type_decl, type_kind, var_decl, module_decl, func_decl, constructor_decl, index_sig_decl, export_decl, import_decl; +non terminal param_list_opt, param_list, param, optional_opt, varargs_opt; +non terminal member_list_opt, member_list, member_elt_with_error, member_elt, member_elt_nodoc; +non terminal enum_decl, enum_member_list, enum_member_list_opt, enum_member_elt_with_error, enum_member_elt, enum_member_elt_nodoc; +non terminal type_annotation_opt, type_annotation, type, basic_type, union_type, intersection_type, array_type, functional_type, new_functional_type, simple_type, object_type, typeof_type, is_type, tuple_type; +non terminal declare_opt, var_opt, const_opt; +non terminal qual_id; +non terminal import_spec; +non terminal type_param_list_opt, type_param_list, type_param; +non terminal type_arg_list_opt, type_arg_list, type_arg_and; +non terminal extends_opt, implements_opt; +non terminal lf, semi_or_lf, semi_or_lf_opt, lf_opt, semi_or_comma_or_lf, semi_or_comma_or_lf_opt; +non terminal type_list; +non terminal doc_list, doc_list_opt, doc_opt; +non terminal literal, export_opt, var_or_const, abstract_opt, export_element_list, export_element; + +precedence left AND, TUBE; +precedence right LF; +precedence right COMMA; +precedence right DOC; + +start with comp_unit; + +/***************************************************************/ +/*** TYPESCRIPT DEFINITION FILES GRAMMAR **/ +/***************************************************************/ + +comp_unit ::= declaration_list_opt:decls {: parser.compilationUnit.setDeclarations((Declaration[])decls); :}; + +declaration_list_opt ::= lf_opt declaration_list:l semi_or_lf_opt {: + parser.comments.pop(); + RESULT = l; + :} | lf_opt {: RESULT = new Declaration[0]; :}; + +declaration_list ::= declaration_list:l semi_or_lf declaration_with_error:d + {: + if(d instanceof Declaration) { + Declaration[] list = (Declaration[])l; + Token doc = parser.comments.peek()[0]; + if(doc!=null) { + ((Declaration)d).setDocumentation(doc.toString()); + parser.comments.peek()[0]=null; + } + RESULT = ArrayUtils.add(list, (Declaration)d); + } else { + if(d instanceof Token) { + parser.comments.peek()[0] = (Token)d; + } + RESULT = l; + } + :} + | declaration_with_error:d {: + if(d instanceof Declaration) { + parser.comments.push(new Token[] { null }); + RESULT = new Declaration[] { (Declaration)d }; + } else { + parser.comments.push(new Token[] { (Token)d }); + RESULT = new Declaration[0]; + } + :} + ; + +declaration_with_error ::= declaration:d {: RESULT=d; :} | error; + +declaration ::= declaration_nodoc:d {: RESULT=d; :} + | DOC:d {: + RESULT=d; + :} +; + +declaration_nodoc ::= + type_macro:d {: RESULT=d; :} + | type_decl:d {: RESULT=d; :} + | enum_decl:d {: RESULT=d; :} + | module_decl:d {: RESULT=d; :} + | var_decl:d {: RESULT=d; :} + | func_decl:d {: RESULT=d; :} + | export_decl:d {: RESULT=d; :} + | import_decl:d {: RESULT=d; :} +; + +export_decl ::= EXPORT ASSIGN IDENTIFIER:exportedIdentifier lf_opt + {: + RESULT = new ReferenceDeclaration((Token)exportedIdentifier, null, exportedIdentifier.toString()); + :} + | EXPORT LCPAREN export_element_list RCPAREN lf_opt + ; + +export_element_list ::= export_element_list:l COMMA lf_opt export_element:t + | export_element:t +; + +export_element ::= IDENTIFIER | IDENTIFIER AS IDENTIFIER; + +export_opt ::= EXPORT |; + +import_decl ::= + export_opt IMPORT import_spec:s + {: + RESULT = s; + :} +; + +import_spec ::= + MULT AS IDENTIFIER:alias FROM qual_id:imported + {: + RESULT = new ReferenceDeclaration((Token)alias, alias.toString(), imported.toString()); + :} + | IDENTIFIER:alias ASSIGN qual_id:imported + {: + RESULT = new ReferenceDeclaration((Token)alias, alias.toString(), imported.toString()); + :} + | IDENTIFIER:alias ASSIGN IDENTIFIER:require LPAREN qual_id:imported RPAREN + {: + if(!"require".equals(require.toString())) { + parser.syntax_error((Token)require); + } else { + RESULT = new ReferenceDeclaration((Token)alias, alias.toString(), imported.toString()); + } + :} + +; + +type_macro ::= TYPE_MACRO IDENTIFIER:alias type_param_list_opt:tparams ASSIGN lf_opt type:type + {: + RESULT = new TypeMacroDeclaration((Token)alias, alias.toString(), (TypeParameterDeclaration[])tparams, (TypeReference)type); + :} + | + EXPORT TYPE_MACRO IDENTIFIER:alias type_param_list_opt:tparams ASSIGN type:type + {: + RESULT = new TypeMacroDeclaration((Token)alias, alias.toString(), (TypeParameterDeclaration[])tparams, (TypeReference)type); + :} +; + +type_decl ::= declare_opt abstract_opt type_kind:def IDENTIFIER:name type_param_list_opt:tparams extends_opt:t implements_opt:t2 lf_opt LCPAREN member_list_opt:members RCPAREN + {: + RESULT = new TypeDeclaration((Token)name,def.toString(),name.toString(),(TypeParameterDeclaration[])tparams,t==null?(TypeReference[])t2:ArrayUtils.addAll((TypeReference[])t,(TypeReference[])t2),(Declaration[])members); + :} | declare_opt DECLARE_CLASS IDENTIFIER:name type_param_list_opt:tparams extends_opt:t implements_opt:t2 lf_opt LCPAREN member_list_opt:members RCPAREN + {: + RESULT = new TypeDeclaration((Token)name,"class",name.toString(),(TypeParameterDeclaration[])tparams,t==null?(TypeReference[])t2:ArrayUtils.addAll((TypeReference[])t,(TypeReference[])t2),(Declaration[])members); + :} +; + +const_opt ::= CONST {: RESULT = true; :} | {: RESULT = false; :}; + +abstract_opt ::= ABSTRACT {: RESULT = "abstract"; :} | ; + +enum_decl ::= declare_opt DECLARE_ENUM IDENTIFIER:name type_param_list_opt:tparams lf_opt LCPAREN enum_member_list_opt:members RCPAREN + {: + RESULT = new TypeDeclaration((Token)name,"enum",name.toString(),(TypeParameterDeclaration[])tparams,null,(Declaration[])members); + :} + | declare_opt const_opt ENUM IDENTIFIER:name type_param_list_opt:tparams lf_opt LCPAREN enum_member_list_opt:members RCPAREN + {: + RESULT = new TypeDeclaration((Token)name,"enum",name.toString(),(TypeParameterDeclaration[])tparams,null,(Declaration[])members); + :} +; + +enum_member_list_opt ::= lf_opt enum_member_list:l lf_opt {: RESULT = l; :} + | lf_opt {: RESULT = new Declaration[0]; :}; + +enum_member_list ::= enum_member_list:l COMMA lf_opt enum_member_elt_with_error:e + {: + if(e!=null) { + Declaration[] list = (Declaration[])l; + RESULT = ArrayUtils.add(list, (Declaration)e); + } else { + RESULT=l; + } + :} + | enum_member_elt_with_error:e + {: + if(e!=null) { + RESULT=new Declaration[] { (Declaration)e }; + } else { + RESULT=new Declaration[0]; + } + :} + | enum_member_list:l COMMA lf_opt + {: + RESULT=l; + :} + | enum_member_list:l lf_opt doc_list lf_opt + {: + RESULT=l; + :} + | enum_member_list:l COMMA lf_opt doc_list lf_opt + {: + RESULT=l; + :} +; + +enum_member_elt_with_error ::= enum_member_elt:d {: RESULT=d; :} | error; + +enum_member_elt ::= doc_list:doc lf_opt enum_member_elt_nodoc:d + {: + if(d!=null) { + Declaration decl = (Declaration)d; + decl.setDocumentation(doc.toString()); + RESULT=d; + } + :} + | enum_member_elt_nodoc:d + {: + RESULT=d; + :} +; + +enum_member_elt_nodoc ::= IDENTIFIER:name {: + RESULT = new VariableDeclaration((Token)name, name.toString(), null, false, true); + :} + | IDENTIFIER:name ASSIGN literal:value {: + Literal literal = new Literal((Token)value, value.toString()); + VariableDeclaration var = new VariableDeclaration((Token)name, name.toString(), null, false, true); + var.setInitializer(literal); + RESULT = var; + :} +; + +literal ::= INT:i {: RESULT=i; :}; + +type_kind ::= INTERFACE:def {: RESULT=def; :} | CLASS:def {: RESULT=def; :}; + +extends_opt ::= EXTENDS type_list:t {: RESULT = t; :} | ; + +implements_opt ::= IMPLEMENTS lf_opt type_list:t {: RESULT = t; :} | ; + +type_list ::= type_list:l COMMA lf_opt type:t + {: + TypeReference[] list = (TypeReference[])l; + RESULT = ArrayUtils.add(list, (TypeReference)t); + :} +| type:t + {: + RESULT=new TypeReference[] { (TypeReference)t }; + :} +; + +member_list_opt ::= lf_opt member_list:l semi_or_comma_or_lf_opt {: + parser.comments.pop(); + RESULT = l; + :} + | lf_opt {: RESULT = new Declaration[0]; :}; + +lf ::= lf LF | LF; + +lf_opt ::= lf |; + +semi_or_lf ::= SEMI lf | SEMI | lf; + +semi_or_lf_opt ::= semi_or_lf |; + +semi_or_comma_or_lf ::= SEMI lf | SEMI | COMMA lf | COMMA | lf; + +semi_or_comma_or_lf_opt ::= semi_or_comma_or_lf |; + +member_list ::= member_list:l semi_or_comma_or_lf member_elt_with_error:d + {: + if(d instanceof Declaration) { + Declaration[] list = (Declaration[])l; + Token doc = parser.comments.peek()[0]; + if(doc!=null) { + ((Declaration)d).setDocumentation(doc.toString()); + parser.comments.peek()[0]=null; + } + RESULT = ArrayUtils.add(list, (Declaration)d); + } else { + if(d instanceof Token) { + parser.comments.peek()[0] = (Token)d; + } + RESULT=l; + } + :} + | member_elt_with_error:d + {: + if(d instanceof Declaration) { + parser.comments.push(new Token[] { null }); + RESULT = new Declaration[] { (Declaration)d }; + } else { + parser.comments.push(new Token[] { (Token)d }); + RESULT = new Declaration[0]; + } + :} +; + +member_elt_with_error ::= member_elt:d {: RESULT=d; :} | error; + +member_elt ::= member_elt_nodoc:d + {: + RESULT=d; + :} + | DOC:doc + {: + RESULT=doc; + :} +; + +doc_list ::= DOC:doc lf_opt doc_list {: RESULT=doc; :} | DOC:doc lf_opt {: RESULT=doc; :}; + +doc_list_opt ::= doc_list:l {: RESULT=l; :} |; + +doc_opt ::= DOC | ; + +member_elt_nodoc ::= + var_decl:d {: RESULT=d; :} + | func_decl:d {: RESULT=d; :} + | index_sig_decl:d {: RESULT=d; :} + | constructor_decl:d {: RESULT=d; :} +; + +module_decl ::= declare_opt IDENTIFIER:t qual_id:name lf_opt LCPAREN declaration_list_opt:declarations RCPAREN + {: + if(!(t.toString().equals("module")||t.toString().equals("namespace"))) { + parser.syntax_error((Token)t); + } + RESULT = ModuleDeclaration.createQualifiedModuleDeclaration((Token)t,name.toString(),(Declaration[])declarations); + :} + | DECLARE_MODULE:t qual_id:name lf_opt LCPAREN declaration_list_opt:declarations RCPAREN + {: + RESULT = ModuleDeclaration.createQualifiedModuleDeclaration((Token)t,name.toString(),(Declaration[])declarations); + :} +; + +var_or_const ::= VAR {: RESULT=false; :} | CONST {: RESULT = true; :}; + +var_decl ::= declare_opt:mod var_or_const:readonly IDENTIFIER:name optional_opt:opt lf_opt type_annotation_opt:t + {: + VariableDeclaration var = new VariableDeclaration((Token)name,name.toString(),(TypeReference)t, (Boolean)opt, (Boolean)readonly); + if(mod!=null) var.addModifier((String)mod); + var.setHidden(var.hasModifier("private")); + RESULT = var; + :} + | declare_opt:mod IDENTIFIER:name optional_opt:opt lf_opt type_annotation_opt:t + {: + VariableDeclaration var = new VariableDeclaration((Token)name,name.toString(),(TypeReference)t, (Boolean)opt, false); + if(mod!=null) var.addModifier((String)mod); + var.setHidden(var.hasModifier("private")); + RESULT = var; + :} + | declare_opt:mod INT:name optional_opt:opt lf_opt type_annotation_opt:t + {: + VariableDeclaration var = new VariableDeclaration((Token)name,name.toString(),(TypeReference)t, (Boolean)opt, false); + if(mod!=null) var.addModifier((String)mod); + var.setHidden(var.hasModifier("private")); + RESULT = var; + :} + // case of a variable called 'new' + | declare_opt:mod NEW:name optional_opt:opt lf_opt type_annotation_opt:t + {: + VariableDeclaration var = new VariableDeclaration((Token)name,name.toString(),(TypeReference)t, (Boolean)opt, false); + if(mod!=null) var.addModifier((String)mod); + var.setHidden(var.hasModifier("private")); + RESULT = var; + :} +// | DECLARE_VAR IDENTIFIER:name optional_opt:opt type_annotation_opt:t +// {: +// RESULT = new VariableDeclaration((Token)name,name.toString(),(TypeReference)t, (Boolean)opt); +// :} +; + +optional_opt ::= QUESTION {: RESULT=true; :} | {: RESULT=false; :}; + +func_decl ::= declare_opt:mod IDENTIFIER:name optional_opt:opt type_param_list_opt:tparams LPAREN param_list_opt:params RPAREN type_annotation_opt:t + {: + //System.err.println("1"); + FunctionDeclaration func = new FunctionDeclaration((Token)name,name.toString(),(TypeReference)t, (ParameterDeclaration[])params, (TypeParameterDeclaration[])tparams); + if(mod!=null) func.addModifier((String)mod); + func.setHidden(func.hasModifier("private")); + RESULT = func; + :} + | declare_opt:mod FUNCTION IDENTIFIER:name optional_opt:opt type_param_list_opt:tparams LPAREN param_list_opt:params RPAREN type_annotation_opt:t + {: + //System.err.println("2"); + FunctionDeclaration func = new FunctionDeclaration((Token)name,name.toString(),(TypeReference)t, (ParameterDeclaration[])params, (TypeParameterDeclaration[])tparams); + if(mod!=null) func.addModifier((String)mod); + func.setHidden(func.hasModifier("private")); + RESULT = func; + :} + | DECLARE_FUNCTION IDENTIFIER:name optional_opt:opt type_param_list_opt:tparams LPAREN param_list_opt:params RPAREN type_annotation_opt:t + {: + //System.err.println("3"); + RESULT = new FunctionDeclaration((Token)name,name.toString(),(TypeReference)t, (ParameterDeclaration[])params, (TypeParameterDeclaration[])tparams); + :} +; + +constructor_decl ::= declare_opt:mod type_param_list_opt:tparams LPAREN:token param_list_opt:params RPAREN type_annotation_opt:t + {: + //System.err.println("4"); + RESULT = new FunctionDeclaration((Token)token,FunctionDeclaration.ANONYMOUS_FUNCTION_RESERVED_NAME,(TypeReference)t, (ParameterDeclaration[])params, (TypeParameterDeclaration[])tparams); + :} + | declare_opt:mod NEW type_param_list_opt:tparams LPAREN:token param_list_opt:params RPAREN type_annotation_opt:t + {: + //System.err.println("5"); + RESULT = new FunctionDeclaration((Token)token,FunctionDeclaration.NEW_FUNCTION_RESERVED_NAME,(TypeReference)t, (ParameterDeclaration[])params, (TypeParameterDeclaration[])tparams); + :} +; + +index_sig_decl ::= declare_opt type_param_list_opt:tparams LSPAREN:token param:param RSPAREN type_annotation_opt:t + {: + RESULT = new FunctionDeclaration((Token)token,FunctionDeclaration.INDEXSIG_RESERVED_NAME,(TypeReference)t, new ParameterDeclaration[] {(ParameterDeclaration)param}, (TypeParameterDeclaration[])tparams); + :} | + declare_opt CONST:readonly type_param_list_opt:tparams LSPAREN:token param:param RSPAREN type_annotation_opt:t + {: + RESULT = new FunctionDeclaration((Token)token,FunctionDeclaration.INDEXSIG_RESERVED_NAME,(TypeReference)t, new ParameterDeclaration[] {(ParameterDeclaration)param}, (TypeParameterDeclaration[])tparams); + :} +; + +param_list_opt ::= lf_opt param_list:l lf_opt {: RESULT = l; :} + | lf_opt {: RESULT = new ParameterDeclaration[0]; :} +; + +param_list ::= param_list:l lf_opt COMMA lf_opt param:p + {: + ParameterDeclaration[] list = (ParameterDeclaration[])l; + RESULT = ArrayUtils.add(list, (ParameterDeclaration)p); + :} + | param:p + {: + RESULT=new ParameterDeclaration[] { (ParameterDeclaration)p }; + :} +; + +param ::= doc_opt lf_opt varargs_opt:varargs IDENTIFIER:i optional_opt:opt type_annotation_opt:t doc_opt lf_opt + {: + RESULT = new ParameterDeclaration( (Token)i, i.toString(), (TypeReference)t, (Boolean)opt, varargs!=null); + :} +; + +varargs_opt ::= DOTDOTDOT:varargs {: RESULT=varargs; :} | ; + +type_annotation_opt ::= type_annotation:t {: RESULT=t; :} | +; + +type_annotation ::= COL lf_opt doc_opt lf_opt type:t {: RESULT=t; :} +; + +type ::= + functional_type:t {: RESULT=t; :} + | typeof_type:t {: RESULT=t; :} + | is_type:t {: RESULT=t; :} + | union_type:t {: RESULT=t; :} + | intersection_type:t {: RESULT=t; :} + | object_type:t {: RESULT=t; :} + | array_type:t {: RESULT=t; :} + | simple_type:t {: RESULT=t; :} + | tuple_type:t {: RESULT=t; :} +; + +union_type ::= type:t1 TUBE:t lf_opt type:t2 {: RESULT=new UnionTypeReference((Token)t, (TypeReference)t1, (TypeReference)t2); :} + | LPAREN union_type:t RPAREN {: RESULT=t; :} +; + +intersection_type ::= type:t1 AND:t lf_opt type:t2 {: RESULT=new UnionTypeReference((Token)t, (TypeReference)t1, (TypeReference)t2, true); :} + | LPAREN intersection_type:t RPAREN {: RESULT=t; :} +; + +simple_type ::= qual_id:q type_arg_list_opt:tparams {: RESULT=new TypeReference(null, (String)q, (TypeReference[])tparams); :}; + +tuple_type ::= + LSPAREN type_list:types RSPAREN {: RESULT=new TypeReference(null, "$tuple$", (TypeReference[])types); :} +; + +array_type ::= + simple_type:t SQUARE {: RESULT=new ArrayTypeReference( null, (TypeReference)t); :} + | object_type:t SQUARE {: RESULT=new ArrayTypeReference( null, (TypeReference)t); :} + | tuple_type:t SQUARE {: RESULT=new ArrayTypeReference( null, (TypeReference)t); :} + | LPAREN functional_type:t RPAREN SQUARE {: RESULT=new ArrayTypeReference(null, (TypeReference)t); :} + | array_type:t SQUARE {: RESULT=new ArrayTypeReference(null, (TypeReference)t); :} + | LPAREN union_type:t RPAREN SQUARE {: RESULT=new ArrayTypeReference(null, (TypeReference)t); :} +; + +functional_type ::= + type_param_list_opt:tparams LPAREN_FUNC:token param_list_opt:params RPAREN_FUNC IMPLIES type:t {: + RESULT=new FunctionalTypeReference((Token)token, (TypeReference)t, (ParameterDeclaration[])params, (TypeParameterDeclaration[])tparams); + :} + | NEW:i type_param_list_opt:tparams LPAREN_FUNC param_list_opt:params RPAREN_FUNC IMPLIES type:t {: + RESULT=new FunctionalTypeReference((Token)i, true, (TypeReference)t, (ParameterDeclaration[])params, (TypeParameterDeclaration[])tparams); + :} + | LPAREN functional_type:t RPAREN {: RESULT=t; :} +; + +object_type ::= LCPAREN:token member_list_opt:members RCPAREN {: RESULT=new TypeReference((Token)token, (Declaration[])members); :} + | LPAREN object_type:t RPAREN {: RESULT=t; :} +; + +typeof_type ::= TYPEOF qual_id:name {: TypeReference t = new TypeReference(null, (String)name, null); t.setTypeOf(true); RESULT=t; :} + | LPAREN TYPEOF qual_id:name RPAREN {: TypeReference t = new TypeReference(null, (String)name, null); t.setTypeOf(true); RESULT=t; :} +; + +is_type ::= IDENTIFIER IS type {: RESULT=new TypeReference(null, "boolean", null); :} + | LPAREN IDENTIFIER IS type RPAREN {: RESULT=new TypeReference(null, "boolean", null); :} +; + +declare_opt ::= EXPORT | DECLARE | STATIC {: RESULT = "static"; :} | PRIVATE {: RESULT = "private"; :} | PROTECTED {: RESULT = "protected"; :} | PRIVATE STATIC {: RESULT = "private static"; :} | PROTECTED STATIC {: RESULT = "protected static"; :} | PUBLIC {: RESULT = "public"; :} | PUBLIC STATIC {: RESULT = "public static"; :} | ; +//declare_opt ::= DECLARE | EXPORT | ; +//declare_opt ::= IDENTIFIER:i {: if(!i.toString().equals("declare") || !i.toString().equals("declare")) { throw new RuntimeException("declare or export expected: "); } RESULT=i; :} | ; + +qual_id ::= IDENTIFIER:i {: RESULT=i.toString(); :} + | IDENTIFIER:i DOT qual_id:q {: RESULT=i.toString()+"."+q.toString(); :} +; + +type_arg_list_opt ::= LT type_arg_list:tparams GT {: RESULT = tparams; :} | ; + +type_arg_list ::= type_arg_list:l COMMA type:p + {: + TypeReference[] list = (TypeReference[])l; + RESULT = ArrayUtils.add(list, (TypeReference)p); + :} + | type:p + {: + RESULT=new TypeReference[] { (TypeReference)p }; + :} +; + +type_param_list_opt ::= LT type_param_list:tparams GT {: RESULT = tparams; :} | ; + +type_param_list ::= type_param_list:l COMMA type_param:p + {: + TypeParameterDeclaration[] list = (TypeParameterDeclaration[])l; + RESULT = ArrayUtils.add(list, (TypeParameterDeclaration)p); + :} + | type_param:p + {: + RESULT=new TypeParameterDeclaration[] { (TypeParameterDeclaration)p }; + :} +; + +type_param ::= type:t + {: + RESULT=new TypeParameterDeclaration(((TypeReference)t).getToken(), ((TypeReference)t).getName()); + :} + | type:t EXTENDS type:s + {: + RESULT=new TypeParameterDeclaration(((TypeReference)t).getToken(), ((TypeReference)t).getName()); + ((TypeParameterDeclaration)RESULT).setUpperBound((TypeReference)s); + :} +; diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/typescriptdef.lex b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/typescriptdef.lex new file mode 100644 index 00000000..188cd3a8 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/parser/typescriptdef.lex @@ -0,0 +1,225 @@ + +/* + * This source code file is the exclusive property of its author. No copy or + * usage of the source code is permitted unless the author contractually + * allows it under the terms of a well-defined agreement. + */ + +package org.jsweet.input.typescriptdef.parser; + +import java_cup.runtime.*; +import org.jsweet.input.typescriptdef.ast.Token; +import java.util.*; + +%% + +%class TypescriptDefScanner +%unicode +%cup +%line +%column +%state STRING +%state CHAR +%state TYPE_MACRO +%state EOL_COMMENT + +%{ + StringBuffer string=new StringBuffer(); + String fileName; + public void setFileName(String name) { + fileName=name; + } + public String getFileName() { + return fileName; + } + private Symbol symbol(int type) { + return new Symbol(type,yyline,yycolumn, + new Token(type,fileName,yytext(), + yyline+1,yycolumn+1, + yycolumn+1+yytext().length())); + } + private Symbol symbol(int type, String value) { + return new Symbol(type,yyline,yycolumn, + new Token(type,fileName,value, + yyline+1,yycolumn+1, + yycolumn+1+yytext().length())); + } + private Stack openParens = new Stack(); +%} + +LineTerminator= \r|\n|\r\n +InputCharacter = [^\r\n] +WhiteSpace = {LineTerminator} | [ \t\f] +WhiteSpaceChar = [ \t\f] +Comment = {TraditionalComment} | {EndOfLineComment} + +StringText=(\\\"|[^\n\"]|\\{WhiteSpaceChar}*\\)* + +TraditionalComment = "/*" ~"*/" +// Comment can be the last line of the file, without line terminator. +//MetaComment = "///" {WhiteSpaceChar}* "<" {InputCharacter}* {LineTerminator}? +EndOfLineComment = "//" {InputCharacter}* {LineTerminator} +DocumentationComment = "/**" {CommentContent} [^*] "*/" +CommentContent = ( [^*] | \*+ [^/*] )* +O = [^()]* +FunctionalTypeEnding = {O} ({O} "(" {O} ({O} "(" {O} ({O} "(" {O} ")" {O})* {O} ")" {O})* {O} ")" {O})* {O} ")" {WhiteSpaceChar}* "=>" + +Identifier = [A-Za-z0-9_$]* + +DecIntegerLiteral = [0-9] | [1-9][0-9]* +HexDigit = [0-9A-Fa-f] +Sign = ("+"|"-") +DecFloatLiteral = {DecIntegerLiteral}\.{DecIntegerLiteral} + +KeywordEnding = {WhiteSpaceChar}+ [\'\"A-Za-z0-9_$/] +SpecialKeywordEnding = {WhiteSpaceChar}+ [\'\"\[A-Za-z0-9_$/] +//KeywordEnding = {WhiteSpaceChar}?[ ]?[^:(;] + +%% + + { + /* keywords */ + "interface" / {KeywordEnding} { return symbol(sym.INTERFACE); } + "class" / {KeywordEnding} { return symbol(sym.CLASS); } + //"declare" {WhiteSpace}* "var" { return symbol(sym.DECLARE_VAR); } + //"declare" {WhiteSpace}* "let" { return symbol(sym.DECLARE_VAR); } + //"declare" {WhiteSpace}* "const" { return symbol(sym.DECLARE_VAR); } + "declare" {WhiteSpace}* "module" { return symbol(sym.DECLARE_MODULE); } + "declare" {WhiteSpace}* "namespace" { return symbol(sym.DECLARE_MODULE); } + "declare" {WhiteSpace}* "function" { return symbol(sym.DECLARE_FUNCTION); } + "declare" {WhiteSpace}* "class" { return symbol(sym.DECLARE_CLASS); } + "declare" {WhiteSpace}* "enum" { return symbol(sym.DECLARE_ENUM); } + {LineTerminator} {WhiteSpaceChar}* "type" / {KeywordEnding} { yypushback(yylength()); yybegin(TYPE_MACRO); } + {LineTerminator} {WhiteSpaceChar}* "export" {WhiteSpace}* "type" / {KeywordEnding} { yypushback(yylength()); yybegin(TYPE_MACRO); } + {LineTerminator} {WhiteSpaceChar}* "declare" {WhiteSpace}* "type" / {KeywordEnding} { yypushback(yylength()); yybegin(TYPE_MACRO); } +// {MetaComment} { return symbol(sym.REFERENCE); } + // most keyword can be used as identifiers, so we differentiate them with special ending + "declare" / {KeywordEnding} { return symbol(sym.DECLARE); } + "var" / {KeywordEnding} { return symbol(sym.VAR); } + "let" / {KeywordEnding} { return symbol(sym.VAR); } + //"const" / {KeywordEnding} { return symbol(sym.VAR); } + "static" / {KeywordEnding} { return symbol(sym.STATIC); } + "abstract" / {KeywordEnding} { return symbol(sym.ABSTRACT); } + "extends" / {KeywordEnding} { return symbol(sym.EXTENDS); } + "extends" / {WhiteSpaceChar}* "{" { return symbol(sym.EXTENDS); } + "extends" / {WhiteSpaceChar}* "(" {FunctionalTypeEnding} { return symbol(sym.EXTENDS); } + "implements" / {KeywordEnding} { return symbol(sym.IMPLEMENTS); } + "import" / {KeywordEnding} { return symbol(sym.IMPORT); } + "import" / {WhiteSpaceChar}* "*" { return symbol(sym.IMPORT); } + "export" / {KeywordEnding} { return symbol(sym.EXPORT); } + "export" / {WhiteSpace}* "=" { return symbol(sym.EXPORT); } + "export" / {WhiteSpace}* "{" { return symbol(sym.EXPORT); } + "private" / {KeywordEnding} { return symbol(sym.PRIVATE); } + "protected" / {KeywordEnding} { return symbol(sym.PROTECTED); } + "public" / {KeywordEnding} { return symbol(sym.PUBLIC); } + "function" / {KeywordEnding} { return symbol(sym.FUNCTION); } + "typeof" / {KeywordEnding} { return symbol(sym.TYPEOF); } + "enum" / {KeywordEnding} { return symbol(sym.ENUM); } + "const" / {KeywordEnding} { return symbol(sym.CONST); } + "readonly" / {SpecialKeywordEnding} { return symbol(sym.CONST); } + "is" / {KeywordEnding} { return symbol(sym.IS); } + "as" / {KeywordEnding} { return symbol(sym.AS); } + "from" / {KeywordEnding} { return symbol(sym.FROM); } + "new" { return symbol(sym.NEW); } + + {Sign}? {DecIntegerLiteral} { return symbol(sym.INT); } + [0][xX]{HexDigit}+ { return symbol(sym.INT); } +// {DecFloatLiteral} { return symbol(sym.NUM); } + {Identifier} { return symbol(sym.IDENTIFIER); } + ":" { return symbol(sym.COL); } + // hack to allow lf before : (would lead to hard disambiguation problem in the parser) + {LineTerminator} {WhiteSpaceChar}* ":" { return symbol(sym.COL); } + ";" { return symbol(sym.SEMI); } + "(" / {FunctionalTypeEnding} { return symbol(sym.LPAREN_FUNC); } + ")" / {WhiteSpaceChar}* "=>" { return symbol(sym.RPAREN_FUNC); } + "(" { return symbol(sym.LPAREN); } + ")" { return symbol(sym.RPAREN); } + "{" { return symbol(sym.LCPAREN); } + "}" { return symbol(sym.RCPAREN); } + "[" {WhiteSpaceChar}* "]" { return symbol(sym.SQUARE); } + "[" { return symbol(sym.LSPAREN); } + "]" { return symbol(sym.RSPAREN); } + "<" { return symbol(sym.LT); } + ">" { return symbol(sym.GT); } + "<=" { return symbol(sym.LTE); } + ">=" { return symbol(sym.GTE); } + "," { return symbol(sym.COMMA); } + "." { return symbol(sym.DOT); } + "=" { return symbol(sym.ASSIGN); } + "==" { return symbol(sym.EQUALS); } + "!=" { return symbol(sym.NOTEQUALS); } + "~" { return symbol(sym.MATCHES); } + "||" { return symbol(sym.OROR); } + "?" { return symbol(sym.QUESTION); } + "&" { return symbol(sym.AND); } + "&&" { return symbol(sym.ANDAND); } + "=>" { return symbol(sym.IMPLIES); } + "!" { return symbol(sym.NOT); } + "+" { return symbol(sym.PLUS); } + "++" { return symbol(sym.PLUSPLUS); } + "-" { return symbol(sym.MINUS); } + "--" { return symbol(sym.MINUSMINUS); } + "/" { return symbol(sym.DIV); } + "*" { return symbol(sym.MULT); } + // hack to allow lf after | (would lead to hard disambiguation problem in the parser) + "|" {WhiteSpaceChar}* {LineTerminator} { return symbol(sym.TUBE); } + "|" { return symbol(sym.TUBE); } + // hack to allow lf before | (would lead to hard disambiguation problem in the parser) + {LineTerminator} {WhiteSpaceChar}* "|" {WhiteSpaceChar}* {LineTerminator}? { return symbol(sym.TUBE); } + "..." { return symbol(sym.DOTDOTDOT); } + ".." { return symbol(sym.DOTDOT); } + "@" { return symbol(sym.AT); } + "'" { string.setLength(0); yybegin(CHAR); } + \" { string.setLength(0); yybegin(STRING); } + {DocumentationComment} { return symbol(sym.DOC); } + {TraditionalComment} { /*System.err.println("COMMENT: "+yytext());*/ /* ignore */ } + "//" { yybegin(EOL_COMMENT); } + {LineTerminator} { /*System.err.println("LF");*/ return symbol(sym.LF); } + {WhiteSpaceChar} { /* ignore */ } + //{WhiteSpace} { /* ignore */ } + [] { /* ignore */ } +} + + { + \" { yybegin(YYINITIAL); + return symbol(sym.IDENTIFIER, + "\""+string.toString()+"\""); } + [^\n\r\"\\]+ { string.append( yytext() ); } + \\t { string.append('\t'); } + \\n { string.append('\n'); } + + \\r { string.append('\r'); } + \\\" { string.append('\"'); } + \\\\ { string.append('\\'); } + \\ { string.append('\\'); } +} + + { + \' { yybegin(YYINITIAL); + return symbol(sym.IDENTIFIER, + "\""+string.toString()+"\""); } + [^\n\r\'\\]+ { string.append( yytext() ); } + \\t { string.append('\t'); } + \\n { string.append('\n'); } + + \\r { string.append('\r'); } + \\\' { string.append('\''); } + \\\\ { string.append('\\'); } + \\ { string.append('\\'); } +} + + { + {LineTerminator} ({WhiteSpace}* | {Comment})* { return symbol(sym.LF); } + "type" { yybegin(YYINITIAL); return symbol(sym.TYPE_MACRO); } + "export" { /* ignore */ } + "declare" { /* ignore */ } + {WhiteSpaceChar}* { /* ignore */ } +} + + { + {LineTerminator} { yybegin(YYINITIAL); yypushback(yylength()); } + <> { yybegin(YYINITIAL); } + [^] { /* ignore */ } +} + +.|\n { System.out.println("unmatched:"+yytext()); } diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/CopyrightHelper.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/CopyrightHelper.java new file mode 100644 index 00000000..61f41c7d --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/CopyrightHelper.java @@ -0,0 +1,57 @@ +package org.jsweet.input.typescriptdef.util; + +import java.io.File; + +import org.apache.commons.io.FileUtils; + +public class CopyrightHelper { + + public static void main(String[] args) { + if (args.length < 2) { + System.err.println("usage: CopyrightHelper "); + System.exit(1); + } + File processedDir; + processedDir = new File(args[1]); + File copyrightFile = new File(args[0]); + if (!copyrightFile.exists()) { + System.err.println(copyrightFile + " does not exist"); + System.err.println("current directory: "+ new File("").getAbsolutePath()); + System.exit(1); + } + try { + String copyrightText = FileUtils.readFileToString(copyrightFile); + insertCopyright(processedDir, copyrightText); + } catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } + System.exit(0); + } + + private static void insertCopyright(File file, String licenceText) throws Exception { + for (File f : file.listFiles()) { + if (f.isDirectory()) { + insertCopyright(f, licenceText); + } else { + if (f.getName().endsWith(".java")) { + System.out.println("inserting copyright in " + f); + String text = FileUtils.readFileToString(f); + int insertIndex = text.indexOf("package"); + int otherIndex = text.indexOf("/**"); + if (otherIndex != -1) { + insertIndex = Math.min(insertIndex, otherIndex); + } + otherIndex = text.indexOf("@"); + if (otherIndex != -1) { + insertIndex = Math.min(insertIndex, otherIndex); + } + text = text.substring(insertIndex); + FileUtils.write(f, licenceText + "\n"); + FileUtils.write(f, text, true); + } + } + } + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/DeclarationFinder.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/DeclarationFinder.java new file mode 100644 index 00000000..5f63f60e --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/DeclarationFinder.java @@ -0,0 +1,71 @@ +package org.jsweet.input.typescriptdef.util; + +import java.util.ArrayList; +import java.util.List; + +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Declaration; +import org.jsweet.input.typescriptdef.ast.QualifiedDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.Visitable; + +public class DeclarationFinder extends Scanner { + + public interface Matcher { + void matches(DeclarationFinder finder, Visitable visitable); + } + + protected List> matches = new ArrayList<>(); + private Matcher matcher; + private boolean match = false; + private boolean stopScan = false; + + public DeclarationFinder(Context context, Matcher matcher) { + super(context); + this.matcher = matcher; + } + + public DeclarationFinder(Scanner parentScanner, Matcher matcher) { + super(parentScanner); + this.matcher = matcher; + } + + @Override + public void scan(Visitable visitable) { + if (visitable != null && !visitable.isHidden()) { + enter(visitable); + try { + matcher.matches(this, visitable); + if (match) { + @SuppressWarnings("unchecked") + T match = (T) visitable; + matches.add(new QualifiedDeclaration(match, getCurrentDeclarationName())); + } + if (!stopScan) { + visitable.accept(this); + } + } finally { + exit(); + } + } + } + + public List> getMatches() { + return matches; + } + + /** + * To be called by a matcher to set the current match state of this finder. + * + * @param match + * tells is the matcher matches the current node + * @param continueScanning + * tells if the matcher want to continue scanning or stop at the + * current node + */ + public void setMatchState(boolean match, boolean continueScanning) { + this.match = match; + this.stopScan = !continueScanning; + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/DirectedGraph.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/DirectedGraph.java new file mode 100644 index 00000000..42aadc87 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/DirectedGraph.java @@ -0,0 +1,503 @@ +package org.jsweet.input.typescriptdef.util; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.function.Consumer; + +/** + * This class defines a directed graph collection type, that is to say a set of + * elements (aka nodes) linked together with directed edges. It is particularly + * useful for the topological sort, which is implemented as depicted in + * Wikipedia and this StackOverflow thread + * + *

+ * Example of use: + * + *

+ * Graph<Integer> g = new Graph<Integer>();
+ * g.add(7, 5, 3, 11, 8, 2, 9, 10);
+ * g.buildEdges(new Comparator<Integer>() {
+ * 	@Override
+ * 	public int compare(Integer o1, Integer o2) {
+ * 		if (o1 == 5 && o2 == 3) {
+ * 			return 1;
+ * 		}
+ * 		return 0;
+ * 	}
+ * });
+ * System.out.println(g.topologicalSort());
+ * 
+ * + *

+ * Prints out: [11, 10, 8, 7, 2, 3, 5, 9] (5 is always after 3, + * because of the edge built by the comparator, however, the remainder is in + * random order). + * + * @author Renaud Pawlak + * + * @param + * the types of the nodes in the graph + */ +public class DirectedGraph implements Collection { + + private Map> nodes = new HashMap>(); + + /** + * Constructs an empty graph collection. + */ + public DirectedGraph() { + } + + /** + * Adds a set of elements to the nodes of this graph. + */ + @Override + public boolean addAll(Collection elements) { + for (T element : elements) { + add(element); + } + return true; + } + + /** + * Adds an element to the nodes. + */ + @Override + public boolean add(T element) { + // logger.info("adding node: " + element); + Node node = new Node(this, element); + nodes.put(element, node); + return true; + } + + /** + * Clears all the nodes of this graph. + */ + @Override + public void clear() { + nodes.clear(); + } + + /** + * Tells if this graph contains the given object as a node. + */ + @Override + public boolean contains(Object o) { + return nodes.containsKey(o); + } + + /** + * Tells if this graph contains the given collection as a node. + */ + @Override + public boolean containsAll(Collection c) { + for (Object o : c) { + if (!contains(o)) { + return false; + } + } + return true; + } + + /** + * Equals two graphs. + */ + @Override + public boolean equals(Object obj) { + if (!(obj instanceof DirectedGraph)) { + return false; + } else { + return nodes.equals(((DirectedGraph) obj).nodes); + } + } + + @Override + public int hashCode() { + return nodes.hashCode(); + } + + /** + * Returns true if this graph has no nodes. + */ + @Override + public boolean isEmpty() { + return nodes.isEmpty(); + } + + /** + * Return an iterator to iterate on graph nodes. + */ + @Override + public Iterator iterator() { + return nodes.keySet().iterator(); + } + + /** + * Removes an object from the graph nodes (if exists). + */ + @Override + public boolean remove(Object o) { + return nodes.remove(o) != null; + } + + /** + * Removes all the objects from the graph nodes (if exists). + */ + @Override + public boolean removeAll(Collection c) { + for (Object o : c) { + remove(o); + } + return true; + } + + /** + * Keeps only the elements of the given collection in the graph. + */ + @Override + public boolean retainAll(Collection c) { + boolean b = false; + for (T element : nodes.keySet()) { + if (!c.contains(element)) { + remove(element); + b = true; + } + } + return b; + } + + /** + * Returns the nodes count in this graph. + */ + @Override + public int size() { + return nodes.size(); + } + + /** + * Returns the graph's nodes as an array (not sorted). + */ + @Override + public Object[] toArray() { + return nodes.keySet().toArray(); + } + + /** + * Returns the graph's nodes as a well-typed array (not sorted). + */ + @Override + public U[] toArray(U[] a) { + return toArray(a); + } + + /** + * Add a set of elements to the nodes of this graph. + */ + @SuppressWarnings("unchecked") + public void add(T... elements) { + for (T element : elements) { + add(element); + } + } + + /** + * Add an edge between the given elements (nodes). + * + * @param sourceElement + * the source element/node + * @param destinationElement + * the destination element/node + */ + public void addEdge(T sourceElement, T destinationElement) { + if (sourceElement.equals(destinationElement)) { + // logger.info("cannot define edge on self: " + sourceElement + + // " == " + // + destinationElement); + return; + } + if (hasEdge(sourceElement, destinationElement)) { + // logger.info("edge already defined: " + sourceElement + " -> " + // + destinationElement); + return; + } + + // logger.info("adding edge: " + sourceElement + " -> " + // + destinationElement); + nodes.get(sourceElement).addEdge(destinationElement); + // logger.info("edges: " + nodes.get(sourceElement).outEdges); + } + + /** + * Automatically builds the edges between all the nodes of the graph by + * using the given comparator. If the comparator returns 0, then no edge is + * constructor between the compared nodes. + * + * @param nodeComparator + * a comparator which is used to build the edges + */ + public void buildEdges(Comparator nodeComparator) { + for (T e1 : nodes.keySet()) { + for (T e2 : nodes.keySet()) { + @SuppressWarnings("unchecked") + int i = nodeComparator.compare((U) e1, (U) e2); + if (i < 0) { + addEdge(e1, e2); + } + if (i > 0) { + addEdge(e2, e1); + } + } + } + } + + /** + * Adds some edges form the source elements to the given destination + * elements. + * + * @param sourceElement + * the source of the edges + * @param destinationElements + * the destination elements of the edges + */ + @SuppressWarnings("unchecked") + public void addEdges(T sourceElement, T... destinationElements) { + nodes.get(sourceElement).addEdges(destinationElements); + } + + /** + * Tells if this graph contains an edge between the given source and the + * destination elements/nodes. + * + * @param sourceElement + * the source node + * @param destinationElement + * the destination node + * @return true if an edge is found, false otherwise + */ + public boolean hasEdge(T sourceElement, T destinationElement) { + if (nodes.get(sourceElement) == null) { + return false; + } + + for (Edge edge : nodes.get(sourceElement).outEdges) { + if (edge.to.element == destinationElement) { + return true; + } + } + return false; + } + + public List getDestinationElements(T sourceElement) { + List l = new ArrayList(); + if (nodes.get(sourceElement) == null) { + return null; + } + for (Edge edge : nodes.get(sourceElement).outEdges) { + l.add(edge.to.element); + } + return l; + } + + public List getSourceElements(T destinationElement) { + if (nodes.get(destinationElement) == null) { + return null; + } + + List l = new ArrayList(); + for (Edge edge : nodes.get(destinationElement).inEdges) { + l.add(edge.from.element); + } + return l; + } + + @Override + public String toString() { + StringBuffer s = new StringBuffer(); + s.append("["); + for (T element : nodes.keySet()) { + s.append(element.toString()); + s.append("->"); + s.append(getDestinationElements(element)); + s.append(","); + } + if (!nodes.isEmpty()) { + s.deleteCharAt(s.length() - 1); + } + s.append("]"); + return s.toString(); + } + + public static class Node { + private DirectedGraph graph; + public final T element; + public final HashSet> inEdges; + public final HashSet> usedInEdges; + public final HashSet> outEdges; + public final HashSet> usedOutEdges; + + public Node(DirectedGraph graph, T element) { + this.graph = graph; + this.element = element; + inEdges = new HashSet>(); + usedInEdges = new HashSet>(); + outEdges = new HashSet>(); + usedOutEdges = new HashSet>(); + } + + public void addEdge(T destinationElement) { + Node node = graph.nodes.get(destinationElement); + if (node == null) { + graph.add(destinationElement); + node = graph.nodes.get(destinationElement); + } + Edge e = new Edge(this, node); + outEdges.add(e); + node.inEdges.add(e); + } + + @SuppressWarnings("unchecked") + public void addEdges(T... destinationElements) { + for (T destinationElement : destinationElements) { + addEdge(destinationElement); + } + } + + public void useInEdge(Edge edge) { + if (inEdges.remove(edge)) { + usedInEdges.add(edge); + } + } + + public void useOutEdge(Edge edge) { + if (outEdges.remove(edge)) { + usedOutEdges.add(edge); + } + } + + public void resetEdges() { + inEdges.addAll(usedInEdges); + usedInEdges.clear(); + outEdges.addAll(usedOutEdges); + usedOutEdges.clear(); + } + + @Override + public String toString() { + return "Node[" + element + "]"; + } + } + + public static class Edge { + public final Node from; + public final Node to; + + public Edge(Node from, Node to) { + this.from = from; + this.to = to; + } + + @Override + public String toString() { + return "Edge[" + from + "->" + to + "]"; + } + + @Override + public boolean equals(Object obj) { + @SuppressWarnings("unchecked") + Edge e = (Edge) obj; + return e.from == from && e.to == to; + } + } + + private List toElements(List> nodes) { + List elements = new ArrayList(); + for (Node node : nodes) { + elements.add(node.element); + } + return elements; + } + + /** + * Sorts this graph using a topological sort algorithm given in this StackOverflow thread. + * + * @return the list of nodes, sorted according to the topological sort + * @throws CycleFoundException + * thrown if a cycle is found in the graph (in that case no + * topological sort is possible) + */ + public List topologicalSort(Consumer> cycleHandler) { + List> allNodes = new ArrayList>(nodes.values()); + // L <- Empty list that will contain the sorted elements + ArrayList> L = new ArrayList>(); + + // S <- Set of all nodes with no incoming edges + HashSet> S = new HashSet>(); + for (Node n : allNodes) { + if (n.inEdges.size() == 0) { + S.add(n); + } + } + + // while S is non-empty do + while (!S.isEmpty()) { + // remove a node n from S + Node n = S.iterator().next(); + S.remove(n); + + // insert n into L + L.add(n); + + // for each node m with an edge e from n to m do + for (Iterator> it = new ArrayList<>(n.outEdges).iterator(); it.hasNext();) { + // remove edge e from the graph + Edge e = it.next(); + Node m = e.to; + n.useOutEdge(e); // Remove edge from n + m.useInEdge(e); // Remove edge from m + + // if m has no other incoming edges then insert m into S + if (m.inEdges.isEmpty()) { + S.add(m); + } + } + } + // Check to see if all edges are removed + for (Node n : allNodes) { + if (!n.inEdges.isEmpty()) { + if (cycleHandler != null) { + cycleHandler.accept(n); + } + } + } + for (Node n : allNodes) { + n.resetEdges(); + } + return toElements(L); + } + + public static void main(String[] args) { + DirectedGraph g = new DirectedGraph(); + g.add(7, 5, 3, 11, 8, 2, 9, 10); + g.buildEdges(new Comparator() { + @Override + public int compare(Integer o1, Integer o2) { + if (o1 == 5 && o2 == 3) { + return 1; + } + return 0; + } + }); + System.out.println(g.topologicalSort(null)); + } +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/NameUtils.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/NameUtils.java new file mode 100644 index 00000000..dfcf9a37 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/NameUtils.java @@ -0,0 +1,26 @@ +package org.jsweet.input.typescriptdef.util; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.apache.commons.lang3.StringUtils; + +public class NameUtils { + + public static String getDiff(String referenceFullSignature, String targetFullSignature) { + List referenceSegments = new ArrayList( + Arrays.asList(referenceFullSignature.replace("[]", "s").split("[<>,\\(\\)]"))); + String[] targetSegments = targetFullSignature.replace("[]", "s").split("[<>,\\(\\)]"); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < targetSegments.length; i++) { + if (!referenceSegments.contains(targetSegments[i])) { + sb.append(StringUtils.capitalize(targetSegments[i])); + } else { + referenceSegments.remove(targetSegments[i]); + } + } + return sb.toString(); + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/NodeFinder.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/NodeFinder.java new file mode 100644 index 00000000..19f6ad94 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/NodeFinder.java @@ -0,0 +1,69 @@ +package org.jsweet.input.typescriptdef.util; + +import java.util.ArrayList; +import java.util.List; + +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.Visitable; + +public class NodeFinder extends Scanner { + + public interface Matcher { + void matches(NodeFinder finder, Visitable visitable); + } + + protected List matches = new ArrayList<>(); + private Matcher matcher; + private boolean match = false; + private boolean stopScan = false; + + public NodeFinder(Context context, Matcher matcher) { + super(context); + this.matcher = matcher; + } + + public NodeFinder(Scanner parentScanner, Matcher matcher) { + super(parentScanner); + this.matcher = matcher; + } + + @Override + public void scan(Visitable visitable) { + if (visitable != null && !visitable.isHidden()) { + enter(visitable); + try { + matcher.matches(this, visitable); + if (match) { + @SuppressWarnings("unchecked") + T match = (T) visitable; + matches.add(match); + } + if (!stopScan) { + visitable.accept(this); + } + } finally { + exit(); + } + } + } + + public List getMatches() { + return matches; + } + + /** + * To be called by a matcher to set the current match state of this finder. + * + * @param match + * tells is the matcher matches the current node + * @param continueScanning + * tells if the matcher want to continue scanning or stop at the + * current node + */ + public void setMatchState(boolean match, boolean continueScanning) { + this.match = match; + this.stopScan = !continueScanning; + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/ProcessUtil.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/ProcessUtil.java new file mode 100644 index 00000000..e7bd8bbc --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/ProcessUtil.java @@ -0,0 +1,82 @@ +package org.jsweet.input.typescriptdef.util; + +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStreamReader; +import java.util.function.Consumer; +import java.util.logging.Logger; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; + +public class ProcessUtil { + private final static Logger logger = Logger.getLogger("process"); + + public static String TSD_COMMAND = "tsd"; + public static String MVN_COMMAND = "mvn"; + public static String BOWER_COMMAND = "bower"; + public static String EXTRA_PATH; + + public static void init() { + // hack for Eclipse under Mac OSX + if (!System.getenv("PATH").contains("/usr/local/bin") && new File("/usr/local/bin/tsd").exists()) { + ProcessUtil.EXTRA_PATH = "/usr/local/bin"; + ProcessUtil.TSD_COMMAND = "/usr/local/bin/tsd"; + ProcessUtil.MVN_COMMAND = "/usr/local/bin/mvn"; + ProcessUtil.BOWER_COMMAND = "/usr/local/bin/bower"; + } + } + + public static void runCmd(Consumer stdoutConsumer, String... cmd) { + runCmd(null, stdoutConsumer, cmd); + } + + public static void runCmd(File directory, Consumer stdoutConsumer, String... cmd) { + System.out.println("run command: " + StringUtils.join(cmd, " ")); + + String[] args; + if (System.getProperty("os.name").startsWith("Windows")) { + args = new String[] { "cmd", "/c" }; + } else { + args = new String[0]; + } + args = ArrayUtils.addAll(args, cmd); + + System.out.println("run command: '" + StringUtils.join(args, " ") + "' in directory " + directory); + // logger.fine("run command: " + StringUtils.join(args, " ")); + int code = -1; + try { + + ProcessBuilder processBuilder = new ProcessBuilder(args); + processBuilder.redirectErrorStream(true); + if (directory != null) { + processBuilder.directory(directory); + } + if (!StringUtils.isBlank(EXTRA_PATH)) { + processBuilder.environment().put("PATH", processBuilder.environment().get("PATH") + File.pathSeparator + EXTRA_PATH); + } + + Process process = processBuilder.start(); + + try (BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()))) { + String line; + while ((line = in.readLine()) != null) { + if (stdoutConsumer != null) { + stdoutConsumer.accept(line); + } else { + logger.info("OUT:" + line); + } + } + } + + code = process.waitFor(); + if (code != 0) { + throw new RuntimeException("error while exectuting: " + StringUtils.join(args, " ") + ", error code: " + + code); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/Tree.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/Tree.java new file mode 100644 index 00000000..cfd4d772 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/Tree.java @@ -0,0 +1,367 @@ +package org.jsweet.input.typescriptdef.util; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Stack; +import java.util.stream.Collectors; + +/** + * A tree is an element container that can have several child trees. + * + * @author Renaud Pawlak + * + * @param + * the type of the element attached to the tree + * @param + * the type of the id attached to the tree + */ +public class Tree { + + private E element; + private ID id; + private Tree parentTree; + private List> childTrees = new ArrayList>(); + + /** + * A default scanner, to be overriden to perform recursive operations on a + * tree. + * + * @author Renaud Pawlak + */ + public static class Scanner { + protected Stack> stack = new Stack<>(); + + public final void scan(Tree tree) { + if (!enter(tree)) { + return; + } + stack.push(tree); + try { + for (Tree childTree : tree.getChildTrees()) { + scan(childTree); + } + } finally { + stack.pop(); + exit(tree); + } + } + + protected boolean enter(Tree tree) { + return true; + } + + protected void exit(Tree tree) { + } + } + + /** + * A helper to match a tree or a path on the to-stringed values of its + * elements. + * + * @author Renaud Pawlak + */ + public static class Matcher { + protected String[] expressions; + + /** + * Each expression is a matcher for an element in the tested path. + *

+ * Not operators are allowed with expressions starting with !. + *

+ * A path will match if all the first elements match each expressions of + * the matcher. + */ + public Matcher(String... expressions) { + this.expressions = expressions; + } + + /** + * Returns true if this matcher matches the given tree (i.e. if one path + * starting from that tree matches). + */ + public boolean matches(Tree tree) { + return matches(Arrays.asList(this.expressions), tree); + } + + private static boolean matches(List expressions, Tree tree) { + if (expressions.isEmpty()) { + return true; + } + + String expr = expressions.get(0); + if (expr.startsWith("!")) { + expr = expr.substring(1); + if (("" + tree.getElement()).equals(expr)) { + return false; + } + } else { + if (!("" + tree.getElement()).equals(expr)) { + return false; + } + } + + if (tree.getChildTrees().isEmpty()) { + return true; + } + + for (Tree child : tree.getChildTrees()) { + if (matches(expressions.subList(1, expressions.size()), child)) { + return true; + } + } + return false; + } + + /** + * Returns true if this matcher matches the given path. + */ + public boolean matches(List path) { + return matches(Arrays.asList(this.expressions), path); + } + + private static boolean matches(List expressions, List path) { + if (expressions.isEmpty()) { + return true; + } + if (path.isEmpty()) { + return false; + } + + String expr = expressions.get(0); + if (expr.startsWith("!")) { + expr = expr.substring(1); + if (("" + path.get(0)).equals(expr)) { + return false; + } + } else { + if (!("" + path.get(0)).equals(expr)) { + return false; + } + } + + return matches(expressions.subList(1, expressions.size()), path.subList(1, path.size())); + } + + } + + /** + * Constructs a tree with a single element (no parent, no children). + */ + public Tree(E element) { + this.element = element; + } + + /** + * Gets the id attached to this tree (optional). + */ + public ID getID() { + return id; + } + + /** + * Sets the id attached to this tree. + */ + public void setID(ID id) { + this.id = id; + } + + /** + * Add some children elements to this tree. + * + * @param element + * the element to add children to (root node if null) + * @param childElements + * the elements to add to the parent + */ + public void addChildElements(List childElements) { + for (E child : childElements) { + Tree childTree = new Tree(child); + childTree.parentTree = this; + this.childTrees.add(childTree); + } + } + + public void clearChildTrees() { + this.childTrees.clear(); + } + + public void addChildTrees(List> childTrees) { + for (Tree childTree : childTrees) { + childTree.parentTree = this; + this.childTrees.add(childTree); + } + } + + public void addChildTree(Tree childTree) { + childTree.parentTree = this; + this.childTrees.add(childTree); + } + + /** + * Adds a child to this tree (add the end of the current children). + */ + public Tree addChildElement(E childElement) { + Tree childTree = new Tree(childElement); + childTree.parentTree = this; + this.childTrees.add(childTree); + return childTree; + } + + /** + * Gets the parent tree of this tree. + */ + public Tree getParentTree() { + return parentTree; + } + + /** + * Gets the parent of this tree. + */ + public E getParentElement() { + return parentTree != null ? parentTree.element : null; + } + + /** + * Gets the children of this tree. + */ + public List> getChildTrees() { + return this.childTrees; + } + + /** + * Gets the child trees that match the given element. + */ + public List> getChildTrees(E e) { + return childTrees.stream().filter(t -> e.equals(t.element)).collect(Collectors.toList()); + } + + /** + * Get the elements attached to the child trees. + */ + public List getChildElements() { + return childTrees.stream().map(t -> t.element).collect(Collectors.toList()); + } + + /** + * Gets the element contained in this tree. + */ + public E getElement() { + return this.element; + } + + /** + * Sets the element contained in this tree; + */ + public void setElement(E element) { + this.element = element; + } + + /** + * Adds a path to the current tree. + */ + final public Tree addPath(List path) { + if (path.size() == 0) { + return this; + } + List childElements = getChildElements(); + int index = childElements.indexOf(path.get(0)); + Tree nextTree; + if (index < 0) { + nextTree = addChildElement(path.get(0)); + } else { + nextTree = getChildTrees().get(index); + } + return nextTree.addPath(path.subList(1, path.size())); + } + + public boolean isLeaf() { + return childTrees.isEmpty(); + } + + @Override + public String toString() { + final StringBuffer output = new StringBuffer(); + new Tree.Scanner() { + protected boolean enter(Tree tree) { + output.append("["); + output.append(tree.getElement()); + if (tree.getID() != null) { + output.append("*"); + } + return true; + } + + protected void exit(Tree tree) { + output.append("]"); + } + }.scan(this); + return output.toString(); + } + + public List>> findElement(final E element) { + final List>> result = new ArrayList<>(); + final List> path = new ArrayList<>(); + new Tree.Scanner() { + protected boolean enter(Tree tree) { + if (element.equals(tree.getElement())) { + path.clear(); + for (Tree t : stack) { + path.add(t); + } + path.add(tree); + result.add(new ArrayList<>(path)); + } + return true; + } + }.scan(this); + return result; + } + + public List> findFirstElement(final E element) { + final List> path = new ArrayList<>(); + new Tree.Scanner() { + protected boolean enter(Tree tree) { + if (!path.isEmpty()) { + return false; + } + if (element.equals(tree.getElement())) { + path.clear(); + for (Tree t : stack) { + path.add(t); + } + path.add(tree); + return false; + } + return true; + } + }.scan(this); + return path; + } + + public List> find(final ID id) { + final List> path = new ArrayList<>(); + new Tree.Scanner() { + protected boolean enter(Tree tree) { + if (!path.isEmpty()) { + return false; + } + if (id.equals(tree.getID())) { + for (Tree t : stack) { + path.add(t); + } + path.add(tree); + return false; + } + return true; + } + }.scan(this); + return path; + } + + public static List toStringPath(List> path) { + return path.stream().map(t -> t.getElement()).collect(Collectors.toList()); + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/Util.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/Util.java new file mode 100644 index 00000000..12aa9185 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/util/Util.java @@ -0,0 +1,636 @@ +package org.jsweet.input.typescriptdef.util; + +import java.io.File; +import java.io.IOException; +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.function.BiConsumer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.commons.lang3.AnnotationUtils; +import org.apache.commons.lang3.ClassUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import org.apache.log4j.Logger; +import org.jsoup.helper.StringUtil; +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.ast.ArrayTypeReference; +import org.jsweet.input.typescriptdef.ast.AstNode; +import org.jsweet.input.typescriptdef.ast.CompilationUnit; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Declaration; +import org.jsweet.input.typescriptdef.ast.DeclarationContainer; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.ModuleDeclaration; +import org.jsweet.input.typescriptdef.ast.ParameterDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.Type; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeParameterDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeParameterizedElement; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.ast.TypedDeclaration; +import org.jsweet.input.typescriptdef.ast.Visitable; + +public class Util { + + protected final static Logger logger = Logger.getLogger(Util.class); + public static Map coreTypeMap = new HashMap(); + public static Map wrapTypeMap = new HashMap(); + + static { + coreTypeMap.put("any", "Object"); + coreTypeMap.put("string", "String"); + coreTypeMap.put("boolean", "Boolean"); + coreTypeMap.put("String", "String"); + coreTypeMap.put("Boolean", "Boolean"); + coreTypeMap.put("Object", "Object"); + } + + static { + wrapTypeMap.put("any", "java.lang.Object"); + wrapTypeMap.put("string", "java.lang.String"); + wrapTypeMap.put("String", "java.lang.String"); + wrapTypeMap.put("Boolean", "java.lang.Boolean"); + wrapTypeMap.put("boolean", "java.lang.Boolean"); + wrapTypeMap.put("double", "java.lang.Double"); + wrapTypeMap.put("number", "java.lang.Double"); + wrapTypeMap.put("int", "java.lang.Integer"); + wrapTypeMap.put("float", "java.lang.Float"); + wrapTypeMap.put("Object", "java.lang.Object"); + } + + public static T wrapTypeReferences(T node) { + // new Scanner((Context) null) { + // @Override + // public void visitTypeReference(TypeReference typeReference) { + // typeReference.setName(typeReference.getWrappingTypeName()); + // } + // }.scan(node); + // return node; + return subtituteTypeReferenceNames(node, wrapTypeMap); + } + + public static T subtituteTypeReferenceNames(T node, final Map nameMap) { + new Scanner((Context) null) { + @Override + public void visitTypeReference(TypeReference typeReference) { + if (nameMap.containsKey(typeReference.getName())) { + typeReference.setName(nameMap.get(typeReference.getName())); + } + } + }.scan(node); + return node; + } + + public static T subtituteTypeReferences(T node, final Map nameMap) { + new Scanner((Context) null) { + @Override + public void visitTypeReference(TypeReference typeReference) { + if (nameMap.containsKey(typeReference.getName())) { + TypeReference targetTypeReference = nameMap.get(typeReference.getName()); + if (getParent() instanceof TypedDeclaration + && ((TypedDeclaration) getParent()).getType() == typeReference) { + ((TypedDeclaration) getParent()).setType(targetTypeReference.copy()); + } else { + if (typeReference instanceof ArrayTypeReference) { + logger.error("cannot substitute array type reference"); + } else { + typeReference.setName(targetTypeReference.getName()); + typeReference.setTypeArguments(targetTypeReference.getTypeArguments()); + } + } + } + } + }.scan(node); + return node; + } + + public static boolean hasTypeParameterReferences(Context context, AstNode node) { + List l = new ArrayList(); + new Scanner(context) { + @Override + public void visitTypeReference(TypeReference typeReference) { + Type t = lookupType(typeReference); + if (t instanceof TypeParameterDeclaration) { + l.add((TypeParameterDeclaration) t); + } + super.visitTypeReference(typeReference); + } + }.scan(node); + return !l.isEmpty(); + } + + public static boolean substituteTypeReference(Scanner scanner, TypedDeclaration targetTypedElement, + TypeReference targetType, TypeReference newType) { + Visitable node = null; + do { + if (node == null) { + node = scanner.getParent(); + } else { + node = scanner.getParent(Visitable.class, node); + } + if (node instanceof TypeReference) { + if (((TypeReference) node).substituteTypeReference(targetType, newType)) { + return true; + } + } + } while (!scanner.getStack().isEmpty() && node != targetTypedElement); + if (node == targetTypedElement) { + targetTypedElement.setType(newType); + return true; + } + return false; + } + + static Pattern referencePathMatcher = Pattern.compile("/// * + * assertEquals("../c", Util.getRelativePath("/a/b", "/a/c")); + * assertEquals("..", Util.getRelativePath("/a/b", "/a")); + * assertEquals("../e", Util.getRelativePath("/a/b/c", "/a/b/e")); + * assertEquals("d", Util.getRelativePath("/a/b/c", "/a/b/c/d")); + * assertEquals("d/e", Util.getRelativePath("/a/b/c", "/a/b/c/d/e")); + * assertEquals("../../../d/e/f", Util.getRelativePath("/a/b/c", "/d/e/f")); + * assertEquals("../..", Util.getRelativePath("/a/b/c", "/a")); + * assertEquals("..", Util.getRelativePath("/a/b/c", "/a/b")); + * + * + *

+ * Thanks to: + * http://mrpmorris.blogspot.com/2007/05/convert-absolute-path-to-relative- + * path.html + * + *

+ * Bug fix: Renaud Pawlak + * + * @param fromPath + * the path to start from + * @param toPath + * the path to reach + */ + public static String getRelativePath(String fromPath, String toPath) { + StringBuilder relativePath = null; + + fromPath = fromPath.replaceAll("\\\\", "/"); + toPath = toPath.replaceAll("\\\\", "/"); + + if (!fromPath.equals(toPath)) { + String[] fromSegments = fromPath.split("/"); + String[] toSegments = toPath.split("/"); + + // Get the shortest of the two paths + int length = fromSegments.length < toSegments.length ? fromSegments.length : toSegments.length; + + // Use to determine where in the loop we exited + int lastCommonRoot = -1; + int index; + + // Find common root + for (index = 0; index < length; index++) { + if (fromSegments[index].equals(toSegments[index])) { + lastCommonRoot = index; + } else { + break; + // If we didn't find a common prefix then throw + } + } + if (lastCommonRoot != -1) { + // Build up the relative path + relativePath = new StringBuilder(); + // Add on the .. + for (index = lastCommonRoot + 1; index < fromSegments.length; index++) { + if (fromSegments[index].length() > 0) { + relativePath.append("../"); + } + } + for (index = lastCommonRoot + 1; index < toSegments.length - 1; index++) { + relativePath.append(toSegments[index] + "/"); + } + if (!fromPath.startsWith(toPath)) { + relativePath.append(toSegments[toSegments.length - 1]); + } else { + if (relativePath.length() > 0) { + relativePath.deleteCharAt(relativePath.length() - 1); + } + } + } + } + return relativePath == null ? null : relativePath.toString(); + } + + private static String getReferenceMainModuleName(Context context, CompilationUnit compilationUnit, String reference) + throws IOException { + if (reference == null) { + return null; + } + File referenceFile = new File(reference); + if (!referenceFile.isAbsolute()) { + referenceFile = new File(compilationUnit.getFile().getParentFile(), reference); + referenceFile = referenceFile.getCanonicalFile(); + } + CompilationUnit referencedCompilationUnit = null; + for (CompilationUnit cu : context.compilationUnits) { + if (cu.getFile().getCanonicalFile().equals(referenceFile)) { + referencedCompilationUnit = cu; + } + } + return referencedCompilationUnit == null ? null : referencedCompilationUnit.getMainModule().getName(); + } + + public static void createDependencyGraph(Context context) throws IOException { + DirectedGraph dependencyGraph = new DirectedGraph(); + for (CompilationUnit compilationUnit : context.compilationUnits) { + String lib = compilationUnit.getMainModule().getName(); + if (lib == null) { + continue; + } + if (!dependencyGraph.contains(lib)) { + dependencyGraph.add(lib); + } + for (String ref : compilationUnit.getReferences()) { + String refLib = getReferenceMainModuleName(context, compilationUnit, Util.getLibPathFromReference(ref)); + if (refLib == null) { + continue; + } + if (refLib.equals(lib)) { + // ignore self references + continue; + } + if (!dependencyGraph.contains(refLib)) { + dependencyGraph.add(refLib); + } + dependencyGraph.addEdge(lib, refLib); + } + } + context.dependencyGraph = dependencyGraph; + } + + public static String toJavaName(String name) { + return toJavaName(name, false); + } + + public static String toJavaName(String name, boolean forceLowerCase) { + if (name == null) { + return null; + } + if (forceLowerCase) { + if (!StringUtils.isAllLowerCase(name)) { + name = name.toLowerCase(); + } + } + if (name.contains("-") || name.contains("/")) { + return name.replace('/', '_').replace('-', '_'); + } + if (Character.isDigit(name.charAt(0))) { + return "_" + name; + } + if (JSweetDefTranslatorConfig.JAVA_KEYWORDS.contains(name)) { + if (forceLowerCase) { + return "_" + name; + } else { + return StringUtils.capitalize(name); + } + } + return name; + } + + /** + *

+ * Generate a string representation of an Annotation, as suggested by + * {@link Annotation#toString()}. + *

+ * + * @param a + * the annotation of which a string representation is desired + * @return the standard string representation of an annotation, not + * {@code null} + */ + public static String toString(final Annotation a) { + final ToStringBuilder builder = new ToStringBuilder(a, TO_STRING_STYLE); + for (final Method m : a.annotationType().getDeclaredMethods()) { + if (m.getParameterTypes().length > 0) { + continue; // wtf? + } + try { + Object val = m.invoke(a); + if (val instanceof String) { + val = "\"" + val + "\""; + } + builder.append(m.getName(), val); + } catch (final RuntimeException ex) { + throw ex; + } catch (final Exception ex) { + throw new RuntimeException(ex); + } + } + return builder.build(); + } + + private static final ToStringStyle TO_STRING_STYLE = new ToStringStyle() { + /** Serialization version */ + private static final long serialVersionUID = 1L; + + { + setDefaultFullDetail(true); + setArrayContentDetail(true); + setUseClassName(true); + setUseShortClassName(true); + setUseIdentityHashCode(false); + setContentStart("("); + setContentEnd(")"); + setFieldSeparator(", "); + setArrayStart("["); + setArrayEnd("]"); + } + + /** + * {@inheritDoc} + */ + @Override + protected String getShortClassName(final java.lang.Class cls) { + Class annotationType = null; + for (final Class iface : ClassUtils.getAllInterfaces(cls)) { + if (Annotation.class.isAssignableFrom(iface)) { + @SuppressWarnings("unchecked") + // OK because we just checked the assignability + final Class found = (Class) iface; + annotationType = found; + break; + } + } + return new StringBuilder(annotationType == null ? "" : annotationType.getName()).insert(0, '@').toString(); + } + + /** + * {@inheritDoc} + */ + @Override + protected void appendDetail(final StringBuffer buffer, final String fieldName, Object value) { + if (value instanceof Annotation) { + value = AnnotationUtils.toString((Annotation) value); + } + super.appendDetail(buffer, fieldName, value); + } + + }; + + public static void checkAndAdjustDeclarationName(Declaration declaration) { + checkAndAdjustDeclarationName(declaration, false); + } + + public static void checkAndAdjustDeclarationName(Declaration declaration, boolean forceLowerCase) { + String oldName = declaration.getName(); + + if (StringUtil.isBlank(oldName)) { + return; + } + String newName = toJavaName(oldName, forceLowerCase); + if (declaration.isQuotedName() && newName.contains(".")) { + newName = newName.replace('.', '_'); + } + if (!oldName.equals(newName)) { + declaration.removeStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_NAME); + declaration.addStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_NAME + "(\"" + oldName + "\")"); + declaration.setOriginalName(declaration.getName()); + declaration.setName(newName); + } + } + + /** + * Returns true if the container or any subnode of that AST contains the + * exact given node object. Note that this function uses object reference + * comparison (==). + */ + public static boolean containsAstNode(AstNode container, AstNode node) { + final boolean[] result = { false }; + new Scanner((Context) null) { + @Override + public void scan(Visitable visitable) { + if (node == visitable) { + result[0] = true; + } else { + super.scan(visitable); + } + } + }.scan(container); + return result[0]; + } + + /** + * Gets the qualifier of the given qualified name. + */ + public static String getQualifier(String qualifiedName) { + if (qualifiedName == null) { + return null; + } + int index = qualifiedName.lastIndexOf('.'); + if (index < 0) { + return null; + } + return qualifiedName.substring(0, qualifiedName.lastIndexOf('.')); + } + + public static boolean isQualified(String name) { + return name.indexOf('.') != -1; + } + + /** + * Gets the simple name of the given qualified name. + */ + public static String getSimpleName(String qualifiedName) { + return qualifiedName == null ? null : qualifiedName.substring(qualifiedName.lastIndexOf('.') + 1); + } + + private static TypeDeclaration createGlobalsClass(String name) { + TypeDeclaration globalsClass = new TypeDeclaration(null, "class", name, null, null, new Declaration[0]); + globalsClass.addModifier("final"); + FunctionDeclaration constructor = new FunctionDeclaration(null, "constructor", null, + new ParameterDeclaration[0], null); + constructor.addModifier("private"); + globalsClass.addMember(constructor); + return globalsClass; + } + + public static TypeDeclaration getOrCreateGlobalsType(Context context, ModuleDeclaration moduleDeclaration, + DeclarationContainer container) { + String modName = moduleDeclaration.getName(); + TypeDeclaration globalsClass = null; + if (container != null && Util.elligibleToClass(moduleDeclaration)) { + globalsClass = container.findType(modName); + if (globalsClass == null) { + globalsClass = createGlobalsClass(modName); + context.registerType( + ((container instanceof ModuleDeclaration) + ? context.getModuleName((ModuleDeclaration) container) + "." : "") + modName, + globalsClass); + globalsClass.setDocumentation("/** Utility class. */"); + container.addMember(globalsClass); + } + } else { + globalsClass = context.getTypeDeclaration( + context.getModuleName(moduleDeclaration) + "." + JSweetDefTranslatorConfig.GLOBALS_CLASS_NAME); + if (globalsClass == null) { + globalsClass = createGlobalsClass(JSweetDefTranslatorConfig.GLOBALS_CLASS_NAME); + context.registerType( + context.getModuleName(moduleDeclaration) + "." + JSweetDefTranslatorConfig.GLOBALS_CLASS_NAME, + globalsClass); + globalsClass.setDocumentation("/** This class holds all the global functions and variables of the " + + moduleDeclaration.getName() + " package. */"); + moduleDeclaration.addMember(globalsClass); + } + } + return globalsClass; + } + + public static TypeParameterDeclaration[] findTypeParameters(Scanner parent, Visitable visitable) { + return new TypeParameterFinder(parent).find(visitable); + } + + public static TypeParameterDeclaration[] findTypeParameters(Context context, + TypeParameterizedElement typeParameterHolder, Visitable visitable) { + return findTypeParameters(context, typeParameterHolder, visitable, null); + } + + public static TypeParameterDeclaration[] findTypeParameters(Context context, + TypeParameterizedElement typeParameterHolder, Visitable visitable, + BiConsumer referenceHandler) { + return new TypeParameterFinder2(context, typeParameterHolder, referenceHandler).find(visitable); + } + + public static String[] findTypeParameterNames(Context context, TypeParameterizedElement typeParameterHolder, + Visitable visitable) { + return Arrays.asList(findTypeParameters(context, typeParameterHolder, visitable)).stream().map(t -> t.getName()) + .toArray(size -> new String[size]); + } + + static class TypeParameterFinder extends Scanner { + private List declarations = new ArrayList(); + + public TypeParameterFinder(Scanner parent) { + super(parent); + } + + public TypeParameterDeclaration[] find(Visitable visitable) { + visitable.accept(this); + return declarations.toArray(new TypeParameterDeclaration[0]); + } + + @Override + public void visitTypeReference(TypeReference typeReference) { + Type t = lookupType(typeReference, null); + if (t instanceof TypeParameterDeclaration) { + if (!declarations.contains(t)) { + declarations.add((TypeParameterDeclaration) t); + } + } + super.visitTypeReference(typeReference); + } + + } + + static class TypeParameterFinder2 extends Scanner { + private List declarations = new ArrayList(); + + private TypeParameterizedElement typeParameterHolder; + + private BiConsumer referenceHandler; + + public TypeParameterFinder2(Context context, TypeParameterizedElement typeParameterHolder, + BiConsumer referenceHandler) { + super(context); + this.typeParameterHolder = typeParameterHolder; + this.referenceHandler = referenceHandler; + } + + public TypeParameterDeclaration[] find(Visitable visitable) { + if (typeParameterHolder.getTypeParameters() != null && typeParameterHolder.getTypeParameters().length > 0) { + visitable.accept(this); + } + return declarations.toArray(new TypeParameterDeclaration[0]); + } + + @Override + public void visitTypeReference(TypeReference typeReference) { + for (TypeParameterDeclaration t : typeParameterHolder.getTypeParameters()) { + if (typeReference.getName().equals(t.getName())) { + if (referenceHandler != null) { + referenceHandler.accept(typeReference, t); + } + if (!declarations.contains(t)) { + declarations.add(t); + } + } + } + super.visitTypeReference(typeReference); + } + + } + + public static Entry splitIntSuffix(String string) { + for (int i = 0; i < string.length(); i++) { + try { + int suffix = Integer.parseInt(string.substring(i)); + return new AbstractMap.SimpleEntry(string.substring(0, i), suffix); + } catch (NumberFormatException e) { + // swallow + } + } + return null; + } + + public static boolean elligibleToClass(ModuleDeclaration module) { + if (Character.isUpperCase(module.getName().charAt(0)) && !StringUtils.isAllUpperCase(module.getName())) { + for (Declaration declaration : module.getMembers()) { + if (declaration instanceof TypeDeclaration || declaration instanceof ModuleDeclaration) { + return false; + } + } + return true; + } else { + return false; + } + } + + public static String getLibPackageNameFromTsDefFile(File libFile) { + File parent = libFile.getParentFile(); + String pack = parent.getName().toLowerCase().replaceAll("[.-]", "_"); + parent = parent.getParentFile(); + + String packageName; + if (parent.getParentFile() != null + && !parent.getName().equals("test") + && !parent.getName().equals("typings") + && !parent.getName().equals("globals")) { + pack = parent.getName().toLowerCase().replaceAll("[.-]", "_") + (pack == null ? "" : "." + pack); + packageName = JSweetDefTranslatorConfig.LIBS_PACKAGE + "." + pack; + } else { + packageName = JSweetDefTranslatorConfig.LIBS_PACKAGE + "." + + libFile.getParentFile().getName().toLowerCase().replaceAll("[.-]", "_"); + } + + logger.debug(libFile.getPath() + " ==> " + packageName); + + return packageName; + } +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ConstructorInterfacesMerger.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ConstructorInterfacesMerger.java new file mode 100644 index 00000000..0a1152bf --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ConstructorInterfacesMerger.java @@ -0,0 +1,80 @@ +package org.jsweet.input.typescriptdef.visitor; + +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Declaration; +import org.jsweet.input.typescriptdef.ast.DeclarationContainer; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.Type; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; + +public class ConstructorInterfacesMerger extends Scanner { + + public ConstructorInterfacesMerger(Context context) { + super(context); + } + + protected void makeAllMembersStatic(TypeDeclaration typeDeclaration) { + for (Declaration member : typeDeclaration.getMembers()) { + member.addModifier("static"); + } + } + + @Override + public void visitTypeDeclaration(TypeDeclaration typeDeclaration) { + // TODO + // if a variable V exists in the same module with the same name then + // -- if V is of the type of typeDeclaration then + // ---- if there is no constructor in typeDeclaration (or supertypes) + // then + // ------ typeDeclaration moves all its functions and variables to + // static ones + // ---- end + // -- else if V is of a type T (can be anonymous - object type) that + // declares a constructor then + // ---- 1. typeDeclaration is not abstract anymore + // ---- 2. all the functions and variables (including constructors) of T + // are injected into typeDeclaration + // ---- 3. all the functions of typeDeclaration are not abstract anymore + // ---- 4. V is deleted from the current modules' members + // ---- 5. T is deleted only if T is not anonymous + // -- end + // end + VariableDeclaration v = getParent(DeclarationContainer.class).findVariable(typeDeclaration.getName()); + if (v != null) { + Type t = lookupType(v.getType(), null); + if (t instanceof TypeDeclaration) { + TypeDeclaration variableType = (TypeDeclaration) t; + if (typeDeclaration.equals(variableType)) { + if (typeDeclaration.findFirstConstructor() == null) { + makeAllMembersStatic(typeDeclaration); + typeDeclaration.removeStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_OBJECT_TYPE); + v.setHidden(true); + } + } else { + for (Declaration declaration : variableType.getMembers()) { + if ((declaration instanceof FunctionDeclaration) + && ((FunctionDeclaration) declaration).isConstructor()) { + continue; + // declaration.setName("constructor"); + } else { + declaration.addModifier("static"); + } + } + typeDeclaration.removeStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_INTERFACE); + typeDeclaration.addMembers(variableType.getMembers()); + typeDeclaration.removeModifier("abstract"); + v.setHidden(true); + if (!variableType.isAnonymous()) { + context.mergedContructors.put(variableType, typeDeclaration); + variableType.setHidden(true); + } + } + } + } + // super.visitTypeDeclaration(typeDeclaration); + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ConstructorTypeReferenceReplacer.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ConstructorTypeReferenceReplacer.java new file mode 100644 index 00000000..220c6355 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ConstructorTypeReferenceReplacer.java @@ -0,0 +1,34 @@ +package org.jsweet.input.typescriptdef.visitor; + +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeReference; + +/** + * @author Renaud Pawlak + */ +public class ConstructorTypeReferenceReplacer extends Scanner { + + public ConstructorTypeReferenceReplacer(Context context) { + super(context); + } + + @Override + public void visitTypeReference(TypeReference typeReference) { + if (context.mergedContructors.containsKey(typeReference.getDeclaration())) { + // TODO: not very well typed but otherwise would require method + // disambiguation... better typing could be quite easily achieved + + // typeReference.setTypeArguments(new TypeReference[] { new + // TypeReference(null, + // context.getTypeName(context.mergedContructors.get(typeReference.getDeclaration())), + // null) }); + typeReference.setTypeArguments(new TypeReference[] { new TypeReference(null, "any", null) }); + typeReference.setName(Class.class.getName()); + typeReference.setDeclaration(context.getTypeDeclaration(Class.class.getName())); + } else { + super.visitTypeReference(typeReference); + } + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/DeclarationBinder.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/DeclarationBinder.java new file mode 100644 index 00000000..4a942bcd --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/DeclarationBinder.java @@ -0,0 +1,38 @@ +package org.jsweet.input.typescriptdef.visitor; + +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.ModuleDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeMacroDeclaration; + +public class DeclarationBinder extends Scanner { + + public DeclarationBinder(Context context) { + super(context); + } + + public DeclarationBinder(Scanner parentScanner) { + super(parentScanner); + } + + @Override + public void visitModuleDeclaration(ModuleDeclaration moduleDeclaration) { + context.registerModule(getCurrentContainerName(), moduleDeclaration); + super.visitModuleDeclaration(moduleDeclaration); + } + + @Override + public void visitTypeDeclaration(TypeDeclaration typeDeclaration) { + if (!typeDeclaration.isAnonymous()) { + context.registerType(getCurrentContainerName(), typeDeclaration); + } + super.visitTypeDeclaration(typeDeclaration); + } + + @Override + public void visitTypeMacro(TypeMacroDeclaration typeMacroDeclaration) { + context.registerType(getCurrentContainerName(), typeMacroDeclaration); + super.visitTypeMacro(typeMacroDeclaration); + } +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/DocFiller.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/DocFiller.java new file mode 100644 index 00000000..62cdc9a8 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/DocFiller.java @@ -0,0 +1,400 @@ +package org.jsweet.input.typescriptdef.visitor; + +import java.io.File; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.apache.log4j.Logger; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Node; +import org.jsoup.nodes.TextNode; +import org.jsoup.select.NodeTraversor; +import org.jsoup.select.NodeVisitor; +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.ast.CompilationUnit; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Declaration; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; + +/** + * This scanner tries to fill the documentation from external sources, when it + * does not pre-exist in the definition file. + * + * @author Renaud Pawlak + */ +public class DocFiller extends Scanner { + + private final static Logger logger = Logger.getLogger(DocFiller.class); + + int domDocsCount = 0; + int domDescriptionDocsCount = 0; + int langDocsCount = 0; + int langDescriptionDocsCount = 0; + String currentModule; + + public DocFiller(Context context) { + super(context); + } + + @Override + public void visitCompilationUnit(CompilationUnit compilationUnit) { + if (context.isDependency(compilationUnit)) { + return; + } + + super.visitCompilationUnit(compilationUnit); + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + } + + @Override + public void visitTypeDeclaration(TypeDeclaration typeDeclaration) { + if (typeDeclaration.getDocumentation() == null) { + String moduleName = getCurrentModuleName(); + if (JSweetDefTranslatorConfig.LANG_PACKAGE.equals(moduleName) + || JSweetDefTranslatorConfig.DOM_PACKAGE.equals(moduleName)) { + this.currentModule = moduleName; + + String content = getTypeContent(context.cacheDir, "mdn", moduleName, typeDeclaration.getName()); + if (content != null) { + try { + Document doc = Jsoup.parse(content, "UTF-8"); + NodeTraversor traversor; + traversor = new NodeTraversor(new MdnTableFormatGrabber(this, typeDeclaration)); + traversor.traverse(doc.body()); + traversor = new NodeTraversor(new MdnDefinitionListFormatGrabber(this, typeDeclaration)); + traversor.traverse(doc.body()); + traversor = new NodeTraversor(new MdnMainDescriptionGrabber(this, typeDeclaration)); + traversor.traverse(doc.body()); + } catch (Throwable t) { + context.reportError("cannot fill documentation for " + context.getTypeName(typeDeclaration), t); + } + } + } + } + } + + void countDoc(boolean description) { + if (JSweetDefTranslatorConfig.LANG_PACKAGE.equals(currentModule)) { + if (description) { + langDescriptionDocsCount++; + } else { + langDocsCount++; + } + } else { + if (description) { + domDescriptionDocsCount++; + } else { + domDocsCount++; + } + } + } + + static String getTypeContent(File cacheDir, String provider, String moduleName, String typeName) { + String content = null; + try { + File cachedFile = cacheDir == null ? null : new File(cacheDir, provider + File.separator + typeName); + if (cachedFile != null && cachedFile.exists()) { + content = FileUtils.readFileToString(cachedFile); + } else { + try { + if (JSweetDefTranslatorConfig.DOM_PACKAGE.equals(moduleName)) { + content = IOUtils + .toString(new URL("https://developer.mozilla.org/en-US/docs/Web/API/" + typeName)); + } + if (JSweetDefTranslatorConfig.LANG_PACKAGE.equals(moduleName)) { + content = IOUtils.toString( + new URL("https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/" + + typeName)); + } + logger.info("content downloaded for " + moduleName + "." + typeName); + } catch (Exception e) { + content = ""; + } + if (cachedFile != null) { + logger.info("writing cache to " + cachedFile); + FileUtils.write(cachedFile, content, false); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return content; + } + + public static String removeTags(String html) { + return removeTags(html, new String[] { "a", "body" }); + } + + public static String removeTags(String html, String[] tagsToBeRemoved) { + StringBuilder sb = new StringBuilder(); + NodeTraversor traversor = new NodeTraversor(new TagRemover(sb, tagsToBeRemoved)); + traversor.traverse(Jsoup.parse(html).body()); + return sb.toString().replace("

", ""); + } + + public static void main(String[] args) { + System.out.println(removeTags("Ceci est un test slurp hop arlgs.", + new String[] { "a", "body" })); + String content = getTypeContent(null, "mdn", JSweetDefTranslatorConfig.LANG_PACKAGE, "Array"); + Document doc = Jsoup.parse(content, "UTF-8"); + System.out.println(doc.toString()); + } + + static void addToMap(Map> map, String key, T value) { + List l = map.get(key); + if (l == null) { + l = new ArrayList<>(); + map.put(key, l); + } + l.add(value); + } + + static List getSiblingTags(Node node) { + List siblings = new ArrayList<>(); + for (Node n : node.siblingNodes()) { + if (!(n instanceof TextNode)) { + siblings.add(n); + } + } + return siblings; + } + + static boolean isLastSiblingTag(Node node) { + List siblings = new ArrayList<>(); + for (Node n : node.parent().childNodes()) { + if (!(n instanceof TextNode)) { + siblings.add(n); + } + } + return (node == siblings.get(siblings.size() - 1)); + } + + @Override + public void onScanEnded() { + System.out.println("Package lang: " + langDescriptionDocsCount + " type descriptions and " + langDocsCount + + " member docs added."); + System.out.println("Package dom: " + domDescriptionDocsCount + " type descriptions and " + domDocsCount + + " member docs added."); + } + +} + +class MdnTableFormatGrabber implements NodeVisitor { + + private Map> members = new HashMap<>(); + private DocFiller docFiller; + + public MdnTableFormatGrabber(DocFiller docFiller, TypeDeclaration typeDeclaration) { + this.docFiller = docFiller; + for (Declaration member : typeDeclaration.getMembers()) { + if (member.getDocumentation() != null + || member.hasStringAnnotation(org.jsweet.JSweetDefTranslatorConfig.ANNOTATION_STRING_TYPE)) { + continue; + } + DocFiller.addToMap(members, member.getName(), member); + } + } + + @Override + public void head(Node node, int depth) { + if (node instanceof TextNode) { + String text = ((TextNode) node).text().trim(); + if (members.containsKey(text)) { + Node parent = node.parent(); + if (parent != null && !"td".equals(parent.nodeName())) { + parent = parent.parent(); + } + if (parent != null && !"td".equals(parent.nodeName())) { + parent = parent.parent(); + } + if (parent != null && "td".equals(parent.nodeName())) { + List siblings = parent.parent().childNodes(); + List tdSiblings = new ArrayList(); + siblings.forEach(n -> { + if ("td".equals(n.nodeName())) + tdSiblings.add(n); + }); + + if (tdSiblings.get(0) == parent && tdSiblings.size() == 3) { + Node td = tdSiblings.get(2); + String s = td.toString(); + String doc = "/** " + DocFiller.removeTags(s.substring(4, s.length() - 5)) + " */"; + for (Declaration d : members.get(text)) { + d.setDocumentation(doc); + } + docFiller.countDoc(false); + } + } + } + } + } + + @Override + public void tail(Node node, int depth) { + } + +} + +class MdnDefinitionListFormatGrabber implements NodeVisitor { + + private Map> members = new HashMap<>(); + private DocFiller docFiller; + + public MdnDefinitionListFormatGrabber(DocFiller docFiller, TypeDeclaration typeDeclaration) { + this.docFiller = docFiller; + for (Declaration member : typeDeclaration.getMembers()) { + if (member.getDocumentation() != null + || member.hasStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_STRING_TYPE)) { + continue; + } + if (member instanceof FunctionDeclaration) { + DocFiller.addToMap(members, typeDeclaration.getName() + "." + member.getName() + "()", member); + } else { + DocFiller.addToMap(members, typeDeclaration.getName() + "." + member.getName(), member); + } + } + } + + @Override + public void head(Node node, int depth) { + if (node instanceof TextNode) { + String text = ((TextNode) node).text().trim(); + if (members.containsKey(text)) { + Node parent = node.parent(); + if (parent != null && !"dt".equals(parent.nodeName())) { + parent = parent.parent(); + } + if (parent != null && !"dt".equals(parent.nodeName())) { + parent = parent.parent(); + } + if (parent != null && "dt".equals(parent.nodeName())) { + List siblings = parent.parent().childNodes(); + List dlSiblings = new ArrayList(); + siblings.forEach(n -> { + if ("dt".equals(n.nodeName()) || "dd".equals(n.nodeName())) + dlSiblings.add(n); + }); + for (int i = 0; i < dlSiblings.size(); i++) { + if (dlSiblings.get(i) == parent) { + if (i < dlSiblings.size() - 1 && "dd".equals(dlSiblings.get(i + 1).nodeName())) { + String s = dlSiblings.get(i + 1).toString(); + String doc = "/** " + DocFiller.removeTags(s.substring(4, s.length() - 5)) + " */"; + for (Declaration d : members.get(text)) { + d.setDocumentation(doc); + } + docFiller.countDoc(false); + } + break; + } + } + } + } + } + } + + @Override + public void tail(Node node, int depth) { + } + +} + +class MdnMainDescriptionGrabber implements NodeVisitor { + + private StringBuffer description = new StringBuffer(); + private boolean found = false; + private TypeDeclaration typeDeclaration; + private DocFiller docFiller; + + public MdnMainDescriptionGrabber(DocFiller docFiller, TypeDeclaration typeDeclaration) { + this.docFiller = docFiller; + this.typeDeclaration = typeDeclaration; + } + + @Override + public void head(Node node, int depth) { + if (!found) { + if (node.attr("id") != null && node.attr("id").equalsIgnoreCase("Quick_Links")) { + found = true; + while (DocFiller.isLastSiblingTag(node)) { + node = node.parent(); + } + + Node n = node; + + while ((n = n.nextSibling()) != null && !("h2".equals(n.nodeName()) || "h3".equals(n.nodeName()))) { + description.append(n.outerHtml()); + } + + String s = Jsoup.parse(description.toString()).text(); + if ("".equals(s.trim())) { + if (n == null) { + n = node; + } + while ((n = n.nextSibling()) != null && !("h2".equals(n.nodeName()) || "h3".equals(n.nodeName()))) { + description.append(n.outerHtml()); + } + } + + typeDeclaration.setDocumentation("/** " + DocFiller.removeTags(description.toString()) + " */"); + docFiller.countDoc(true); + } + } + } + + @Override + public void tail(Node node, int depth) { + } + +} + +class TagRemover implements NodeVisitor { + + private StringBuilder out; + private Set tagsToBeRemoved; + + public TagRemover(StringBuilder out, String[] tagsToBeRemoved) { + this.out = out; + this.tagsToBeRemoved = new HashSet(Arrays.asList(tagsToBeRemoved)); + } + + public void head(Node node, int depth) { + String name = node.nodeName(); + if (!tagsToBeRemoved.contains(name)) { + if (node instanceof TextNode) { + TextNode tn = (TextNode) node; + out.append(tn.toString()); + } else { + out.append("<" + name + ">"); + } + } + } + + public void tail(Node node, int depth) { + String name = node.nodeName(); + if (!tagsToBeRemoved.contains(name)) { + if (!(node instanceof TextNode)) { + out.append(""); + } + } + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/DuplicateMethodsCleaner.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/DuplicateMethodsCleaner.java new file mode 100644 index 00000000..4b903f81 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/DuplicateMethodsCleaner.java @@ -0,0 +1,645 @@ +package org.jsweet.input.typescriptdef.visitor; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.apache.commons.lang3.StringUtils; +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Declaration; +import org.jsweet.input.typescriptdef.ast.DeclarationHelper; +import org.jsweet.input.typescriptdef.ast.FullFunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.ParameterDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeParameterDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; +import org.jsweet.input.typescriptdef.util.NameUtils; +import org.jsweet.input.typescriptdef.util.Util; + +/** + * This scanner hides duplicate method (real duplicates but also the ones with + * the same type erasure). + * + * @author Renaud Pawlak + */ +public class DuplicateMethodsCleaner extends Scanner { + + private int hiddenMethodCount = 0; + + private boolean dump = false; + + private final static String NO_OVERRIDE = ""; + + public enum Strategy { + USER_FRIENDLY, FULL; + } + + private final static int MAX_NAME_LENGTH = 40; + + public DuplicateMethodsCleaner(Context context) { + super(context); + } + + private void hideDuplicatesInDeclarations(TypeDeclaration originalDeclaringType, + FunctionDeclaration functionDeclaration, TypeDeclaration declaringType) { + Declaration[] declarations = declaringType.getMembers(); + if (declarations == null) { + return; + } + for (Declaration d : declarations) { + if (d instanceof FunctionDeclaration) { + FunctionDeclaration f = (FunctionDeclaration) d; + if (f != functionDeclaration && !f.isHidden() + && (f.getName().equals(functionDeclaration.getName()) + || (f.isConstructor() && functionDeclaration.isConstructor())) + && f.getParameters().length == functionDeclaration.getParameters().length) { + boolean duplicate = true; + boolean checkReturnType = true; + // static methods can never be overloaded + // if (!(!functionDeclaration.hasModifier("static") && + // f.hasModifier("static"))) { + + for (int i = 0; i < f.getParameters().length; i++) { + ParameterDeclaration d1 = functionDeclaration.getParameters()[i]; + ParameterDeclaration d2 = f.getParameters()[i]; + String erasedName1 = context.getTypeNameErased(d1.getType()); + String erasedName2 = context.getTypeNameErased(d2.getType()); + + try { + if (!erasedName1.equals(erasedName2)) { + duplicate = false; + break; + } else { + checkReturnType = context.getFullTypeNameNoErasure(d1.getType()) + .equals(context.getFullTypeNameNoErasure(d2.getType())); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + boolean incompatibleReturnType = false; + if (duplicate && checkReturnType && originalDeclaringType != declaringType + && !f.hasModifier("static")) { + // String name1 = + // functionDeclaration.getType().getName(); + // String name2 = f.getType().getName(); + // if (name1 != null && !name1.equals(name2)) { + // duplicate = false; + // } + try { + if (!Object.class.getName().equals(f.getType().getName()) + && !"Object".equals(f.getType().getName()) + && !functionDeclaration.getType().equals(f.getType()) + && !functionDeclaration.getType().isSubtypeOf(f.getType())) { + // duplicate = false; + incompatibleReturnType = true; + logger.debug("incompatible return types: " + functionDeclaration + " - " + + functionDeclaration.getType() + " / " + f); + } + } catch (Exception e) { + context.reportError("unattributed type ref for " + f + " at " + f.getLocation() + + ", declaring type: " + declaringType + " at " + declaringType.getLocation()); + } + } + if (duplicate) { + boolean isErased = false; + for (int i = 0; i < functionDeclaration.getParameters().length; i++) { + ParameterDeclaration d1 = functionDeclaration.getParameters()[i]; + ParameterDeclaration d2 = f.getParameters()[i]; + if (!context.getFullTypeNameNoErasure(d1.getType()) + .equals(context.getFullTypeNameNoErasure(d2.getType()))) { + isErased = true; + } + } + boolean staticDuplicate = (f.hasModifier("static") != functionDeclaration + .hasModifier("static")); + if (!incompatibleReturnType && originalDeclaringType != declaringType && !staticDuplicate) { + context.addOverride( + new FullFunctionDeclaration(null, originalDeclaringType, functionDeclaration), + new FullFunctionDeclaration(null, declaringType, f)); + } else if (isErased && !staticDuplicate) { + context.addDuplicate( + new FullFunctionDeclaration(null, originalDeclaringType, functionDeclaration), + new FullFunctionDeclaration(null, declaringType, f)); + } else { + if (context.verbose) { + logger.debug("WARNING: removing duplicate " + f + + (f.getToken() == null ? "" : " at " + f.getToken().getLocation()) + ", type " + + declaringType.getName()); + } + hiddenMethodCount++; + functionDeclaration.setHidden(true); + } + } + } + } + } + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + TypeDeclaration declaringType = getParent(TypeDeclaration.class); + TypeDeclaration orgType = declaringType; + while (declaringType != null) { + hideDuplicatesInDeclarations(orgType, functionDeclaration, declaringType); + if (!functionDeclaration.isConstructor()) { + if (declaringType.getSuperTypes() != null && declaringType.getSuperTypes().length > 0) { + declaringType = (TypeDeclaration) lookupType(declaringType.getSuperTypes()[0], null); + } else if ("class".equals(declaringType.getKind()) + && !JSweetDefTranslatorConfig.getObjectClassName().equals(context.getTypeName(declaringType))) { + declaringType = context.getTypeDeclaration(JSweetDefTranslatorConfig.getObjectClassName()); + } else { + declaringType = null; + } + } else { + declaringType = null; + } + } + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + } + + @Override + public void onScanEnded() { + handleDuplicates(); + if (hiddenMethodCount > 0) { + logger.debug(hiddenMethodCount + " method(s) hidden."); + } + } + + private void dumpDuplicates(List> duplicatesList) { + if (dump) { + for (Set s : duplicatesList) { + TypeDeclaration type = s.iterator().next().declaringType; + System.out.println(" -- " + context.getTypeName(type)); + for (FullFunctionDeclaration d : s) { + System.out.println(" * " + d); + if (context.overrides.get(d) != null) { + System.out.println(" -> overrides: " + context.overrides.get(d)); + } + if (context.overridens.get(d) != null) { + System.out.println(" -> overridens: " + context.overridens.get(d)); + } + } + } + } + } + + private void handleDuplicates() { + dumpDuplicates(context.duplicates); + List> newDuplicatesList = new ArrayList>(); + for (Set duplicates : context.duplicates) { + Set newDuplicates = new HashSet(duplicates); + for (FullFunctionDeclaration f : duplicates) { + if (context.overrides.containsKey(f)) { + for (Set duplicates2 : context.duplicates) { + if (duplicates2.contains(context.overrides.get(f))) { + newDuplicates.addAll(duplicates2); + newDuplicatesList.remove(duplicates2); + } + } + } + } + newDuplicatesList.add(newDuplicates); + } + dumpDuplicates(newDuplicatesList); + + for (Set duplicates : newDuplicatesList) { + Map> nameMatrix = null; + // System.out.println("disambiguation for " + duplicates); + nameMatrix = calculateNames(duplicates, Strategy.USER_FRIENDLY); + dumpNameMatrix(nameMatrix); + if (hasDuplicate(nameMatrix)) { + // System.out.println("found duplicate!"); + nameMatrix = calculateNames(duplicates, Strategy.FULL); + dumpNameMatrix(nameMatrix); + } + applyDisambiguation(duplicates, nameMatrix); + } + } + + private void dumpNameMatrix(Map> nameMatrix) { + if (dump) { + System.out.println("Dumping name matrix:"); + for (Entry> e : nameMatrix.entrySet()) { + System.out.println("# " + e.getKey() + " ---> " + e.getValue()); + } + } + } + + private boolean hasDuplicate(Map> nameMatrix) { + Map> m = new HashMap>(nameMatrix); + for (FullFunctionDeclaration f : nameMatrix.keySet()) { + if (context.overridens.get(f) != null && m.containsKey(context.overridens.get(f))) { + m.remove(f); + } + } + // System.out.println("TESTING DUPLICATES ON:"); + // dumpNameMatrix(m); + List signatures = new ArrayList(); + for (List l : m.values()) { + String s = l.toString(); + if (signatures.contains(s)) { + return true; + } + signatures.add(s); + } + return false; + } + + private Map> calculateNames(Set duplicates, + Strategy strategy) { + Map> nameMatrix = new HashMap>(); + List l = new ArrayList(duplicates); + TypeDeclaration highestTypeDeclaration = getHighestSuperType(duplicates); + + for (int paramIndex = 0; paramIndex < l.get(0).function.getParameters().length; paramIndex++) { + final int i = paramIndex; + l.sort(new Comparator() { + @Override + public int compare(FullFunctionDeclaration f1, FullFunctionDeclaration f2) { + int diff = context.getShortTypeNameNoErasure(f1.function.getParameters()[i].getType()).length() + - context.getShortTypeNameNoErasure(f2.function.getParameters()[i].getType()).length(); + if (diff == 0) { + return context.getShortTypeNameNoErasure(f1.function.getParameters()[i].getType()) + .compareTo(context.getShortTypeNameNoErasure(f2.function.getParameters()[i].getType())); + } else { + return diff; + } + } + }); + + List names; + boolean functionalDisambiguation = isFunctionalTypeReference( + l.get(0).function.getParameters()[i].getType()); + if (functionalDisambiguation) { + if (!isFunctionalTypeReference(l.get(0).function.getParameters()[i].getType()) + || context.getShortTypeNameNoErasure(l.get(0).function.getParameters()[i].getType()) + .equals(context.getShortTypeNameNoErasure( + l.get(l.size() - 1).function.getParameters()[i].getType()))) { + // no erasure conflict comes form parameter i (by convention + // we set an empty name) + names = new ArrayList(Collections.nCopies(l.size(), NO_OVERRIDE)); + } else { + names = calculateNames(highestTypeDeclaration, strategy, functionalDisambiguation, l, + l.get(0).function, i); + } + } else { + if (context.getShortTypeNameNoErasure(l.get(0).function.getParameters()[i].getType()).equals( + context.getShortTypeNameNoErasure(l.get(l.size() - 1).function.getParameters()[i].getType()))) { + // no erasure conflict comes form parameter i (by convention + // we set an empty name) + names = new ArrayList(Collections.nCopies(l.size(), NO_OVERRIDE)); + } else { + names = calculateNames(highestTypeDeclaration, strategy, functionalDisambiguation, l, + l.get(0).function, i); + } + } + for (int j = 0; j < l.size(); j++) { + List paramNames = nameMatrix.get(l.get(j)); + if (paramNames == null) { + paramNames = new ArrayList(); + nameMatrix.put(l.get(j), paramNames); + } + paramNames.add(names.get(j)); + } + } + return nameMatrix; + } + + private void applyDisambiguation(Set duplicates, + Map> nameMatrix) { + TypeDeclaration highestTypeDeclaration = getHighestSuperType(duplicates); + List l = new ArrayList(duplicates); + for (int paramIndex = 0; paramIndex < l.get(0).function.getParameters().length; paramIndex++) { + final int i = paramIndex; + for (FullFunctionDeclaration f : l) { + String newTypeName = nameMatrix.get(f).get(i); + if (newTypeName == NO_OVERRIDE) { + continue; + } + + ParameterDeclaration parameter = f.function.getParameters()[i]; + TypeDeclaration newType = null; + boolean alreadyCreated = false; + + if (newType == null && (newType = highestTypeDeclaration.findType(newTypeName)) != null) { + alreadyCreated = true; + } + + boolean functionalDisambiguation = isFunctionalTypeReference( + l.get(0).function.getParameters()[i].getType()); + if (functionalDisambiguation) { + if (f.function.isConstructor()) { + if (!alreadyCreated) { + boolean hasResult = ((TypeDeclaration) parameter.getType().getDeclaration()).getName() + .contains("Function"); + newType = DeclarationHelper.createFunctionalType(newTypeName, + parameter.getType().getTypeArguments().length - (hasResult ? 1 : 0), hasResult, + true); + newType.addStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_ERASED); + highestTypeDeclaration.addMember(newType); + context.registerType(context.getTypeName(highestTypeDeclaration) + "." + newType.getName(), + newType); + } + parameter.setType(new TypeReference(null, newType, + DeclarationHelper.copyReferences(parameter.getType().getTypeArguments()))); + } else { + if (!f.function.hasStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_NAME)) { + f.function.addStringAnnotation( + JSweetDefTranslatorConfig.ANNOTATION_NAME + "(\"" + f.function.getName() + "\")"); + f.function.setName(f.function.getName() + newTypeName); + } else { + if (!StringUtils.isBlank(newTypeName)) { + f.function.setName(StringUtils.uncapitalize(f.function.getName()) + newTypeName); + } + } + } + } else { + TypeParameterDeclaration[] typeParameters = Util.findTypeParameters(this, parameter); + if (typeParameters.length == 0) { + typeParameters = null; + } + if (!alreadyCreated) { + FunctionDeclaration newConstructor = new FunctionDeclaration(null, "constructor", null, + new ParameterDeclaration[] { parameter.copy() }, null); + newType = new TypeDeclaration(null, "class", newTypeName, + DeclarationHelper.copy(typeParameters), null, new Declaration[] { newConstructor }); + newType.setDocumentation( + "/** This class was automatically generated for disambiguating erased method signatures. */"); + if (newType.getTypeParameters() != null) { + for (TypeParameterDeclaration t : newType.getTypeParameters()) { + t.setUpperBound(null); + } + } + newType.addModifier("static"); + newType.addStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_ERASED); + highestTypeDeclaration.addMember(newType); + context.registerType(context.getTypeName(highestTypeDeclaration) + "." + newType.getName(), + newType); + } + parameter.setType(new TypeReference(null, newType, DeclarationHelper.toReferences(typeParameters))); + } + + } + } + } + + private String resolveNameClash(boolean functionalDisambiguation, TypeDeclaration highestTypeDeclaration, + TypeReference parameterType, String newTypeName) { + TypeDeclaration resolved = highestTypeDeclaration.findType(newTypeName); + if (resolved == null) { + return newTypeName; + } else { + if (resolved.getTypeParameters() == null && parameterType.getTypeArguments() == null) { + return newTypeName; + } + if (!functionalDisambiguation) { + if (resolved.getTypeParameters() != null && parameterType.getTypeArguments() != null + && resolved.getTypeParameters().length == parameterType.getTypeArguments().length) { + return newTypeName; + } + FunctionDeclaration constructor = resolved.findFirstConstructor(); + if (constructor != null && constructor.getParameters() != null + && constructor.getParameters().length == 1 + && constructor.getParameters()[0].getType().equals(parameterType)) { + return newTypeName; + } + } else { + FunctionDeclaration apply = resolved + .findFirstFunction(JSweetDefTranslatorConfig.ANONYMOUS_FUNCTION_NAME); + if (apply != null && resolved.getTypeParameters() != null && parameterType.getTypeArguments() != null + && resolved.getTypeParameters().length == parameterType.getTypeArguments().length) { + if (parameterType.getName().endsWith("Consumer") && "void".equals(apply.getType().getName())) { + return newTypeName; + } + if (parameterType.getName().endsWith("Provider") && apply.getParameters().length == 0) { + return newTypeName; + } + if (parameterType.getName().endsWith("Function") && apply.getParameters().length > 0 + && !"void".equals(apply.getType().getName())) { + return newTypeName; + } + } + } + Map.Entry intSuffix = Util.splitIntSuffix(newTypeName); + if (intSuffix == null) { + return resolveNameClash(functionalDisambiguation, highestTypeDeclaration, parameterType, + newTypeName + 2); + } else { + return resolveNameClash(functionalDisambiguation, highestTypeDeclaration, parameterType, + intSuffix.getKey() + (intSuffix.getValue() + 1)); + } + + } + } + + private List calculateNames(TypeDeclaration highestTypeDeclaration, Strategy strategy, + boolean functionalDisambiguation, List l, FunctionDeclaration reference, + int paramIndex) { + List names = new ArrayList(); + switch (strategy) { + case USER_FRIENDLY: + if (functionalDisambiguation) { + // apply a diff strategy (more user friendly in some cases) + for (FullFunctionDeclaration f : l) { + String newInterfaceName = StringUtils.capitalize(reference.getParameters()[paramIndex].getName()) + + NameUtils.getDiff( + context.getShortTypeNameNoErasure(reference.getParameters()[paramIndex].getType()), + context.getShortTypeNameNoErasure( + f.function.getParameters()[paramIndex].getType())); + if (newInterfaceName.length() > MAX_NAME_LENGTH) { + newInterfaceName = StringUtils.capitalize(reference.getParameters()[paramIndex].getName()) + + names.size(); + } + TypeReference parameterType = reference.getParameters()[paramIndex].getType(); + if (parameterType.getName().contains("Consumer")) { + switch (parameterType.getTypeArguments().length) { + case 1: + newInterfaceName += "Consumer"; + break; + case 2: + newInterfaceName += "BiConsumer"; + break; + case 3: + newInterfaceName += "TriConsumer"; + break; + default: + newInterfaceName += "Consumer"; + newInterfaceName += parameterType.getTypeArguments().length; + break; + } + } + if (parameterType.getName().contains("Function")) { + switch (parameterType.getTypeArguments().length) { + case 2: + newInterfaceName += "Function"; + break; + case 3: + newInterfaceName += "BiFunction"; + break; + case 4: + newInterfaceName += "TriFunction"; + break; + default: + newInterfaceName += "Function"; + newInterfaceName += parameterType.getTypeArguments().length - 1; + break; + } + } + if (parameterType.getName().contains("Supplier")) { + newInterfaceName += "Supplier"; + } + // this naming convention seems to avoid all name clashes + // newInterfaceName = + // resolveNameClash(functionalDisambiguation, + // highestTypeDeclaration, + // f.function.getParameters()[paramIndex].getType(), + // newInterfaceName); + names.add(newInterfaceName); + } + } else { + for (FullFunctionDeclaration f : l) { + // TODO: the parameter happens to clash sometime (so full + // strategy from scratch until we find a better way) + // SEE: underscore: _._Chain.map(...) methods + // String newInterfaceName = + // StringUtils.capitalize(reference.getParameters()[paramIndex].getName()); + + String newInterfaceName = null; + if (DeclarationHelper.getTypeOrComponentType( + reference.getParameters()[paramIndex].getType()) instanceof TypeParameterDeclaration) { + newInterfaceName = StringUtils.capitalize(reference.getParameters()[paramIndex].getName()); + } else { + newInterfaceName = StringUtils.capitalize( + context.getShortTypeNameErased(reference.getParameters()[paramIndex].getType()) + .replace("[]", "s")); + } + if (f.function.getParameters()[paramIndex].getType().getTypeArguments() != null) { + for (TypeReference t : f.function.getParameters()[paramIndex].getType().getTypeArguments()) { + String[] tokens = context.getShortTypeNameNoErasure(t).split("[<>,]"); + for (String token : tokens) { + newInterfaceName += StringUtils.capitalize(token).replace("[]", "s"); + } + } + } else { + String[] tokens = context + .getShortTypeNameNoErasure(f.function.getParameters()[paramIndex].getType()) + .split("[<>,]"); + for (String token : tokens) { + newInterfaceName += StringUtils.capitalize(token).replace("[]", "s"); + } + } + if (newInterfaceName.length() > MAX_NAME_LENGTH) { + newInterfaceName = StringUtils.capitalize(reference.getParameters()[paramIndex].getName()) + + names.size(); + } + newInterfaceName = resolveNameClash(functionalDisambiguation, highestTypeDeclaration, + f.function.getParameters()[paramIndex].getType(), newInterfaceName); + names.add(newInterfaceName); + } + } + break; + case FULL: + // apply a whole name strategy + if (functionalDisambiguation) { + for (FullFunctionDeclaration f : l) { + String newInterfaceName = StringUtils.capitalize(reference.getParameters()[paramIndex].getName()); + if (f.function.getParameters()[paramIndex].getType().getTypeArguments() != null) { + for (TypeReference t : f.function.getParameters()[paramIndex].getType().getTypeArguments()) { + String[] tokens = context.getShortTypeNameNoErasure(t).split("[<>,]"); + for (String token : tokens) { + newInterfaceName += StringUtils.capitalize(token).replace("[]", "s"); + } + } + } else { + String[] tokens = context + .getShortTypeNameNoErasure(f.function.getParameters()[paramIndex].getType()) + .split("[<>,]"); + for (String token : tokens) { + newInterfaceName += StringUtils.capitalize(token).replace("[]", "s"); + } + } + if (newInterfaceName.length() > MAX_NAME_LENGTH) { + newInterfaceName = StringUtils.capitalize(reference.getParameters()[paramIndex].getName()) + + names.size(); + } + newInterfaceName = resolveNameClash(functionalDisambiguation, highestTypeDeclaration, + f.function.getParameters()[paramIndex].getType(), newInterfaceName); + names.add(newInterfaceName); + } + } else { + for (FullFunctionDeclaration f : l) { + String newInterfaceName = StringUtils + .capitalize(context.getShortTypeNameErased(reference.getParameters()[paramIndex].getType()) + .replace("[]", "s")); + if (f.function.getParameters()[paramIndex].getType().getTypeArguments() != null) { + for (TypeReference t : f.function.getParameters()[paramIndex].getType().getTypeArguments()) { + String[] tokens = context.getShortTypeNameNoErasure(t).split("[<>,]"); + for (String token : tokens) { + newInterfaceName += StringUtils.capitalize(token).replace("[]", "s"); + } + } + } else { + String[] tokens = context + .getShortTypeNameNoErasure(f.function.getParameters()[paramIndex].getType()) + .split("[<>,]"); + for (String token : tokens) { + newInterfaceName += StringUtils.capitalize(token).replace("[]", "s"); + } + } + if (newInterfaceName.length() > MAX_NAME_LENGTH) { + newInterfaceName = StringUtils.capitalize(reference.getParameters()[paramIndex].getName()) + + names.size(); + } + newInterfaceName = resolveNameClash(functionalDisambiguation, highestTypeDeclaration, + f.function.getParameters()[paramIndex].getType(), newInterfaceName); + names.add(newInterfaceName); + } + } + } + return names; + } + + private boolean isTypePresent(TypeDeclaration t, Set duplicates) { + if (t == null) { + return false; + } + for (FullFunctionDeclaration f : duplicates) { + if (t.equals(f.declaringType)) { + return true; + } + } + return false; + } + + private TypeDeclaration getHighestSuperType(Set duplicates) { + FullFunctionDeclaration first = duplicates.iterator().next(); + TypeDeclaration hightest = first.declaringType; + TypeDeclaration t = hightest; + while (t.getSuperTypes() != null && t.getSuperTypes().length > 0) { + TypeDeclaration st = (TypeDeclaration) lookupType(t.getSuperTypes()[0], null); + if (st == null) { + context.reportError("undefined type " + t.getSuperTypes()[0]); + } + if (isTypePresent(st, duplicates)) { + hightest = st; + } + t = st; + } + return hightest; + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/DynamicTypeParametersExpander.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/DynamicTypeParametersExpander.java new file mode 100644 index 00000000..91abe210 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/DynamicTypeParametersExpander.java @@ -0,0 +1,74 @@ +package org.jsweet.input.typescriptdef.visitor; + +import org.apache.commons.lang3.ArrayUtils; +import org.jsweet.input.typescriptdef.ast.ArrayTypeReference; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.DeclarationContainer; +import org.jsweet.input.typescriptdef.ast.DeclarationHelper; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.ParameterDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; + +/** + * + * + * @author Renaud Pawlak + */ +public class DynamicTypeParametersExpander extends Scanner { + + private int expandedParameterCount = 0; + + public DynamicTypeParametersExpander(Context context) { + super(context); + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + super.visitFunctionDeclaration(functionDeclaration); + DeclarationContainer container = getParent(DeclarationContainer.class); + if (container instanceof TypeDeclaration && ((TypeDeclaration) container).isFunctionalInterface()) { + // do not expand method signature if container is a functional + // interface + return; + } + + for (int i = functionDeclaration.getParameters().length - 1; i >= 0; i--) { + if (functionDeclaration.getParameters()[i].getType().getTypeArguments() != null + && functionDeclaration.getParameters()[i].getType().getTypeArguments().length == 1 + && context.arrayTypes.contains(lookupType(functionDeclaration.getParameters()[i].getType(), null))) { + expandedParameterCount++; + if (context.verbose) { + logger.debug("expanding dynamic type for: " + functionDeclaration); + } + FunctionDeclaration newFunction = new FunctionDeclaration(functionDeclaration.getToken(), + functionDeclaration.getName(), functionDeclaration.getType(), + DeclarationHelper.copy(functionDeclaration.getParameters()), + functionDeclaration.getTypeParameters()); + newFunction.setDocumentation(functionDeclaration.getDocumentation()); + newFunction.setModifiers(functionDeclaration.getModifiers()); + newFunction.getParameters()[i] = new ParameterDeclaration(null, + functionDeclaration.getParameters()[i].getName(), new ArrayTypeReference(null, + functionDeclaration.getParameters()[i].getType().getTypeArguments()[0]), + functionDeclaration.getParameters()[i].isOptional(), + functionDeclaration.getParameters()[i].isVarargs()); + if (!ArrayUtils.contains(container.getMembers(), newFunction)) { + container.addMember(newFunction); + } + } + } + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + } + + @Override + public void onScanEnded() { + if (expandedParameterCount > 0) { + logger.debug(expandedParameterCount + " parameter(s) expanded."); + } + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/EmptyConstructorAdder.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/EmptyConstructorAdder.java new file mode 100644 index 00000000..cd19bd25 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/EmptyConstructorAdder.java @@ -0,0 +1,58 @@ +package org.jsweet.input.typescriptdef.visitor; + +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.ParameterDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeMacroDeclaration; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; + +/** + * This scanner adds an empty protected constructor in classes that have + * non-empty constructors, so that subclasses can define constructors without + * having to explicitly invoke a superclass constructor. + * + * @author Renaud Pawlak + */ +public class EmptyConstructorAdder extends Scanner { + + public EmptyConstructorAdder(Context context) { + super(context); + } + + @Override + public void visitTypeDeclaration(TypeDeclaration typeDeclaration) { + boolean hasEmptyConstructor = false; + boolean hasNonEmptyConstructor = false; + for (FunctionDeclaration func : typeDeclaration.findConstructors()) { + if (func.isHidden()) { + continue; + } + if (func.getParameters().length == 0) { + hasEmptyConstructor = true; + } else { + hasNonEmptyConstructor = true; + } + } + if (hasNonEmptyConstructor && !hasEmptyConstructor) { + FunctionDeclaration constructor = new FunctionDeclaration(null, + FunctionDeclaration.NEW_FUNCTION_RESERVED_NAME, null, new ParameterDeclaration[0], null); + constructor.addModifier("protected"); + typeDeclaration.addMember(constructor); + } + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + } + + @Override + public void visitTypeMacro(TypeMacroDeclaration typeMacroDeclaration) { + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/EmptyModulesCleaner.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/EmptyModulesCleaner.java new file mode 100644 index 00000000..72ac5251 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/EmptyModulesCleaner.java @@ -0,0 +1,51 @@ +package org.jsweet.input.typescriptdef.visitor; + +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Declaration; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.ModuleDeclaration; +import org.jsweet.input.typescriptdef.ast.ReferenceDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeMacroDeclaration; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; + +/** + * This scanner hides the module that don't have visible members. + * + * @author Renaud Pawlak + */ +public class EmptyModulesCleaner extends Scanner { + + public EmptyModulesCleaner(Context context) { + super(context); + } + + @Override + public void visitModuleDeclaration(ModuleDeclaration moduleDeclaration) { + for (Declaration d : moduleDeclaration.getMembers()) { + if (!d.isHidden() && !(d instanceof ReferenceDeclaration)) { + super.visitModuleDeclaration(moduleDeclaration); + return; + } + } + moduleDeclaration.setHidden(true); + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + } + + @Override + public void visitTypeDeclaration(TypeDeclaration typeDeclaration) { + } + + @Override + public void visitTypeMacro(TypeMacroDeclaration typeMacroDeclaration) { + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FactoryMethodsCreator.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FactoryMethodsCreator.java new file mode 100644 index 00000000..e62733f3 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FactoryMethodsCreator.java @@ -0,0 +1,58 @@ +package org.jsweet.input.typescriptdef.visitor; + +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.Type; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; + +/** + * This scanner creates factory methods out of anonymous ones when they return a + * different type than the declaring type (otherwise, they are just + * constructors). + * + * @author Renaud Pawlak + */ +public class FactoryMethodsCreator extends Scanner { + + private int createdMethodCount = 0; + + public FactoryMethodsCreator(Context context) { + super(context); + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + if (!functionDeclaration.isAnonymous()) { + return; + } + TypeDeclaration declaringType = getParent(TypeDeclaration.class); + if (declaringType != null) { + if (!"any".equals(functionDeclaration.getType().getName())) { + Type t = lookupType(functionDeclaration.getType(), null); + if (t != declaringType) { + createdMethodCount++; + if (context.verbose) { + String location = functionDeclaration.getToken() == null ? "?" : functionDeclaration.getToken() + .getLocation(); + logger.debug("creating factory method at " + location); + functionDeclaration.setName("_create"); + } + } + } + } + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + } + + @Override + public void onScanEnded() { + if (createdMethodCount > 0) { + logger.debug(createdMethodCount + " factory method(s) created."); + } + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FieldTypeFunctionInjector.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FieldTypeFunctionInjector.java new file mode 100644 index 00000000..ba8f6cd8 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FieldTypeFunctionInjector.java @@ -0,0 +1,149 @@ +package org.jsweet.input.typescriptdef.visitor; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang3.ArrayUtils; +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Declaration; +import org.jsweet.input.typescriptdef.ast.DeclarationHelper; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.ParameterDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.Type; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeParameterDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; +import org.jsweet.input.typescriptdef.util.Util; + +public class FieldTypeFunctionInjector extends Scanner { + + public FieldTypeFunctionInjector(Context context) { + super(context); + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + + if ("constructor".equals(variableDeclaration.getName()) + || JSweetDefTranslatorConfig.ANONYMOUS_FUNCTION_NAME.equals(variableDeclaration.getName()) + || JSweetDefTranslatorConfig.NEW_FUNCTION_NAME.equals(variableDeclaration.getName())) { + return; + } + + Type type = lookupType(variableDeclaration.getType()); + boolean candidate = (type instanceof TypeDeclaration) && (getParent() instanceof TypeDeclaration); + + if (candidate) { + TypeDeclaration typeDeclaration = (TypeDeclaration) type; + TypeDeclaration parentTypeDeclaration = (TypeDeclaration) getParent(); + + if ("Function".equals(typeDeclaration.getName())) { + String typeName = context.getTypeName(typeDeclaration); + if ((JSweetDefTranslatorConfig.LANG_PACKAGE + ".Function").equals(typeName) + || "Function".equals(context.getLibRelativePath(context.getTypeName(typeDeclaration)))) { + FunctionDeclaration newFunction = new FunctionDeclaration(null, variableDeclaration.getName(), + new TypeReference(null, Object.class.getName(), null), + new ParameterDeclaration[] { new ParameterDeclaration(null, "args", + new TypeReference(null, Object.class.getName(), null), false, true) }, + null); + if (variableDeclaration.hasModifier("static")) { + newFunction.addModifier("static"); + } + if (variableDeclaration.getStringAnnotations() != null) { + newFunction.setStringAnnotations( + new ArrayList(variableDeclaration.getStringAnnotations())); + } + parentTypeDeclaration.addMember(newFunction); + } + return; + } + + for (Declaration d : typeDeclaration.getMembers()) { + if (d instanceof FunctionDeclaration && ((FunctionDeclaration) d).isAnonymous() + && !((FunctionDeclaration) d).hasModifier("static")) { + FunctionDeclaration anonymousFunction = (FunctionDeclaration) d; + FunctionDeclaration newFunction = new FunctionDeclaration(null, variableDeclaration.getName(), + anonymousFunction.getType().copy(), + DeclarationHelper.copy(anonymousFunction.getParameters()), + DeclarationHelper.copy(anonymousFunction.getTypeParameters())); + newFunction.setDocumentation(anonymousFunction.getDocumentation()); + if (variableDeclaration.hasModifier("static")) { + newFunction.addModifier("static"); + } + if (variableDeclaration.getStringAnnotations() != null) { + if (anonymousFunction.getStringAnnotations() != null) { + List annotations = new ArrayList( + variableDeclaration.getStringAnnotations()); + annotations.addAll(anonymousFunction.getStringAnnotations()); + newFunction.setStringAnnotations(annotations); + } else { + newFunction.setStringAnnotations( + new ArrayList(variableDeclaration.getStringAnnotations())); + } + } + // expand type references in the + // function since it is not always + // copied in the same module + new Scanner(this) { + @Override + public void visitTypeReference(TypeReference typeReference) { + Type t = null; + // created inner type case (object type for + // instance) + t = typeDeclaration.findType(typeReference.getName()); + if (t == null) { + t = lookupType(typeReference, context.getTypeModule(typeDeclaration)); + } + if (t instanceof TypeDeclaration) { + TypeDeclaration typeDeclaration = (TypeDeclaration) t; + String typeName = context.getTypeName(typeDeclaration); + if (!typeName.equals(typeReference.getName())) { + if (context.verbose) { + logger.debug("WARNING: rewriting type ref " + typeReference.getName() + " -> " + + typeName + " at " + + (getCurrentToken() == null ? "?" : getCurrentToken().getLocation())); + } + typeReference.setName(typeName); + } + } + } + }.visitFunctionDeclaration(newFunction); + // substitute type parameters + TypeParameterDeclaration[] usedTypeParametersInType = Util.findTypeParameters(context, + typeDeclaration, anonymousFunction); + String[] usedTypeParametersInFunction = Util.findTypeParameterNames(context, anonymousFunction, + anonymousFunction); + + if (usedTypeParametersInType.length > 0) { + Map typeMapping = new HashMap<>(); + for (TypeParameterDeclaration usedTypeParameter : usedTypeParametersInType) { + if (ArrayUtils.contains(usedTypeParametersInFunction, usedTypeParameter.getName())) { + // type parameter is hidden by local type + // parameter + continue; + } + int index = ArrayUtils.indexOf(typeDeclaration.getTypeParameters(), usedTypeParameter); + if (index >= 0) { + typeMapping.put(usedTypeParameter.getName(), + variableDeclaration.getType().getTypeArguments()[index]); + } + } + Util.subtituteTypeReferences(newFunction, typeMapping); + } + parentTypeDeclaration.addMember(newFunction); + } + } + } + + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ForEachClashRemover.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ForEachClashRemover.java new file mode 100644 index 00000000..7796febe --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ForEachClashRemover.java @@ -0,0 +1,46 @@ +package org.jsweet.input.typescriptdef.visitor; + +import java.util.function.Consumer; + +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.Type; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeMacroDeclaration; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; + +/** + * Very specific case for JavaScript Array. Will not be necessary if we switch + * to Peter's technique. + * + * @author Renaud Pawlak + */ +public class ForEachClashRemover extends Scanner { + + public ForEachClashRemover(Context context) { + super(context); + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + if ("forEach".equals(functionDeclaration.getName()) && functionDeclaration.getParameters().length == 1) { + Type t = functionDeclaration.getParameters()[0].getType().getDeclaration(); + if (t instanceof TypeDeclaration + && Consumer.class.getName().equals(context.getTypeName((TypeDeclaration) t))) { + functionDeclaration.getParameters()[0].getType() + .setName(JSweetDefTranslatorConfig.FUNCTION_CLASSES_PACKAGE + ".Consumer"); + } + } + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + } + + @Override + public void visitTypeMacro(TypeMacroDeclaration typeMacroDeclaration) { + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FunctionKindAdapter.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FunctionKindAdapter.java new file mode 100644 index 00000000..feaa9946 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FunctionKindAdapter.java @@ -0,0 +1,49 @@ +package org.jsweet.input.typescriptdef.visitor; + +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; + +public class FunctionKindAdapter extends Scanner { + + public FunctionKindAdapter(Context context) { + super(context); + } + + boolean isInInterface = false; + + @Override + public void visitTypeDeclaration(TypeDeclaration typeDeclaration) { + isInInterface = "interface".equals(typeDeclaration.getKind()) + || typeDeclaration.hasStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_INTERFACE); + super.visitTypeDeclaration(typeDeclaration); + isInInterface = false; + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + if (!(getParent() instanceof TypeDeclaration)) { + return; + } + final TypeDeclaration parent = (TypeDeclaration) getParent(); + if (functionDeclaration.isConstructor() && isInInterface) { + functionDeclaration.addModifier("native"); + functionDeclaration.setName(JSweetDefTranslatorConfig.NEW_FUNCTION_NAME); + if (functionDeclaration.getType() == null) { + functionDeclaration.setType(new TypeReference(null, parent, null)); + } + } else if (JSweetDefTranslatorConfig.ANONYMOUS_FUNCTION_NAME.equals(functionDeclaration.getName()) + && functionDeclaration.hasModifier("static")) { + functionDeclaration.setName(JSweetDefTranslatorConfig.ANONYMOUS_STATIC_FUNCTION_NAME); + } + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FunctionTypeOfReplacer.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FunctionTypeOfReplacer.java new file mode 100644 index 00000000..3a20febc --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FunctionTypeOfReplacer.java @@ -0,0 +1,45 @@ +package org.jsweet.input.typescriptdef.visitor; + +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.DeclarationContainer; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.QualifiedDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeMacroDeclaration; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; + +public class FunctionTypeOfReplacer extends Scanner { + + public FunctionTypeOfReplacer(Context context) { + super(context); + } + + public FunctionTypeOfReplacer(Scanner parentScanner) { + super(parentScanner); + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + if (variableDeclaration.getType().isTypeOf()) { + QualifiedDeclaration function = lookupFunctionDeclaration( + variableDeclaration.getType().getName()); + if (function != null) { + DeclarationContainer container = getParent(DeclarationContainer.class); + container.removeMember(variableDeclaration); + FunctionDeclaration f = function.getDeclaration().copy(); + f.setName(variableDeclaration.getName()); + container.addMember(f); + } + } + super.visitVariableDeclaration(variableDeclaration); + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + } + + @Override + public void visitTypeMacro(TypeMacroDeclaration typeMacroDeclaration) { + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FunctionalInterfacesCreator.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FunctionalInterfacesCreator.java new file mode 100644 index 00000000..5676d418 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FunctionalInterfacesCreator.java @@ -0,0 +1,193 @@ +package org.jsweet.input.typescriptdef.visitor; + +import static org.jsweet.JSweetDefTranslatorConfig.FUNCTION_CLASSES_PACKAGE; + +import java.util.function.BiConsumer; +import java.util.function.BiFunction; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; + +import org.apache.commons.lang3.ArrayUtils; +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.ast.ArrayTypeReference; +import org.jsweet.input.typescriptdef.ast.CompilationUnit; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Declaration; +import org.jsweet.input.typescriptdef.ast.DeclarationContainer; +import org.jsweet.input.typescriptdef.ast.DeclarationHelper; +import org.jsweet.input.typescriptdef.ast.FunctionalTypeReference; +import org.jsweet.input.typescriptdef.ast.ModuleDeclaration; +import org.jsweet.input.typescriptdef.ast.ParameterDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.Type; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeParameterDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.ast.TypedDeclaration; +import org.jsweet.input.typescriptdef.util.Util; + +public class FunctionalInterfacesCreator extends Scanner { + + public static final String RUNNABLE = Runnable.class.getName(); + public static final String SUPPLIER = Supplier.class.getName(); + public static final String FUNCTION = Function.class.getName(); + public static final String BI_FUNCTION = BiFunction.class.getName(); + public static final String TRI_FUNCTION = FUNCTION_CLASSES_PACKAGE + ".TriFunction"; + public static final String CONSUMER = Consumer.class.getName(); + public static final String BI_CONSUMER = BiConsumer.class.getName();; + public static final String TRI_CONSUMER = FUNCTION_CLASSES_PACKAGE + ".TriConsumer"; + + public FunctionalInterfacesCreator(Context context) { + super(context); + } + + @Override + public void visitFunctionalTypeReference(FunctionalTypeReference functionalTypeReference) { + super.visitFunctionalTypeReference(functionalTypeReference); + substituteTypeParameters(functionalTypeReference); + + DeclarationContainer container = getParent(DeclarationContainer.class); + if (container instanceof TypeDeclaration) { + if ("interface".equals(((TypeDeclaration) container).getKind())) { + container = getParent(DeclarationContainer.class, container); + } + } + TypedDeclaration currentTypedElement = getParent(TypedDeclaration.class); + ParameterDeclaration lastParam = functionalTypeReference.getParameters().length == 0 ? null + : functionalTypeReference.getParameters()[functionalTypeReference.getParameters().length - 1]; + if (lastParam != null && lastParam.isVarargs()) { + ParameterDeclaration[] parameters = DeclarationHelper.copy(functionalTypeReference.getParameters()); + parameters[parameters.length - 1] + .setType(((ArrayTypeReference) parameters[parameters.length - 1].getType()).getComponentType()); + replaceFunctionnalType(container, currentTypedElement, functionalTypeReference, parameters, + functionalTypeReference.getReturnType()); + } else { + replaceFunctionnalType(container, currentTypedElement, functionalTypeReference, + functionalTypeReference.getParameters(), functionalTypeReference.getReturnType()); + } + } + + private void substituteTypeParameters(final FunctionalTypeReference functionalTypeReference) { + if (functionalTypeReference.getTypeParameters() != null) { + new Scanner(context) { + @Override + public void visitTypeReference(TypeReference typeReference) { + Type t = lookupType(typeReference); + if (t instanceof TypeParameterDeclaration) { + typeReference.setDeclaration(null); + TypeReference upperBound = ((TypeParameterDeclaration) t).getUpperBound(); + if (upperBound != null) { + typeReference.setName(upperBound.getName()); + if (upperBound.getTypeArguments() != null) { + typeReference.setTypeArguments(DeclarationHelper.copyReferences(upperBound + .getTypeArguments())); + } + } else { + typeReference.setName("any"); + } + } + super.visitTypeReference(typeReference); + } + }.scan(functionalTypeReference); + ; + } + } + + private void replaceFunctionnalType(DeclarationContainer container, TypedDeclaration currentTypedElement, + TypeReference currentType, ParameterDeclaration[] parameters, TypeReference returnType) { + if (parameters.length <= 3) { + TypeReference functionType = new TypeReference(null, "unamed", null); + if (!"void".equals(returnType.getName())) { + switch (parameters.length) { + case 0: + functionType.setName(SUPPLIER); + functionType.setTypeArguments(new TypeReference[] { returnType }); + break; + case 1: + functionType.setName(FUNCTION); + functionType.setTypeArguments(new TypeReference[] { parameters[0].getType(), returnType }); + break; + case 2: + functionType.setName(BI_FUNCTION); + functionType.setTypeArguments(new TypeReference[] { parameters[0].getType(), + parameters[1].getType(), returnType }); + break; + case 3: + functionType.setName(TRI_FUNCTION); + functionType.setTypeArguments(new TypeReference[] { parameters[0].getType(), + parameters[1].getType(), parameters[2].getType(), returnType }); + break; + } + } else { + switch (parameters.length) { + case 0: + functionType.setName(RUNNABLE); + break; + case 1: + functionType.setName(CONSUMER); + functionType.setTypeArguments(new TypeReference[] { parameters[0].getType() }); + break; + case 2: + functionType.setName(BI_CONSUMER); + functionType.setTypeArguments(new TypeReference[] { parameters[0].getType(), + parameters[1].getType() }); + break; + case 3: + functionType.setName(TRI_CONSUMER); + functionType.setTypeArguments(new TypeReference[] { parameters[0].getType(), + parameters[1].getType(), parameters[2].getType() }); + break; + } + } + Util.substituteTypeReference(this, currentTypedElement, currentType, functionType); + } else { + // TODO: generate functions with more than 3 parameters in the + // util.function package so that we don't loose override links. + // At the moment we choose not to support functions with more than 3 + // parameteres + + TypeDeclaration t = getOrCreateFunctionalType(parameters, returnType); + + TypeReference[] typeArgs = new TypeReference[parameters.length]; + for (int i = 0; i < parameters.length; i++) { + typeArgs[i] = parameters[i].getType(); + } + if (!"void".equals(returnType.getName())) { + typeArgs = ArrayUtils.add(typeArgs, returnType); + } + + Util.substituteTypeReference(this, currentTypedElement, currentType, new TypeReference(null, t, typeArgs)); + + // // recursively apply to the generated functional interface + // scan(newInterface); + } + } + + private TypeDeclaration getOrCreateFunctionalType(ParameterDeclaration[] parameters, TypeReference returnType) { + CompilationUnit cu = getParent(CompilationUnit.class); + ModuleDeclaration m = getOrCreateModule(cu, JSweetDefTranslatorConfig.UTIL_PACKAGE); + m = getOrCreateModule(m, "function"); + boolean hasResult = !"void".equals(returnType.getName()); + String name = (hasResult ? "Function" : "Consumer") + parameters.length; + TypeDeclaration functionalType = m.findType(name); + if (functionalType == null) { + functionalType = DeclarationHelper.createFunctionalType(name, parameters.length, hasResult, false); + m.addMember(functionalType); + context.registerType(JSweetDefTranslatorConfig.UTIL_PACKAGE + ".function." + functionalType.getName(), functionalType); + // recursively apply to the generated functional interface + // scan(newInterface); + } + return functionalType; + } + + private ModuleDeclaration getOrCreateModule(DeclarationContainer container, String name) { + ModuleDeclaration m = DeclarationHelper.findModule(container, name); + if (m == null) { + m = new ModuleDeclaration(null, name, new Declaration[0]); + container.addMember(m); + } + return m; + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FunctionalParametersExpander.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FunctionalParametersExpander.java new file mode 100644 index 00000000..21ce6ef5 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/FunctionalParametersExpander.java @@ -0,0 +1,44 @@ +package org.jsweet.input.typescriptdef.visitor; + +import org.apache.commons.lang3.ArrayUtils; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.DeclarationContainer; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.FunctionalTypeReference; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; + +public class FunctionalParametersExpander extends Scanner { + + public FunctionalParametersExpander(Context context) { + super(context); + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + super.visitFunctionDeclaration(functionDeclaration); + DeclarationContainer container = getParent(DeclarationContainer.class); + expandFunctionalParameters(container, functionDeclaration); + } + + private void expandFunctionalParameters(DeclarationContainer container, FunctionDeclaration functionDeclaration) { + for (int i = functionDeclaration.getParameters().length - 1; i >= 0; i--) { + if (functionDeclaration.getParameters()[i].getType() instanceof FunctionalTypeReference) { + FunctionalTypeReference p = (FunctionalTypeReference) functionDeclaration.getParameters()[i].getType(); + if ("any".equals(p.getReturnType().getName())) { + FunctionDeclaration newFunction = functionDeclaration.copy(); + ((FunctionalTypeReference) newFunction.getParameters()[i].getType()).getReturnType().setName("void"); + if (!ArrayUtils.contains(container.getMembers(), newFunction)) { + container.addMember(newFunction); + expandFunctionalParameters(container, newFunction); + } + } + } + } + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/GlobalsCreator.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/GlobalsCreator.java new file mode 100644 index 00000000..388c99d0 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/GlobalsCreator.java @@ -0,0 +1,72 @@ +package org.jsweet.input.typescriptdef.visitor; + +import static org.jsweet.input.typescriptdef.util.Util.getOrCreateGlobalsType; + +import org.apache.commons.lang3.StringUtils; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Declaration; +import org.jsweet.input.typescriptdef.ast.DeclarationHelper; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.ModuleDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.Type; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; + +public class GlobalsCreator extends Scanner { + + public GlobalsCreator(Context context) { + super(context); + } + + @Override + public void visitModuleDeclaration(ModuleDeclaration moduleDeclaration) { + for (Declaration declaration : moduleDeclaration.getMembers()) { + if (declaration.isHidden()) { + continue; + } + if ((declaration instanceof VariableDeclaration) || (declaration instanceof FunctionDeclaration)) { + TypeDeclaration globalsClass = getOrCreateGlobalsType(context, moduleDeclaration, + getParent(ModuleDeclaration.class)); + if (DeclarationHelper.JS_OBJECT_METHOD_NAMES.contains(declaration.getName())) { + declaration.setName(StringUtils.capitalize(declaration.getName())); + } + moduleDeclaration.removeMember(declaration); + if (declaration instanceof VariableDeclaration) { + VariableDeclaration existing = globalsClass.findVariable(declaration.getName()); + if (existing != null && !existing.isHidden()) { + context.reportWarning("skip variable " + declaration + " - already exists in " + + moduleDeclaration + " (" + existing + ")"); + // variable already exists + continue; + } + } + globalsClass.addMember(declaration); + declaration.addModifier("static"); + if (declaration instanceof VariableDeclaration) { + VariableDeclaration varDecl = (VariableDeclaration) declaration; + Type t = lookupType(varDecl.getType(), null); + if (t instanceof TypeDeclaration) { + final TypeDeclaration typeDeclaration = (TypeDeclaration) t; + if (!typeDeclaration.isExternal() && typeDeclaration.isStatic()) { + globalsClass.removeMember(declaration); + } + } + } + } + } + super.visitModuleDeclaration(moduleDeclaration); + } + + @Override + public void visitTypeDeclaration(TypeDeclaration typeDeclaration) { + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + } +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ImportedAndExportedReferenceExpander.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ImportedAndExportedReferenceExpander.java new file mode 100644 index 00000000..741e0485 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ImportedAndExportedReferenceExpander.java @@ -0,0 +1,504 @@ +package org.jsweet.input.typescriptdef.visitor; + +import java.io.File; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.ast.AstNode; +import org.jsweet.input.typescriptdef.ast.CompilationUnit; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Declaration; +import org.jsweet.input.typescriptdef.ast.DeclarationContainer; +import org.jsweet.input.typescriptdef.ast.DeclarationHelper; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.ModuleDeclaration; +import org.jsweet.input.typescriptdef.ast.QualifiedDeclaration; +import org.jsweet.input.typescriptdef.ast.ReferenceDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; +import org.jsweet.input.typescriptdef.util.Util; + +/** + * This scanner expands the imported / exported references to anything declared. + * + * @author Louis Grignon + * @author Renaud Pawlak + */ +public class ImportedAndExportedReferenceExpander extends Scanner { + + private int referencesCount = 0; + private QualifiedDeclaration[] containerScope; + private boolean importMode = false; + + public ImportedAndExportedReferenceExpander(Context context, boolean importMode) { + super(context); + this.importMode = importMode; + } + + public ImportedAndExportedReferenceExpander(Context context, + QualifiedDeclaration[] containerScope, boolean importMode) { + super(context); + this.containerScope = containerScope; + logger.trace("searching imports in " + Arrays.asList(containerScope)); + this.importMode = importMode; + } + + /** + * Overrides the default implementation because we intend to pass this + * scanner before the packages reorganization. + */ + @Override + protected QualifiedDeclaration lookupModuleDeclaration(String name) { + for (int i = 0; i < getStack().size(); i++) { + String containerName = getContainerNameAtIndex(i); + String declFullName = StringUtils.isBlank(containerName) ? name : containerName + "." + name; + // first search in the current compilation unit + List> matches = context.findDeclarations(ModuleDeclaration.class, + declFullName, (CompilationUnit) getRoot()); + for (QualifiedDeclaration m : matches) { + if (!m.getDeclaration().isQuotedName()) { + return m; + } + } + for (QualifiedDeclaration m : matches) { + return m; + } + } + for (int i = 0; i < getStack().size(); i++) { + String containerName = getContainerNameAtIndex(i); + String declFullName = StringUtils.isBlank(containerName) ? name : containerName + "." + name; + // search in all compilation units + List> matches = context.findDeclarations(ModuleDeclaration.class, + declFullName); + for (QualifiedDeclaration m : matches) { + if (!m.getDeclaration().isQuotedName()) { + return m; + } + } + for (QualifiedDeclaration m : matches) { + return m; + } + } + return null; + } + + /** + * Overrides the default implementation because we intend to pass this + * scanner before the packages reorganization. + */ + @Override + protected QualifiedDeclaration lookupTypeDeclaration(String name) { + for (int i = 0; i < getStack().size(); i++) { + String containerName = getContainerNameAtIndex(i); + String declFullName = StringUtils.isBlank(containerName) ? name : containerName + "." + name; + // first search in the current compilation unit + QualifiedDeclaration match = context.findFirstDeclaration(TypeDeclaration.class, + declFullName, (CompilationUnit) getRoot()); + if (match != null) { + return match; + } + // search in all compilation units + match = context.findFirstDeclaration(TypeDeclaration.class, declFullName); + if (match != null) { + return match; + } + } + return null; + } + + private boolean isInContainerScope(QualifiedDeclaration declaration) { + if (containerScope == null) { + return false; + } + for (QualifiedDeclaration d : containerScope) { + if (declaration.getDeclaration() == d.getDeclaration()) { + return true; + } + } + return false; + } + + @Override + public void visitReferenceDeclaration(ReferenceDeclaration referenceDeclaration) { + if (referenceDeclaration.isExport() && importMode) { + return; + } + if (referenceDeclaration.isImport() && !importMode) { + return; + } + + if (containerScope != null) { + for (QualifiedDeclaration d : containerScope) { + if (!isInScope(d.getDeclaration())) { + return; + } + } + } + logger.debug("analysing reference: " + getParent(CompilationUnit.class) + "->" + referenceDeclaration); + + DeclarationContainer container = (DeclarationContainer) getParent(); + DeclarationContainer parentContainer = getParent(DeclarationContainer.class, container); + QualifiedDeclaration foreignDeclaration = lookupModuleDeclaration( + referenceDeclaration.getReferencedName()); + if (foreignDeclaration == null) { + foreignDeclaration = lookupTypeDeclaration(referenceDeclaration.getReferencedName()); + } + if (foreignDeclaration == null) { + foreignDeclaration = lookupFunctionDeclaration(referenceDeclaration.getReferencedName()); + } + if (foreignDeclaration == null) { + foreignDeclaration = lookupVariableDeclaration(referenceDeclaration.getReferencedName()); + } + if (foreignDeclaration != null) { + if (isInContainerScope(foreignDeclaration)) { + return; + } + logger.trace((containerScope == null ? "" : "(scope=" + Arrays.asList(containerScope) + ") ") + + "reference found: " + getCurrentContainerName() + "->" + referenceDeclaration + " references => " + + foreignDeclaration); + + // resolve foreign import first + if (foreignDeclaration.getDeclaration() instanceof DeclarationContainer) { + logger.trace("looking into context for " + foreignDeclaration.getQualifiedDeclarationName()); + + ImportedAndExportedReferenceExpander subScanner = new ImportedAndExportedReferenceExpander(context, + ArrayUtils.add(containerScope, foreignDeclaration), this.importMode); + subScanner.scan(context.compilationUnits); + } + + // TODO: this part contains a lot of code duplication (function/var) + // because the development is very experimental... consolidate at + // some point... + + if (referenceDeclaration.isExport()) { + + String foreignLib = Util.getLibPackageNameFromTsDefFile( + new File(foreignDeclaration.getDeclaration().getToken().getFileName())); + String currentLib = Util + .getLibPackageNameFromTsDefFile(new File(((AstNode) container).getToken().getFileName())); + boolean externalReference = !foreignLib.equals(currentLib); + + // FUNCTION or VARIABLE case + if (foreignDeclaration.getDeclaration() instanceof FunctionDeclaration + || foreignDeclaration.getDeclaration() instanceof VariableDeclaration) { + Declaration declaration = foreignDeclaration.getDeclaration(); + if (((Declaration) container).isQuotedName()) { + if (!declaration.hasStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_MODULE)) { + declaration.addStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_MODULE + "(\"" + + ((Declaration) container).getOriginalName() + "\")"); + } + } + Declaration copy = declaration.copy(); + if (getParent(2) instanceof DeclarationContainer) { + copy.setName(((Declaration) container).getName()); + ((DeclarationContainer) getParent(2)).addMember(copy); + logger.info("added member " + copy + " to " + (DeclarationContainer) getParent(2)); + rewriteTypeReferences(getCurrentContainerName(), copy); + // make target container external if necessary + if (((Declaration) container).isQuotedName()) { + if (container.findDeclaration(foreignDeclaration.getDeclaration()) != null) { + declaration.setHidden(true); + } + } + } else { + copy.setName(JSweetDefTranslatorConfig.ANONYMOUS_FUNCTION_NAME); + container.addMember(copy); + logger.info("added member " + copy + " to " + container); + + // if function is internal, we assume the actual + // function to + // export is the one that belongs to container + if (!externalReference) { + foreignDeclaration.getDeclaration().setHidden(true); + } + } + return; + } + + // HEURISTIC: when the exported element is not in the same + // lib, then is it external and it should not be exported + if (externalReference) { + return; + } + + // CONTAINER CASE: add members to container directly + + DeclarationContainer foreignDeclarationContainer = (DeclarationContainer) foreignDeclaration + .getDeclaration(); + String name = ((Declaration) container).getName(); + if (((Declaration) container).isQuotedName()) { + if (!foreignDeclaration.getDeclaration() + .hasStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_MODULE)) { + foreignDeclaration.getDeclaration() + .addStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_MODULE + "(\"" + + ((Declaration) container).getOriginalName() + "\")"); + } + } + + boolean exportInnerNamespace = container.findDeclaration(foreignDeclaration.getDeclaration()) != null; + if ((name.equals(foreignDeclaration.getDeclaration().getName()) || (!exportInnerNamespace) + || (container == foreignDeclarationContainer + && foreignDeclaration.getDeclaration().isQuotedName()))) { + // useless self exporting (quoted module export non quoted + // module of the same name) + // referenceDeclaration.setHidden(true); + // return; + } else { + + logger.info("adding " + foreignDeclarationContainer + " members to " + container + " / " + + getCurrentContainerName()); + if (foreignDeclarationContainer instanceof ModuleDeclaration) { + if (container.findDeclaration(foreignDeclaration.getDeclaration()) != null) { + foreignDeclarationContainer.setHidden(true); + } + } + container.addMembers(DeclarationHelper.copy(foreignDeclarationContainer.getMembers())); + // absolute path redirector + new TypeReferenceRedirector(foreignDeclaration, foreignDeclaration.getQualifiedDeclarationName(), + StringUtils.isBlank(getCurrentContainerName()) ? referenceDeclaration.getName() + : getCurrentContainerName()).scan(container); + // relative path + if (foreignDeclaration.getQualifiedDeclarationName().startsWith(name + ".")) { + new TypeReferenceRedirector(foreignDeclaration, + foreignDeclaration.getQualifiedDeclarationName().substring(name.length() + 1), "") + .scan(container); + } + } + + foreignDeclarationContainer = findContainer(foreignDeclaration); + + // deal with functions and variables + List functions = foreignDeclarationContainer + .findFunctions(foreignDeclaration.getDeclaration().getName()); + + for (FunctionDeclaration function : functions) { + if (function.isHidden()) { + continue; + } + if (((Declaration) container).isQuotedName()) { + if (!function.hasStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_MODULE)) { + function.addStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_MODULE + "(\"" + + ((Declaration) container).getOriginalName() + "\")"); + } + } + if (exportInnerNamespace) { + logger.debug("renaming function: " + function + " -> " + name); + function.setName(name); + } + if (getParent(2) instanceof DeclarationContainer) { + FunctionDeclaration functionCopy = function.copy(); + ((DeclarationContainer) getParent(2)).addMember(functionCopy); + if (exportInnerNamespace) { + function.setHidden(true); + } + rewriteTypeReferences(getCurrentContainerName(), functionCopy); + } + } + // TODO: check if this case actually happens (but there is no + // reasons why it shouldn't) + VariableDeclaration var = foreignDeclarationContainer + .findVariable(foreignDeclaration.getDeclaration().getName()); + if (var != null && !var.isHidden()) { + if (((Declaration) container).isQuotedName()) { + if (!var.hasStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_MODULE)) { + var.addStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_MODULE + "(\"" + + ((Declaration) container).getOriginalName() + "\")"); + } + } + if (exportInnerNamespace) { + logger.debug("renaming variable: " + var + " -> " + name); + var.setName(name); + } + if (getParent(2) instanceof DeclarationContainer) { + VariableDeclaration varCopy = var.copy(); + ((DeclarationContainer) getParent(2)).addMember(varCopy); + if (exportInnerNamespace) { + var.setHidden(true); + } + rewriteTypeReferences(getCurrentContainerName(), varCopy); + } + } + + } else { + + referenceDeclaration.setName(Util.toJavaName(referenceDeclaration.getName())); + // we must do the job in all compilation units + @SuppressWarnings({ "rawtypes", "unchecked" }) + List> declarations = (List) context.findDeclarations( + foreignDeclaration.getDeclaration().getClass(), + foreignDeclaration.getQualifiedDeclarationName()); + for (QualifiedDeclaration declaration : declarations) { + // HEURISTIC: if the import imports a module in the same + // container, then it is a way to make the module public... + // so we just rename the module. + String modName = declaration.getQualifier(); + Declaration d = declaration.getDeclaration(); + if (parentContainer == null || getCurrentContainerName().equals(modName == null ? "" : modName)) { + if (d != null && d instanceof ModuleDeclaration && !d.isQuotedName()) { + logger.info("renaming module: " + d + " -> " + referenceDeclaration.getName() + " (" + + referenceDeclaration.getLocation() + ")"); + for (Declaration currentDecl : container.getMembers()) { + if (currentDecl.isQuotedName() && d.getName().equals(currentDecl.getName())) { + if (d.isQuotedName()) { + d.setOriginalName(d.getOriginalName()); + break; + } + } + } + d.setName(referenceDeclaration.getName()); + new TypeReferenceRedirector(null, foreignDeclaration.getQualifiedDeclarationName(), + StringUtils.isBlank(getCurrentContainerName()) ? referenceDeclaration.getName() + : getCurrentContainerName() + "." + referenceDeclaration.getName()) + .scan(context.compilationUnits); + } + } else { + if (!declaration.getDeclaration().getName().equals(referenceDeclaration.getName())) { + logger.info("substituting " + referenceDeclaration.getName() + " -> " + declaration + " (" + + referenceDeclaration.getLocation() + ")"); + // redirect global members in parent modules + // (because global functions are moved there) + List declarationsToProcess = Arrays.asList(parentContainer.getMembers()) + .stream().filter(d2 -> { + return d2 == container || !(d2 instanceof ModuleDeclaration); + }).collect(Collectors.toList()); + // qualified + new TypeReferenceRedirector(foreignDeclaration, + StringUtils.isBlank(getCurrentContainerName()) ? referenceDeclaration.getName() + : getCurrentContainerName() + "." + referenceDeclaration.getName(), + foreignDeclaration.getQualifiedDeclarationName()).scan(declarationsToProcess); + // not qualified + new TypeReferenceRedirector(foreignDeclaration, referenceDeclaration.getName(), + foreignDeclaration.getQualifiedDeclarationName()).scan(declarationsToProcess); + } + } + } + + } + + referencesCount++; + } else { + logger.warn("referenced declaration not found in " + getCurrentContainerName() + ": " + + referenceDeclaration.getReferencedName()); + } + + container.removeMember(referenceDeclaration); + } + + private DeclarationContainer findContainer(QualifiedDeclaration foreignDeclaration) { + if (!foreignDeclaration.getQualifiedDeclarationName().contains(".")) { + return (DeclarationContainer) getStack().get(0); + } else { + String name = foreignDeclaration.getQualifier(); + List> modules = context.findDeclarations(ModuleDeclaration.class, + name); + for (QualifiedDeclaration m : modules) { + if (ArrayUtils.contains(m.getDeclaration().getMembers(), foreignDeclaration.getDeclaration())) { + return m.getDeclaration(); + } + } + return null; + } + } + + private void rewriteTypeReferences(String initialContainerName, Declaration declaration) { + TypeReferenceRewriter rewriter = new TypeReferenceRewriter(context, initialContainerName); + rewriter.scan(declaration); + } + + @Override + public void onScanEnded() { + // if main pass handled results + if (containerScope == null && referencesCount > 0) { + logger.debug(referencesCount + " imported reference(s) expanded."); + } + } + + public static class TypeReferenceRedirector extends Scanner { + + private static Logger logger = Logger.getLogger(TypeReferenceRedirector.class); + private QualifiedDeclaration initialDeclaration; + private String sourcePrefix; + private String targetPrefix; + + public TypeReferenceRedirector(QualifiedDeclaration initialDeclaration, + String sourcePrefix, String targetPrefix) { + super((Context) null); + logger.info(sourcePrefix + " -> " + targetPrefix); + this.initialDeclaration = initialDeclaration; + this.sourcePrefix = sourcePrefix; + this.targetPrefix = targetPrefix; + } + + @Override + public void visitModuleDeclaration(ModuleDeclaration moduleDeclaration) { + if (initialDeclaration == null || moduleDeclaration != initialDeclaration.getDeclaration()) { + super.visitModuleDeclaration(moduleDeclaration); + } + } + + @Override + public void visitTypeDeclaration(TypeDeclaration typeDeclaration) { + if (initialDeclaration == null || typeDeclaration != initialDeclaration.getDeclaration()) { + super.visitTypeDeclaration(typeDeclaration); + } + } + + @Override + public void visitTypeReference(TypeReference typeReference) { + if (typeReference.getName() != null && typeReference.getName().startsWith(sourcePrefix + ".")) { + typeReference.setDeclaration(null); + String newName = typeReference.getName().replaceFirst(sourcePrefix + ".", + StringUtils.isBlank(targetPrefix) ? "" : targetPrefix + "."); + logger.debug("redirecting type reference: " + typeReference.getName() + " -> " + newName); + typeReference.setName(newName); + } + super.visitTypeReference(typeReference); + } + + @Override + public void visitReferenceDeclaration(ReferenceDeclaration referenceDeclaration) { + if (referenceDeclaration.isImport() && referenceDeclaration.getReferencedName() != null + && referenceDeclaration.getReferencedName().startsWith(sourcePrefix + ".")) { + String newName = referenceDeclaration.getReferencedName().replaceFirst(sourcePrefix + ".", + StringUtils.isBlank(targetPrefix) ? "" : targetPrefix + "."); + logger.debug("redirecting reference declaration: " + referenceDeclaration.getReferencedName() + " -> " + + newName); + referenceDeclaration.setReferencedName(newName); + } + super.visitReferenceDeclaration(referenceDeclaration); + } + + } + + public static class TypeReferenceRewriter extends Scanner { + + private static Logger logger = Logger.getLogger(TypeReferenceRedirector.class); + private String initialContainerName; + + public TypeReferenceRewriter(Context context, String initialContainerName) { + super((Context) context); + this.initialContainerName = initialContainerName; + } + + @Override + public void visitTypeReference(TypeReference typeReference) { + QualifiedDeclaration declaration = context.findFirstDeclaration(TypeDeclaration.class, + initialContainerName + "." + typeReference); + if (declaration != null) { + logger.debug("rewriting type reference: " + typeReference.getName() + " -> " + + declaration.getQualifiedDeclarationName()); + typeReference.setName(declaration.getQualifiedDeclarationName()); + } + super.visitTypeReference(typeReference); + } + + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/IterableInjector.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/IterableInjector.java new file mode 100644 index 00000000..b2688eec --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/IterableInjector.java @@ -0,0 +1,82 @@ +package org.jsweet.input.typescriptdef.visitor; + +import org.apache.commons.lang3.ArrayUtils; +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.ParameterDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; +import org.jsweet.input.typescriptdef.util.Util; + +/** + * This scanner injects the java.lang.Iterable interface when possible on + * indexed types (it also injects the $set method when not found). + * + * @author Renaud Pawlak + */ +public class IterableInjector extends Scanner { + + public IterableInjector(Context context) { + super(context); + } + + @Override + public void visitTypeDeclaration(TypeDeclaration typeDeclaration) { + for (FunctionDeclaration getFunction : typeDeclaration.findFunctions(JSweetDefTranslatorConfig.INDEXED_GET_FUCTION_NAME)) { + if (getFunction.isHidden()) { + continue; + } + + // inject the Iterable interface if needed + VariableDeclaration var = typeDeclaration.findVariable("length"); + if (var == null) { + return; + } + if (getFunction.getParameters().length == 1 + && "number".equals(getFunction.getParameters()[0].getType().getName())) { + // skip if already in a super type + if (typeDeclaration.getSuperTypes() != null) { + for (TypeReference t : typeDeclaration.getSuperTypes()) { + FunctionDeclaration alreadyInSupertype = lookupFunctionDeclaration(t, + JSweetDefTranslatorConfig.INDEXED_GET_FUCTION_NAME, new TypeReference(null, "number", null)); + if (alreadyInSupertype != null) { + return; + } + } + } + + if ("class".equals(typeDeclaration.getKind()) || "interface".equals(typeDeclaration.getKind())) { + TypeReference iterableType = new TypeReference(null, "Iterable", + new TypeReference[] { Util.wrapTypeReferences(getFunction.getType().copy()) }); + if (!ArrayUtils.contains(typeDeclaration.getSuperTypes(), iterableType)) { + logger.trace("add " + getFunction.getType() + " iterator to " + + context.getTypeName(typeDeclaration)); + typeDeclaration.setSuperTypes(ArrayUtils.add(typeDeclaration.getSuperTypes(), iterableType)); + if (!"interface".equals(typeDeclaration.getKind())) { + FunctionDeclaration iterator = new FunctionDeclaration(null, "iterator", new TypeReference( + null, "java.util.Iterator", + new TypeReference[] { Util.wrapTypeReferences(getFunction.getType().copy()) }), + new ParameterDeclaration[0], null); + iterator.setDocumentation("/** From Iterable, to allow foreach loop (do not use directly). */"); + iterator.addStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_ERASED); + + typeDeclaration.addMember(iterator); + } + } + } + } + } + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/JavaDefModelPrinter.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/JavaDefModelPrinter.java new file mode 100644 index 00000000..16dd0679 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/JavaDefModelPrinter.java @@ -0,0 +1,614 @@ +package org.jsweet.input.typescriptdef.visitor; + +import static java.util.Arrays.asList; +import static org.apache.commons.lang3.StringUtils.isBlank; +import static org.apache.commons.lang3.StringUtils.join; + +import java.io.File; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.ast.AbstractPrinter; +import org.jsweet.input.typescriptdef.ast.ArrayTypeReference; +import org.jsweet.input.typescriptdef.ast.CompilationUnit; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Declaration; +import org.jsweet.input.typescriptdef.ast.DeclarationHelper; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.FunctionalTypeReference; +import org.jsweet.input.typescriptdef.ast.ModuleDeclaration; +import org.jsweet.input.typescriptdef.ast.ParameterDeclaration; +import org.jsweet.input.typescriptdef.ast.QualifiedDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.Type; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeParameterDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.ast.UnionTypeReference; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; +import org.jsweet.input.typescriptdef.util.Util; + +public class JavaDefModelPrinter extends AbstractPrinter { + + private static Map typeMap = new HashMap(); + + static { + typeMap.put("any", "Object"); + typeMap.put("string", "String"); + typeMap.put("number", "double"); + typeMap.put("symbol", "String"); + } + + private static String toJavaTypeName(String typeName) { + if (typeMap.containsKey(typeName)) { + return typeMap.get(typeName); + } else { + return typeName; + } + } + + private File outputDir; + + public JavaDefModelPrinter(Context context, File outputDir) { + super(context); + this.outputDir = outputDir; + } + + private AbstractPrinter printIdentifier(String identifier) { + print(DeclarationHelper.toJavaIdentifier(identifier)); + return this; + } + + private AbstractPrinter printFunctionName(String functionName) { + return printIdentifier(functionName); + } + + @Override + public void visitCompilationUnit(CompilationUnit compilationUnit) { + if (context.isDependency(compilationUnit)) { + return; + } + + super.visitCompilationUnit(compilationUnit); + } + + String currentModuleName; + + @Override + public void visitModuleDeclaration(ModuleDeclaration moduleDeclaration) { + currentModuleName = getCurrentModuleName(); + String dependenciesNamesString = null; + if (context.libModules.contains(currentModuleName)) { + + List dependenciesNames = context.dependencyGraph + .getDestinationElements(moduleDeclaration.getName()); + dependenciesNamesString = ""; + if (dependenciesNames != null) { + for (int i = 0; i < dependenciesNames.size(); i++) { + dependenciesNames.set(i, "\"" + dependenciesNames.get(i) + "\""); + } + dependenciesNamesString = join(dependenciesNames, ","); + } + } + File f = new File(outputDir, currentModuleName.replace('.', '/') + "/package-info.java"); + f.getParentFile().mkdirs(); + try { + if (dependenciesNamesString != null) { + FileUtils.write(f, // + "/** This package contains the " + moduleDeclaration.getName() + + " library (source: Definitely Typed). */\n"); + + String mixins = ""; + if (context.getMixins(currentModuleName) != null) { + mixins = StringUtils.join( + context.getMixins(currentModuleName).stream().map(t -> context.getTypeName(t)).toArray(), + ".class,") + ".class"; + } + FileUtils.write(f, "@" + JSweetDefTranslatorConfig.ANNOTATION_ROOT + "(dependencies={" + + dependenciesNamesString + "}, mixins={" + mixins + "})\n", true); + } else { + FileUtils.write(f, // + "/** (source: Definitely Typed) */\n"); + } + CharSequence annosDecls = annotationsToString(moduleDeclaration); + if (!isBlank(annosDecls)) { + FileUtils.write(f, annosDecls, true); + } + if (context.externalModules.keySet().contains(currentModuleName)) { + FileUtils.write(f, "@" + JSweetDefTranslatorConfig.ANNOTATION_MODULE + "(\"" + + context.externalModules.get(currentModuleName) + "\")\n", true); + } + FileUtils.write(f, "package " + currentModuleName + ";\n", true); + } catch (Exception e) { + throw new RuntimeException(e); + } + scan(moduleDeclaration.getMembers()); + } + + private void printDocumentation(Declaration declaration) { + if (declaration.getDocumentation() != null) { + printIndent().print(declaration.getDocumentation()).println(); + } + } + + @Override + public void visitTypeDeclaration(TypeDeclaration typeDeclaration) { + // typeDeclaration.setName(toJavaDeclarationName(typeDeclaration.getName())); + if (typeDeclaration.isExternal()) { + return; + } + boolean innerType = getParent() instanceof TypeDeclaration; + + StringBuilder mergedSuperTypeList = new StringBuilder(); + if (typeDeclaration.getMergedSuperTypes() != null) { + for (TypeReference type : typeDeclaration.getMergedSuperTypes()) { + mergedSuperTypeList.append(type.getName() + ".class,"); + } + if (mergedSuperTypeList.length() > 1) { + mergedSuperTypeList.deleteCharAt(mergedSuperTypeList.length() - 1); + typeDeclaration.addStringAnnotation( + JSweetDefTranslatorConfig.ANNOTATION_EXTENDS + "({" + mergedSuperTypeList.toString() + "})"); + } + } + if (!innerType) { + clearOutput(); + currentModuleName = getCurrentModuleName(); + + print("package " + currentModuleName + ";").println(); + + // dynamically create imports + Set imports = new HashSet(); + new Scanner(this) { + @Override + public void visitTypeReference(TypeReference typeReference) { + TypeDeclaration enclosingTypeDecl = getParent(TypeDeclaration.class); + if (typeReference.getName() != null && enclosingTypeDecl != null + && typeReference.getName().equals(enclosingTypeDecl.getName())) { + return; + } + + Type t = lookupType(typeReference, null); + if (t instanceof TypeDeclaration) { + TypeDeclaration typeDeclaration = (TypeDeclaration) t; + String name = context.getTypeName(typeDeclaration); + if (!typeDeclaration.isExternal() && name != null + && !(typeReference.getName().contains(".") && typeReference.getName().equals(name))) { + imports.add(name); + } + } + super.visitTypeReference(typeReference); + } + }.visitTypeDeclaration(typeDeclaration); + List importShortNames = imports.stream().map(name -> Util.getSimpleName(name)) + .collect(Collectors.toList()); + List clashes = new ArrayList<>(); + for (String typeName : imports) { + if (!typeName.startsWith(currentModuleName + ".")) { + if (typeName.contains(".")) { + if (Collections.frequency(importShortNames, Util.getSimpleName(typeName)) > 1) { + clashes.add(typeName); + } else { + print("import ").print(typeName).print(";").println(); + } + } + } + } + for (String clash : clashes) { + new Scanner(this) { + @Override + public void visitTypeReference(TypeReference typeReference) { + TypeDeclaration enclosingTypeDecl = getParent(TypeDeclaration.class); + if (typeReference.getName() != null && enclosingTypeDecl != null + && typeReference.getName().equals(enclosingTypeDecl.getName())) { + return; + } + + Type t = lookupType(typeReference, null); + if (t instanceof TypeDeclaration) { + TypeDeclaration typeDeclaration = (TypeDeclaration) t; + String name = context.getTypeName(typeDeclaration); + if (clash.equals(name)) { + typeReference.setName(name); + } + } + super.visitTypeReference(typeReference); + } + }.visitTypeDeclaration(typeDeclaration); + } + + printDocumentation(typeDeclaration); + printAnnotations(typeDeclaration); + print("public "); + } else { + printDocumentation(typeDeclaration); + printAnnotations(typeDeclaration); + printIndent().print("public "); + } + if (typeDeclaration.hasModifier("static")) { + print("static "); + } + if (typeDeclaration.hasModifier("abstract")) { + print("abstract "); + } + if (JSweetDefTranslatorConfig.GLOBALS_CLASS_NAME.equals(typeDeclaration.getName())) { + print("final "); + } + print(typeDeclaration.getKind() + " "); + printIdentifier(typeDeclaration.getName()); + printTypeParameters(typeDeclaration.getTypeParameters(), false); + if ("interface".equals(typeDeclaration.getKind())) { + if (typeDeclaration.getSuperTypes() != null && typeDeclaration.getSuperTypes().length > 0) { + for (TypeReference r : typeDeclaration.getSuperTypes()) { + TypeDeclaration t = (TypeDeclaration) lookupType(r, null); + if ("interface".equals(t.getKind())) { + print(" extends ").print(typeDeclaration.getSuperTypes()[0]); + } else { + context.reportError("wrong subclassing link between " + typeDeclaration.getName() + " and " + + t.getName() + " at " + typeDeclaration.getToken().getLocation()); + } + } + } + } else if ("class".equals(typeDeclaration.getKind())) { + List extendList = new ArrayList(); + List implementList = new ArrayList(); + if (typeDeclaration.getSuperTypes() != null && typeDeclaration.getSuperTypes().length > 0) { + for (TypeReference r : typeDeclaration.getSuperTypes()) { + TypeDeclaration t = (TypeDeclaration) lookupType(r, null); + if (t != null) { + if ("interface".equals(t.getKind())) { + implementList.add(r); + } else { + extendList.add(r); + } + } else { + logger.warn("unresolved inheritance reference: " + r); + } + } + } + + if (extendList.size() > 1) { + + context.reportError( + "multiple inheritance should not appear at this stage for " + typeDeclaration.getName() + " at " + + typeDeclaration.getToken().getLocation() + " extends=" + extendList); + } else if (extendList.size() == 1) { + print(" extends ").print(extendList.get(0)); + } else if (!JSweetDefTranslatorConfig.isJDKReplacementMode() + && !((JSweetDefTranslatorConfig.getObjectClassName()) + .equals(currentModuleName + "." + typeDeclaration.getName()))) { + print(" extends ").print(JSweetDefTranslatorConfig.getObjectClassName()); + } + if (!implementList.isEmpty()) { + print(" implements "); + for (TypeReference r : implementList) { + print(r); + print(", "); + } + removeLastChars(2); + } + } + + print(" {"); + println().startIndent(); + scan(typeDeclaration.getMembers()); + endIndent(); + printIndent().print("}").println(); + if (!innerType) { + String typeName = currentModuleName + "." + typeDeclaration.getName(); + File outputFile = new File(outputDir, typeName.replace('.', '/') + ".java"); + writeToFile(outputFile, getResult()); + } + } + + private void writeToFile(File f, String output) { + f.getParentFile().mkdirs(); + if (f.exists()) { + logger.warn(f + " already exists!!"); + } + + try { + try (PrintWriter out = new PrintWriter(f.getPath())) { + out.println(output); + out.close(); + logger.trace("wrote " + f); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private JavaDefModelPrinter printTypeParameters(TypeParameterDeclaration[] typeParameters, boolean whitespace) { + if (typeParameters != null && typeParameters.length > 0) { + print("<"); + for (TypeParameterDeclaration t : typeParameters) { + print(t); + print(","); + } + if (typeParameters.length > 0) { + removeLastChar(); + } + print(">"); + if (whitespace) { + print(" "); + } + } + return this; + } + + private String getTypeInitalValue(String typeName) { + if (typeName == null) { + return "null"; + } + switch (typeName) { + case "void": + return null; + case "boolean": + return "false"; + case "number": + return "0"; + default: + return "null"; + } + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + printDocumentation(functionDeclaration); + TypeDeclaration owningType = getParent(TypeDeclaration.class); + // boolean hasConstructor = owningType != null && + // owningType.hasConstructor; + String name = DeclarationHelper.getActualFunctionName(functionDeclaration); + if (name != null && !name.equals(functionDeclaration.getName())) { + functionDeclaration.addStringAnnotation( + JSweetDefTranslatorConfig.ANNOTATION_NAME + "(\"" + functionDeclaration.getName() + "\")"); + } + printAnnotations(functionDeclaration).printIndent(); + boolean isNative = false; + if (owningType != null && !owningType.getKind().equals("interface") && !functionDeclaration.isConstructor()) { + print("native "); + isNative = true; + } + if (!functionDeclaration.isConstructor()) { + print("public "); + } + boolean isInterface = (owningType != null && owningType.isInterface()); + boolean isStatic = false; + if (functionDeclaration.hasModifier("static")) { + isStatic = true; + print("static "); + } + if (functionDeclaration.isConstructor()) { + if (JSweetDefTranslatorConfig.GLOBALS_CLASS_NAME.equals(owningType.getName())) { + print("private "); + } else { + if (functionDeclaration.hasModifier("protected")) { + print("protected "); + } else if (functionDeclaration.hasModifier("private")) { + print("private "); + } else { + print("public "); + } + } + if (functionDeclaration.getTypeParameters() != null) { + List typeParameters = new ArrayList<>( + asList(functionDeclaration.getTypeParameters())); + if (owningType.getTypeParameters() != null) { + typeParameters.removeAll(asList(owningType.getTypeParameters())); + } + printTypeParameters(typeParameters.toArray(new TypeParameterDeclaration[0]), true); + } + print(owningType.getName()); + } else { + printTypeParameters(functionDeclaration.getTypeParameters(), true); + switch (functionDeclaration.getName()) { + case JSweetDefTranslatorConfig.INDEXED_GET_FUCTION_NAME: + case JSweetDefTranslatorConfig.INDEXED_SET_FUCTION_NAME: + case JSweetDefTranslatorConfig.INDEXED_DELETE_FUCTION_NAME: + if (Util.wrapTypeMap.containsKey(functionDeclaration.getType().getName())) { + print(Util.wrapTypeMap.get(functionDeclaration.getType().getName())).print(" "); + } else { + print(functionDeclaration.getType()).print(" "); + } + if (isStatic) { + print(functionDeclaration.getName() + "Static"); + } else { + printFunctionName(functionDeclaration.getName()); + } + break; + default: + print(functionDeclaration.getType()).print(" "); + printFunctionName(name); + } + } + print("("); + for (VariableDeclaration t : functionDeclaration.getParameters()) { + print(t); + print(", "); + } + if (functionDeclaration.getParameters().length > 0) { + removeLastChars(2); + } + print(")"); + if (isNative || (isInterface && !isStatic)) { + print(";"); + } else { + if (functionDeclaration.isConstructor()) { + print("{}"); + } else { + print("{"); + String typeName = functionDeclaration.getType().getName(); + if (typeName == null) { + typeName = "Object"; + } + String initialValue = getTypeInitalValue(typeName); + if (initialValue != null) { + print("return " + initialValue + ";"); + } + print("}"); + } + } + println(); + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + TypeDeclaration owningType = getParent(TypeDeclaration.class); + printDocumentation(variableDeclaration); + printAnnotations(variableDeclaration); + if (variableDeclaration.isOptional() && owningType != null) { + printIndent().print("@" + JSweetDefTranslatorConfig.ANNOTATION_OPTIONAL).println(); + } + if (owningType != null && "enum".equals(owningType.getKind())) { + printIndent().print(variableDeclaration.getName()); + print(",").println(); + } else { + printIndent().print("public "); + if (variableDeclaration.hasModifier("static")) { + print("static "); + } + if (variableDeclaration.isReadonly()) { + print("final "); + } + print(variableDeclaration.getType()); + print(" "); + printIdentifier(variableDeclaration.getName()); + if (owningType != null && "interface".equals(owningType.getKind()) || variableDeclaration.isReadonly()) { + String typeName = variableDeclaration.getType().getName(); + String initialValue = getTypeInitalValue(typeName); + if (initialValue != null) { + print("=" + initialValue); + } + } + print(";").println(); + } + } + + @Override + public void visitParameterDeclaration(ParameterDeclaration parameterDeclaration) { + printDocumentation(parameterDeclaration); + if (parameterDeclaration.isVarargs()) { + if (Util.hasTypeParameterReferences(context, parameterDeclaration.getType())) { + print("@SuppressWarnings(\"unchecked\") "); + } + if (parameterDeclaration.getType().isArray()) { + print(parameterDeclaration.getType().getComponentType()); + } else { + print(parameterDeclaration.getType()); + } + print("..."); + } else { + print(parameterDeclaration.getType()); + } + print(" "); + printIdentifier(parameterDeclaration.getName()); + } + + @Override + public void visitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration) { + String name = toJavaTypeName(typeParameterDeclaration.getName()); + print(name); + if (typeParameterDeclaration.getUpperBound() != null) { + print(" extends ").print(typeParameterDeclaration.getUpperBound()); + } + } + + @Override + public void visitTypeReference(TypeReference typeReference) { + if (typeReference.isObjectType()) { + logger.error( + "object types are not allowed at this point: " + getCurrentContainerName() + ":" + getParent()); + return; + } + if ("this".equals(typeReference.getName())) { + print(getParent(TypeDeclaration.class).getName()); + } else { + String name = toJavaTypeName(typeReference.getName()); + if (Util.coreTypeMap.containsKey(typeReference.getName()) + && !JSweetDefTranslatorConfig.isJDKReplacementMode() + && JSweetDefTranslatorConfig.LANG_PACKAGE.equals(currentModuleName)) { + print("java.lang."); + print(name); + } else { + print(name); + } + } + if (typeReference.getTypeArguments() != null) { + boolean functionalTypeReference = isFunctionalTypeReference(typeReference); + boolean superTypeReference = isSuperTypeReference(typeReference); + print("<"); + for (TypeReference t : typeReference.getTypeArguments()) { + if (!superTypeReference && !functionalTypeReference && ("any".equals(t.getName()) + || (t instanceof UnionTypeReference && "java.lang.Object".equals(t.getName())))) { + print("?"); + } else { + print(t); + } + print(","); + } + if (typeReference.getTypeArguments().length > 0) { + removeLastChar(); + } + print(">"); + } + } + + @Override + public void visitFunctionalTypeReference(FunctionalTypeReference functionalTypeReference) { + // functional interfaces should have been generated at this point + print(""); + } + + @Override + public void visitArrayTypeReference(ArrayTypeReference arrayTypeReference) { + print(arrayTypeReference.getComponentType()); + if (!arrayTypeReference.isDisableArray()) { + print("[]"); + } + } + + @Override + public void visitUnionTypeReference(UnionTypeReference unionTypeReference) { + switch (unionTypeReference.getSelected()) { + case NONE: + case PENDING: + // union types should have been expanded at this point + print(""); + break; + case LEFT: + print(unionTypeReference.getLeftType()); + break; + case RIGHT: + print(unionTypeReference.getRightType()); + break; + } + } + + @Override + public void onScanEnded() { + for (QualifiedDeclaration moduleDeclaration : context + .findDeclarations(ModuleDeclaration.class, "*")) { + String module = context.getModuleName(moduleDeclaration.getDeclaration()); + if (context.moduleDocumentations.containsKey(module)) { + System.out.println("generating package-info.java for " + module); + File f = new File(outputDir, module.replace('.', '/') + "/package-info.java"); + f.getParentFile().mkdirs(); + try { + FileUtils.write(f, context.moduleDocumentations.get(module) + "\npackage " + module + ";", false); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ModuleToTypeMerger.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ModuleToTypeMerger.java new file mode 100644 index 00000000..3d88e9de --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ModuleToTypeMerger.java @@ -0,0 +1,78 @@ +package org.jsweet.input.typescriptdef.visitor; + +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Declaration; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.ModuleDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; + +public class ModuleToTypeMerger extends Scanner { + + public ModuleToTypeMerger(Context context) { + super(context); + } + + @Override + public void visitModuleDeclaration(ModuleDeclaration moduleDeclaration) { + if (moduleDeclaration.getName().contains("-")) { + context.reportWarning("invalid module name " + moduleDeclaration.getName() + " at " + + moduleDeclaration.getToken().getLocation()); + moduleDeclaration.setHidden(true); + return; + } + String fullName = getCurrentModuleName(); + TypeDeclaration type = context.getTypeDeclaration(fullName); + boolean hideType = false; + boolean hideModule = true; + if (type != null) { +// for (Declaration declaration : moduleDeclaration.getMembers()) { +// if (!(declaration instanceof VariableDeclaration || declaration instanceof FunctionDeclaration +// || (declaration instanceof TypeDeclaration))) { +// hideType = true; +// logger.warn("submodule '" + declaration.getName() +// + "' found while merging module into class... erase class and keep modules at " +// + declaration.getToken().getLocation()); +// moduleDeclaration.addMembers(type.getMembers()); +// type.setHidden(true); +// context.unregisterType(type); +// hideType = true; +// break; +// } +// } + if (!hideType) { + for (Declaration declaration : moduleDeclaration.getMembers()) { + if (declaration instanceof VariableDeclaration || declaration instanceof FunctionDeclaration + /*|| (declaration instanceof TypeDeclaration)*/) { + type.addMember(declaration); + moduleDeclaration.removeMember(declaration); + if(!(declaration instanceof TypeDeclaration)) { + declaration.addModifier("static"); + } + } else { + logger.warn("cannot merge declaration '" + declaration.getName() + + "' " + + declaration.getToken().getLocation()); + hideModule = false; + } + } + if(hideModule) { + moduleDeclaration.setHidden(true); + } else { + context.setTypeClashingWithModule(context.getTypeName(type)); + } + } + } + super.visitModuleDeclaration(moduleDeclaration); + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/NameAdapter.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/NameAdapter.java new file mode 100644 index 00000000..18e6dc3d --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/NameAdapter.java @@ -0,0 +1,66 @@ +package org.jsweet.input.typescriptdef.visitor; + +import static org.jsweet.JSweetDefTranslatorConfig.STRING_TYPES_INTERFACE_NAME; +import static org.jsweet.input.typescriptdef.util.Util.checkAndAdjustDeclarationName; +import static org.jsweet.input.typescriptdef.util.Util.toJavaName; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.ModuleDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeReference; + +public class NameAdapter extends Scanner { + + public NameAdapter(Context context) { + super(context); + } + + public NameAdapter(Scanner parentScanner) { + super(parentScanner); + } + + @Override + public void visitModuleDeclaration(ModuleDeclaration declaration) { + checkAndAdjustDeclarationName(declaration, true); + if (declaration.isQuotedName()) { + context.externalModules.put(getCurrentModuleName(), declaration.getOriginalName()); + } + super.visitModuleDeclaration(declaration); + } + + @Override + public void visitTypeReference(TypeReference typeReference) { + String adaptedName = getAdaptedName(typeReference); + if (adaptedName != null) { + typeReference.setName(adaptedName); + } + super.visitTypeReference(typeReference); + } + + private String getAdaptedName(TypeReference typeReference) { + String simpleName = typeReference.getSimpleName(); + String qualifier = typeReference.getQualifier(); + TypeDeclaration type = context.getTypeDeclaration(qualifier); + boolean innerType = type != null && !context.isTypeClashingWithModule(qualifier); + String newSimpleName = toJavaName(simpleName); + if (innerType) { + return getAdaptedName(new TypeReference(null, qualifier, null)) + "." + newSimpleName; + } else { + if (qualifier != null && !qualifier.endsWith(STRING_TYPES_INTERFACE_NAME)) { + String newQualifier = null; + if (qualifier != null) { + newQualifier = Arrays.stream(qualifier.split("\\.")).map(name -> toJavaName(name, true)) + .collect(Collectors.joining(".")); + } + return newQualifier + "." + newSimpleName; + } else { + return null; + } + } + + } +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/NameChecker.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/NameChecker.java new file mode 100644 index 00000000..57af6641 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/NameChecker.java @@ -0,0 +1,91 @@ +package org.jsweet.input.typescriptdef.visitor; + +import static org.jsweet.input.typescriptdef.util.Util.checkAndAdjustDeclarationName; +import static org.jsweet.input.typescriptdef.util.Util.toJavaName; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.ModuleDeclaration; +import org.jsweet.input.typescriptdef.ast.ReferenceDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeParameterDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; + +/** + * This scanner checks that declaration names are valid Java identifiers and + * change the names when not valid. The original names are kept in {@link Name} + * annotations, which are added to the modified declarations. + */ +public class NameChecker extends Scanner { + + public NameChecker(Context context) { + super(context); + } + + public NameChecker(Scanner parentScanner) { + super(parentScanner); + } + + @Override + public void visitModuleDeclaration(ModuleDeclaration moduleDeclaration) { + checkAndAdjustDeclarationName(moduleDeclaration); + super.visitModuleDeclaration(moduleDeclaration); + } + + @Override + public void visitTypeDeclaration(TypeDeclaration typeDeclaration) { + checkAndAdjustDeclarationName(typeDeclaration); + super.visitTypeDeclaration(typeDeclaration); + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + checkAndAdjustDeclarationName(variableDeclaration); + super.visitVariableDeclaration(variableDeclaration); + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + checkAndAdjustDeclarationName(functionDeclaration); + super.visitFunctionDeclaration(functionDeclaration); + } + + @Override + public void visitReferenceDeclaration(ReferenceDeclaration referenceDeclaration) { + referenceDeclaration.setName(toJavaName(referenceDeclaration.getName())); + referenceDeclaration.setReferencedName(toJavaName(referenceDeclaration.getReferencedName())); + super.visitReferenceDeclaration(referenceDeclaration); + } + + @Override + public void visitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration) { + typeParameterDeclaration.setName(toJavaName(typeParameterDeclaration.getName())); + super.visitTypeParameterDeclaration(typeParameterDeclaration); + } + + @Override + public void visitTypeReference(TypeReference typeReference) { + if (!"this".equals(typeReference.getName())) { + String simpleName = typeReference.getSimpleName(); + String qualifier = typeReference.getQualifier(); + String newSimpleName = toJavaName(simpleName); + if (qualifier == null) { + typeReference.setName(newSimpleName); + } else { + String newQualifier = null; + if (qualifier != null) { + newQualifier = Arrays.stream(qualifier.split("\\.")).map(name -> toJavaName(name)) + .collect(Collectors.joining(".")); + } + typeReference.setName(newQualifier + "." + newSimpleName); + } + } + super.visitTypeReference(typeReference); + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ObjectTypeCreator.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ObjectTypeCreator.java new file mode 100644 index 00000000..52a4116f --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ObjectTypeCreator.java @@ -0,0 +1,164 @@ +package org.jsweet.input.typescriptdef.visitor; + +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Declaration; +import org.jsweet.input.typescriptdef.ast.DeclarationContainer; +import org.jsweet.input.typescriptdef.ast.DeclarationHelper; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeMacroDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeParameterDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.ast.TypedDeclaration; +import org.jsweet.input.typescriptdef.util.Util; + +public class ObjectTypeCreator extends Scanner { + + public ObjectTypeCreator(Context context) { + super(context); + } + + private class NameConflictFinder extends Scanner { + private String name; + public boolean conflict = false; + + public NameConflictFinder(Context context, String name) { + super(context); + this.name = name; + } + + @Override + public void visitTypeReference(TypeReference typeReference) { + if (name.equals(typeReference.getName())) { + conflict = true; + } + super.visitTypeReference(typeReference); + } + + @Override + public void visitTypeMacro(TypeMacroDeclaration typeMacroDeclaration) { + if (name.equals(typeMacroDeclaration.getName())) { + conflict = true; + } + super.visitTypeMacro(typeMacroDeclaration); + } + }; + + private static String[] suffixes = { "Object", "Data", "Dto", "Structure", "Info" }; + + private static String getSuffix(int i) { + if (i < suffixes.length) { + return suffixes[i]; + } else { + return "" + (i + 1 - suffixes.length); + } + } + + @Override + public void visitTypeReference(TypeReference typeReference) { + if (typeReference.isObjectType()) { + DeclarationContainer container = getParent(t -> { + return (t instanceof DeclarationContainer) && !(t instanceof TypeMacroDeclaration); + }); + TypedDeclaration parentDeclaration = getParent(TypedDeclaration.class); + if (typeReference.getObjectType().getMembers().length == 0) { + Util.substituteTypeReference(this, parentDeclaration, typeReference, + new TypeReference(null, Object.class.getName(), null)); + } else { + + String rootName = StringUtils.capitalize(parentDeclaration.getName()); + String name = rootName; + int i = 1; + + TypeParameterDeclaration[] typeParameters = Util.findTypeParameters(this, typeReference); + for (TypeParameterDeclaration p : typeParameters) { + if (Util.containsAstNode(typeReference, p)) { + typeParameters = ArrayUtils.remove(typeParameters, ArrayUtils.indexOf(typeParameters, p)); + } + } + if (typeParameters.length == 0) { + typeParameters = null; + } + TypeDeclaration newClass = null; + + while (newClass == null) { + // first check that no type of the same level has the same + // name + TypeDeclaration conflictingType = container.findType(name); + boolean conflict = false; + if (conflictingType != null) { + for (Declaration member : typeReference.getObjectType().getMembers()) { + if (!ArrayUtils.contains(conflictingType.getMembers(), member)) { + conflict = true; + break; + } + } + if (!conflict) { + newClass = conflictingType; + } else { + name = rootName + getSuffix(i++); + } + } else { + // check enclosing types names (in Java, enclosed types + // cannot be named like an enclosing one) + List parents = getParents(TypeDeclaration.class); + for (TypeDeclaration parent : parents) { + if (name.equals(parent.getName())) { + conflict = true; + } + } + if (!conflict) { + NameConflictFinder finder = new NameConflictFinder(context, name); + container.accept(finder); + conflict = finder.conflict; + } + if (conflict) { + name = rootName + getSuffix(i++); + } else { + // finally, no conflict, we create the class + newClass = new TypeDeclaration(null, "class", name, DeclarationHelper.copy(typeParameters), + null, null); + newClass.setDocumentation( + "/** This is an automatically generated object type (see the source definition). */"); + if (container instanceof TypeDeclaration) { + newClass.addModifier("static"); + } + newClass.addMembers(typeReference.getObjectType().getMembers()); + newClass.addStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_OBJECT_TYPE); + container.addMember(newClass); + } + } + } + + String objectTypeFullName = getCurrentContainerName() + "." + newClass.getName(); + + logger.trace("registering object type: " + objectTypeFullName + " in container " + container + " (" + + container.getClass().getSimpleName() + ")"); + List containerGeneratedTypes = context.generatedObjectTypes.get(container); + if (containerGeneratedTypes == null) { + context.generatedObjectTypes.put(container, + containerGeneratedTypes = new LinkedList()); + } + containerGeneratedTypes.add(newClass); + + // parentDeclaration.setType(new TypeReference(null, + // newClass.getName(), DeclarationHelper + // .toTypeArguments(typeParameters))); + + Util.substituteTypeReference(this, parentDeclaration, typeReference, + new TypeReference(null, newClass.getName(), DeclarationHelper.toTypeArguments(typeParameters))); + context.registerType(objectTypeFullName, newClass); + // recursively scan the newly created class + scan(newClass); + } + } + scan(typeReference.getTypeArguments()); + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ObjectTypeDuplicateMerger.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ObjectTypeDuplicateMerger.java new file mode 100644 index 00000000..f77ef7b7 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ObjectTypeDuplicateMerger.java @@ -0,0 +1,164 @@ +package org.jsweet.input.typescriptdef.visitor; + +import static org.apache.commons.lang3.StringUtils.defaultString; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.jsweet.input.typescriptdef.ast.CompilationUnit; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.DeclarationContainer; +import org.jsweet.input.typescriptdef.ast.DeclarationHelper; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.Type; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.ast.TypedDeclaration; +import org.jsweet.input.typescriptdef.util.Util; + +public class ObjectTypeDuplicateMerger extends Scanner { + + public ObjectTypeDuplicateMerger(Context context) { + super(context); + } + + Map duplicatesToReplace; + + @Override + public void visitCompilationUnit(CompilationUnit compilationUnit) { + DuplicateCollector collector = new DuplicateCollector(context); + compilationUnit.accept(collector); + duplicatesToReplace = collector.replacements; + if (duplicatesToReplace.isEmpty()) { + return; + } + + logger.debug(compilationUnit + " object types replacements: " + duplicatesToReplace); + + super.visitCompilationUnit(compilationUnit); + } + + @Override + public void visitTypeDeclaration(TypeDeclaration typeDeclaration) { + String qualifiedName = getCurrentContainerName(); + TypeDeclaration replacement = duplicatesToReplace.get(qualifiedName); + if (replacement != null) { + DeclarationContainer container = getParent(DeclarationContainer.class); + logger.trace("replace " + qualifiedName + " with " + context.getTypeName(replacement) + " in " + container); + container.removeMember(typeDeclaration); + } else { + super.visitTypeDeclaration(typeDeclaration); + } + } + + @Override + public void visitTypeReference(TypeReference typeReference) { + String qualifiedName = getCurrentContainerName() + "." + typeReference.getName(); + TypeDeclaration replacement = duplicatesToReplace.get(qualifiedName); + if (replacement == null) { + replacement = duplicatesToReplace.get(qualifiedName = typeReference.getName()); + } + + if (replacement != null) { + logger.trace("replace reference " + qualifiedName + " with " + replacement); + TypedDeclaration parentDeclaration = getParent(TypedDeclaration.class); + Util.substituteTypeReference(this, parentDeclaration, typeReference, new TypeReference(null, replacement, + typeReference.getTypeArguments())); + } + super.visitTypeReference(typeReference); + } + + private class DuplicateCollector extends Scanner { + public DuplicateCollector(Context context) { + super(context); + } + + protected Map replacements = new HashMap<>(); + + @Override + public void visitTypeDeclaration(TypeDeclaration typeDeclaration) { + super.visitTypeDeclaration(typeDeclaration); + + // TODO : this only a POC, how to handle duplicates within + // moduleDeclaration ???? + List objectTypes = context.generatedObjectTypes.get(typeDeclaration); + if (objectTypes != null) { + for (TypeDeclaration objectType : objectTypes) { + String qualifiedName = getCurrentContainerName() + "." + objectType; + logger.trace("lookup duplicate of " + qualifiedName); + TypeDeclaration match = searchTopMostDuplicateInParentHierarchy(typeDeclaration, objectType); + if (match != null) { + replacements.put(qualifiedName, match); + logger.trace("most relevant match: " + match); + } + } + } + } + + private TypeDeclaration searchTopMostDuplicateInParentHierarchy(TypeDeclaration owner, + TypeDeclaration objectType) { + if (objectType.getMembers() == null || objectType.getMembers().length == 0) { + return null; + } + + TypeDeclaration match = null; + + List objectTypeMatches = context.generatedObjectTypes.get(owner); + if (objectTypeMatches != null) { + for (TypeDeclaration matchInCurrent : objectTypeMatches) { + if (matchInCurrent != objectType && areObjectTypesEqual(matchInCurrent, objectType)) { + match = matchInCurrent; + } + } + } + + TypeReference[] superRefs = ((TypeDeclaration) owner).getSuperTypes(); + if (superRefs != null) { + for (TypeReference superRef : superRefs) { + Type superType = lookupType(superRef, context.getTypeModule(((TypeDeclaration) owner))); + if (superType instanceof TypeDeclaration) { + TypeDeclaration matchInSuperType = searchTopMostDuplicateInParentHierarchy( + (TypeDeclaration) superType, objectType); + if (matchInSuperType != null) { + match = matchInSuperType; + } + } + } + } + + return match; + } + + // TODO : externalize ??? + private boolean areObjectTypesEqual(TypeDeclaration left, TypeDeclaration right) { + if (!defaultString(left.getName()).equals(defaultString(right.getName()))) { + return false; + } + + int leftTypeParametersCount = left.getTypeParameters() == null ? 0 : left.getTypeParameters().length; + int rightTypeParametersCount = right.getTypeParameters() == null ? 0 : right.getTypeParameters().length; + if (leftTypeParametersCount != rightTypeParametersCount) { + return false; + } + + // TODO : TypeParamDecl equals AND TypedDeclaration equals are not + // correctly implemented .... (only name is checked) + if (leftTypeParametersCount > 0 + && !DeclarationHelper.areDeclarationsEqual(left.getTypeParameters(), right.getTypeParameters())) { + return false; + } + + if (left.getMembers() == null || right.getMembers() == null) { + return false; + } + + if (left.getMembers().length != right.getMembers().length) { + return false; + } + + return DeclarationHelper.areDeclarationsEqual(left.getMembers(), right.getMembers()); + } + + } +} \ No newline at end of file diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/OptionalLambdasParametersExpander.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/OptionalLambdasParametersExpander.java new file mode 100644 index 00000000..b0731d90 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/OptionalLambdasParametersExpander.java @@ -0,0 +1,105 @@ +package org.jsweet.input.typescriptdef.visitor; + +import java.util.ArrayList; +import java.util.HashSet; + +import org.apache.commons.lang3.ArrayUtils; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.DeclarationContainer; +import org.jsweet.input.typescriptdef.ast.DeclarationHelper; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.FunctionalTypeReference; +import org.jsweet.input.typescriptdef.ast.ParameterDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; + +/** + * This scanner makes functional type parameters and return optional in + * functions. + * + *

+ * For instance: f(p:A,B=>C) will generate: + * + *

    + *
  • f(p:(a:A,b:B)=>C)
  • + *
  • f(p:(a:A,b:B)=>void)
  • + *
  • f(p:()=>C)
  • + *
  • f(p:()=>void)
  • + *
+ * + * @author Renaud Pawlak + */ +public class OptionalLambdasParametersExpander extends Scanner { + + int param = 0; + + public OptionalLambdasParametersExpander(Context context) { + super(context); + } + + public OptionalLambdasParametersExpander(Scanner parent, int param) { + super(parent); + this.param = param; + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + super.visitFunctionDeclaration(functionDeclaration); + DeclarationContainer container = getParent(DeclarationContainer.class); + for (int i = param; i < functionDeclaration.getParameters().length; i++) { + if (functionDeclaration.getParameters()[i].getType() instanceof FunctionalTypeReference) { + FunctionalTypeReference functionalType = (FunctionalTypeReference) functionDeclaration + .getParameters()[i].getType(); + FunctionDeclaration voidFunction = null; + FunctionalTypeReference voidFunctionalType = null; + if (!"void".equals(functionalType.getReturnType().getName())) { + voidFunctionalType = functionalType.copy(); + voidFunctionalType.setReturnType(new TypeReference(null, "void", null)); + voidFunction = createFunction(container, functionDeclaration, voidFunctionalType, i); + new OptionalLambdasParametersExpander(this, param + 1).visitFunctionDeclaration(voidFunction); + } + if (functionalType.getParameters().length > 0) { + FunctionalTypeReference truncatedFunctionalType = functionalType.copy(); + truncatedFunctionalType.setParameters(new ParameterDeclaration[0]); + FunctionDeclaration truncatedFunction = createFunction(container, functionDeclaration, + truncatedFunctionalType, i); + new OptionalLambdasParametersExpander(this, param + 1).visitFunctionDeclaration(truncatedFunction); + if (voidFunction != null) { + truncatedFunctionalType = voidFunctionalType.copy(); + truncatedFunctionalType.setParameters(new ParameterDeclaration[0]); + truncatedFunction = createFunction(container, functionDeclaration, truncatedFunctionalType, i); + new OptionalLambdasParametersExpander(this, param + 1) + .visitFunctionDeclaration(truncatedFunction); + } + } + } + } + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + } + + private FunctionDeclaration createFunction(DeclarationContainer container, FunctionDeclaration functionDeclaration, + FunctionalTypeReference newParamType, int param) { + FunctionDeclaration newFunction = new FunctionDeclaration(functionDeclaration.getToken(), + functionDeclaration.getName(), + functionDeclaration.getType() == null ? null : functionDeclaration.getType().copy(), + DeclarationHelper.copy(functionDeclaration.getParameters()), + DeclarationHelper.copy(functionDeclaration.getTypeParameters())); + newFunction.getParameters()[param].setType(newParamType); + newFunction.setDocumentation(functionDeclaration.getDocumentation()); + newFunction.setModifiers(functionDeclaration.getModifiers() == null ? null + : new HashSet(functionDeclaration.getModifiers())); + if (functionDeclaration.getStringAnnotations() != null) { + newFunction.setStringAnnotations(new ArrayList<>(functionDeclaration.getStringAnnotations())); + } + if (!ArrayUtils.contains(container.getMembers(), newFunction)) { + container.addMember(newFunction); + } + return newFunction; + + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/OptionalParametersExpander.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/OptionalParametersExpander.java new file mode 100644 index 00000000..34059f91 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/OptionalParametersExpander.java @@ -0,0 +1,48 @@ +package org.jsweet.input.typescriptdef.visitor; + +import java.util.ArrayList; +import java.util.HashSet; + +import org.apache.commons.lang3.ArrayUtils; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.DeclarationContainer; +import org.jsweet.input.typescriptdef.ast.DeclarationHelper; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; + +public class OptionalParametersExpander extends Scanner { + + public OptionalParametersExpander(Context context) { + super(context); + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + super.visitFunctionDeclaration(functionDeclaration); + DeclarationContainer container = getParent(DeclarationContainer.class); + for (int i = functionDeclaration.getParameters().length - 1; i >= 0; i--) { + if (functionDeclaration.getParameters()[i].isOptional()) { + FunctionDeclaration newFunction = new FunctionDeclaration(functionDeclaration.getToken(), + functionDeclaration.getName(), + functionDeclaration.getType() == null ? null : functionDeclaration.getType().copy(), + DeclarationHelper.copy(ArrayUtils.subarray(functionDeclaration.getParameters(), 0, i)), + DeclarationHelper.copy(functionDeclaration.getTypeParameters())); + newFunction.setDocumentation(functionDeclaration.getDocumentation()); + newFunction.setModifiers(functionDeclaration.getModifiers() == null ? null + : new HashSet(functionDeclaration.getModifiers())); + if (functionDeclaration.getStringAnnotations() != null) { + newFunction.setStringAnnotations(new ArrayList<>(functionDeclaration.getStringAnnotations())); + } + if (!ArrayUtils.contains(container.getMembers(), newFunction)) { + container.addMember(newFunction); + } + } + } + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/OptionalParametersInFunctionalTypesExpander.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/OptionalParametersInFunctionalTypesExpander.java new file mode 100644 index 00000000..a403b8fe --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/OptionalParametersInFunctionalTypesExpander.java @@ -0,0 +1,54 @@ +package org.jsweet.input.typescriptdef.visitor; + +import org.apache.commons.lang3.ArrayUtils; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.DeclarationContainer; +import org.jsweet.input.typescriptdef.ast.DeclarationHelper; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.FunctionalTypeReference; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; + +/** + * Expands optional parameters in functional types. + * + * @author Renaud Pawlak + */ +public class OptionalParametersInFunctionalTypesExpander extends Scanner { + + public OptionalParametersInFunctionalTypesExpander(Context context) { + super(context); + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + super.visitFunctionDeclaration(functionDeclaration); + DeclarationContainer container = getParent(DeclarationContainer.class); + for (int i = functionDeclaration.getParameters().length - 1; i >= 0; i--) { + if (functionDeclaration.getParameters()[i].getType() instanceof FunctionalTypeReference) { + FunctionalTypeReference f = (FunctionalTypeReference) functionDeclaration.getParameters()[i].getType(); + for (int j = f.getParameters().length - 1; j >= 0; j--) { + if (f.getParameters()[j].isOptional()) { + FunctionalTypeReference newFunctionalType = new FunctionalTypeReference(null, + f.getReturnType(), ArrayUtils.subarray(f.getParameters(), 0, j), null); + FunctionDeclaration newFunction = new FunctionDeclaration(functionDeclaration.getToken(), + functionDeclaration.getName(), functionDeclaration.getType(), + DeclarationHelper.copy(functionDeclaration.getParameters()), + functionDeclaration.getTypeParameters()); + newFunction.getParameters()[i].setType(newFunctionalType); + newFunction.setDocumentation(functionDeclaration.getDocumentation()); + newFunction.setModifiers(functionDeclaration.getModifiers()); + if (!ArrayUtils.contains(container.getMembers(), newFunction)) { + container.addMember(newFunction); + } + } + } + } + } + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/PackageOrganizer.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/PackageOrganizer.java new file mode 100644 index 00000000..a5ebb220 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/PackageOrganizer.java @@ -0,0 +1,88 @@ +package org.jsweet.input.typescriptdef.visitor; + +import java.util.Arrays; +import java.util.Comparator; + +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.TypescriptDef2Java; +import org.jsweet.input.typescriptdef.ast.CompilationUnit; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Declaration; +import org.jsweet.input.typescriptdef.ast.ModuleDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.util.Util; + +public class PackageOrganizer extends Scanner { + + public PackageOrganizer(Context context) { + super(context); + } + + @Override + public void visitCompilationUnit(CompilationUnit compilationUnit) { + ModuleDeclaration currentModule = null; + + if (compilationUnit.getFile().getParentFile().getName().equals(TypescriptDef2Java.TS_CORE_LIB_DIR)) { + // in case all files are placed in the core directory, discriminate + // on the file name + if (compilationUnit.getFile().getName().startsWith("lib.core")) { + currentModule = new ModuleDeclaration(null, JSweetDefTranslatorConfig.LANG_PACKAGE, new Declaration[0]); + } else { + currentModule = new ModuleDeclaration(null, JSweetDefTranslatorConfig.DOM_PACKAGE, new Declaration[0]); + } + } + if (compilationUnit.getFile().getParentFile().getName().equals(TypescriptDef2Java.TS_DOM_LIB_DIR)) { + currentModule = new ModuleDeclaration(null, JSweetDefTranslatorConfig.DOM_PACKAGE, new Declaration[0]); + } + if (currentModule == null) { + String name = Util.getLibPackageNameFromTsDefFile(compilationUnit.getFile()); + logger.trace("root package found: " + name + " for " + compilationUnit); + currentModule = new ModuleDeclaration(null, name, new Declaration[0]); + if (compilationUnit.isExternal()) { + String filename = compilationUnit.getFile().getName(); + filename = filename.substring(0, filename.indexOf('.')); + currentModule.addStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_NAME + "(\"" + filename + "\")"); + currentModule.setQuotedName(true); + } + if (!context.libModules.contains(name)) { + context.libModulesCompilationUnits.put(name, compilationUnit); + context.libModules.add(name); + context.libModules.sort(new Comparator() { + @Override + public int compare(String s1, String s2) { + return -s1.compareTo(s2); + } + }); + } else { + // this is the case when a group contains several definition + // files + context.reportWarning("root package has already been registered: " + name); + } + } + + for (Declaration declaration : compilationUnit.getMembers()) { + currentModule.addMember(declaration); + } + compilationUnit.clearMembers(); + + // TODO : the following code was supposed to handle a compilation unit + // which would not be any of lang, dom, webworkers or lib + // for (Declaration declaration : compilationUnit.getMembers()) { + // if (!(declaration instanceof ModuleDeclaration)) { + // if (currentModule == null) { + // currentModule = new ModuleDeclaration(null, + // JSweetConfig.GLOBALS_PACKAGE_NAME, + // new Declaration[0]); + // } + // compilationUnit.removeMember(declaration); + // currentModule.addMember(declaration); + // } + // } + if (currentModule != null) { + if (context.verbose) { + logger.debug("creating module: " + currentModule + " - " + Arrays.asList(currentModule.getMembers())); + } + compilationUnit.addMember(currentModule); + } + } +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ParentMethodReturnTypeSusbtitutor.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ParentMethodReturnTypeSusbtitutor.java new file mode 100644 index 00000000..a8e13993 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/ParentMethodReturnTypeSusbtitutor.java @@ -0,0 +1,86 @@ +package org.jsweet.input.typescriptdef.visitor; + +import java.util.function.Consumer; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.Type; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; + +/** + * This scanner substitutes void return types of parent methods with Object. + * + *

+ * In Typescript, one can override a void method with a method that returns an + * object. In Java, it is not possible. So this scanner make sure that the + * parent method with actually return an object to avoid Java compile errors. + * + * @author Renaud Pawlak + */ +public class ParentMethodReturnTypeSusbtitutor extends Scanner { + + public ParentMethodReturnTypeSusbtitutor(Context context) { + super(context); + } + + private void applyToParentMethod(TypeDeclaration declaringType, FunctionDeclaration childFunction, + TypeDeclaration parentType, Consumer apply) { + int index = -1; + if (declaringType != parentType) { + index = ArrayUtils.indexOf(parentType.getMembers(), childFunction); + } + if (index != -1) { + apply.accept((FunctionDeclaration) parentType.getMembers()[index]); + } else { + if (parentType.getSuperTypes() != null && parentType.getSuperTypes().length > 0) { + for (TypeReference ref : parentType.getSuperTypes()) { + Type decl = lookupType(ref, null); + if (decl instanceof TypeDeclaration) { + applyToParentMethod(declaringType, childFunction, (TypeDeclaration) decl, apply); + } + } + } else if (!JSweetDefTranslatorConfig.getObjectClassName().equals(context.getTypeName(parentType))) { + TypeDeclaration decl = context.getTypeDeclaration(JSweetDefTranslatorConfig.getObjectClassName()); + if (decl != null) { + applyToParentMethod(declaringType, childFunction, (TypeDeclaration) decl, apply); + } + } + } + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + TypeDeclaration declaringType = getParent(TypeDeclaration.class); + if (declaringType != null && functionDeclaration.getType() != null + && functionDeclaration.getType().getName() != null + && !functionDeclaration.getType().getName().equals("void")) { + applyToParentMethod( + declaringType, + functionDeclaration, + declaringType, + (function) -> { + if (functionDeclaration.getType().isPrimitive() && !function.getType().isPrimitive()) { + functionDeclaration.getType().setName( + StringUtils.capitalize(functionDeclaration.getType().getName())); + } else { + if ("void".equals(function.getType().getName())) { + System.out.println("modify return type of " + function + ": " + function.getType() + + " -> " + functionDeclaration.getType()); + function.setType(functionDeclaration.getType()); + } + } + }); + } + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/SerializableHandler.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/SerializableHandler.java new file mode 100644 index 00000000..feef3e77 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/SerializableHandler.java @@ -0,0 +1,43 @@ +package org.jsweet.input.typescriptdef.visitor; + +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeMacroDeclaration; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; + +/** + * This scanner makes sure that classes that are sub-types of a serializable + * class do not trigger useless compilation warnings. + * + * @author Renaud Pawlak + */ +public class SerializableHandler extends Scanner { + + public SerializableHandler(Context context) { + super(context); + } + + @Override + public void visitTypeDeclaration(TypeDeclaration typeDeclaration) { + if (typeDeclaration.isSubtypeOf(context.getTypeDeclaration(JSweetDefTranslatorConfig.LANG_PACKAGE + "." + + RuntimeException.class.getSimpleName()))) { + typeDeclaration.addStringAnnotation(SuppressWarnings.class.getName() + "(\"serial\")"); + } + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + } + + @Override + public void visitTypeMacro(TypeMacroDeclaration typeMacroDeclaration) { + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/StringTypeCreator.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/StringTypeCreator.java new file mode 100644 index 00000000..35957071 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/StringTypeCreator.java @@ -0,0 +1,126 @@ +package org.jsweet.input.typescriptdef.visitor; + +import static org.apache.commons.lang3.StringUtils.strip; + +import org.apache.commons.lang3.StringUtils; +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.ast.CompilationUnit; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Declaration; +import org.jsweet.input.typescriptdef.ast.DeclarationContainer; +import org.jsweet.input.typescriptdef.ast.DeclarationHelper; +import org.jsweet.input.typescriptdef.ast.ModuleDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.ast.TypedDeclaration; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; +import org.jsweet.input.typescriptdef.util.Util; + +public class StringTypeCreator extends Scanner { + + /** + * Dashes can be used in Javascript identifiers, and will be replaced by + * this string. + */ + public static final String DASH_STRING_IN_JAVA_IDENTIFIERS = "_"; + + public static String toJavaStringType(String stringType) { + String stripped = strip(stringType, "\""); + if (Character.isDigit(stripped.charAt(0))) { + stripped = "_" + stripped; + } + stripped = stripped.replaceAll("[-:.!,;]", DASH_STRING_IN_JAVA_IDENTIFIERS); + if (JSweetDefTranslatorConfig.JAVA_KEYWORDS.contains(stripped)) { + stripped = StringUtils.capitalize(stripped); + } + return stripped; + } + + public StringTypeCreator(Context context) { + super(context); + } + + @Override + public void visitTypeReference(TypeReference typeReference) { + if (typeReference.isStringType()) { + TypedDeclaration parentDeclaration = getParent(TypedDeclaration.class); + + String stripped = strip(typeReference.getName(), "['\"]"); + String name = toJavaStringType(typeReference.getName()); + + DeclarationContainer stringsContainer = getStringsDeclarationContainer(); + TypeDeclaration newInterface = stringsContainer.findTypeIgnoreCase(name); + if (newInterface == null) { + newInterface = new TypeDeclaration(null, "interface", name, null, null, new Declaration[0]); + newInterface.setDocumentation("/**\n" + " * Generated to type the string " + typeReference.getName() + + ".\n" + " * @exclude\n" + " */"); + stringsContainer.addMember(newInterface); + context.registerType( + JSweetDefTranslatorConfig.UTIL_PACKAGE + "." + + JSweetDefTranslatorConfig.STRING_TYPES_INTERFACE_NAME + "." + newInterface.getName(), + newInterface); + if (stripped.equals(name)) { + newInterface.addStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_STRING_TYPE); + } else { + newInterface.addStringAnnotation( + JSweetDefTranslatorConfig.ANNOTATION_STRING_TYPE + "(\"" + stripped + "\")"); + } + } + VariableDeclaration var = null; + if ((var = stringsContainer.findVariableIgnoreCase(name)) == null) { + VariableDeclaration value = new VariableDeclaration(null, name, new TypeReference(null, + JSweetDefTranslatorConfig.UTIL_PACKAGE + "." + + JSweetDefTranslatorConfig.STRING_TYPES_INTERFACE_NAME + "." + newInterface.getName(), + null), false, false); + value.setDocumentation("/**\n" + " * Generated to type the string " + typeReference.getName() + ".\n" + + " * @exclude\n" + " */"); + value.addModifier("static"); + stringsContainer.addMember(value); + if (stripped.equals(name)) { + value.addStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_STRING_TYPE); + } else { + value.addStringAnnotation( + JSweetDefTranslatorConfig.ANNOTATION_STRING_TYPE + "(\"" + stripped + "\")"); + } + } + Util.substituteTypeReference(this, parentDeclaration, typeReference, + new TypeReference(null, + JSweetDefTranslatorConfig.UTIL_PACKAGE + "." + + JSweetDefTranslatorConfig.STRING_TYPES_INTERFACE_NAME + "." + + (var == null ? name : var.getName()), + null)); + + } + super.visitTypeReference(typeReference); + } + + private DeclarationContainer getStringsDeclarationContainer() { + // string declarations are all merged in the same package / class: + // jsweet util + CompilationUnit destinationCompilUnit = context.getTranslatedCompilationUnits().get(0); + + ModuleDeclaration destinationModule = getOrCreateModule(destinationCompilUnit, + JSweetDefTranslatorConfig.UTIL_PACKAGE); + String name = JSweetDefTranslatorConfig.STRING_TYPES_INTERFACE_NAME; + TypeDeclaration candidate = destinationModule.findType(name); + if (candidate == null) { + candidate = new TypeDeclaration(null, "interface", JSweetDefTranslatorConfig.STRING_TYPES_INTERFACE_NAME, + null, null, new Declaration[0]); + candidate.addModifier("public"); + destinationModule.addMember(candidate); + context.registerType(destinationModule + "." + name, candidate); + } + return candidate; + } + + private ModuleDeclaration getOrCreateModule(DeclarationContainer container, String name) { + ModuleDeclaration m = DeclarationHelper.findModule(container, name); + if (m == null) { + m = new ModuleDeclaration(null, name, new Declaration[0]); + container.addMember(m); + } + return m; + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/StringTypeExpander.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/StringTypeExpander.java new file mode 100644 index 00000000..f433d27a --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/StringTypeExpander.java @@ -0,0 +1,53 @@ +package org.jsweet.input.typescriptdef.visitor; + +import org.apache.commons.lang3.ArrayUtils; +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.DeclarationContainer; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.ast.TypedDeclaration; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; + +public class StringTypeExpander extends Scanner { + + public StringTypeExpander(Context context) { + super(context); + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + super.visitFunctionDeclaration(functionDeclaration); + redirectStringType(functionDeclaration); + DeclarationContainer container = getParent(DeclarationContainer.class); + expandStringParameters(container, functionDeclaration); + } + + private void expandStringParameters(DeclarationContainer container, FunctionDeclaration functionDeclaration) { + for (int i = functionDeclaration.getParameters().length - 1; i >= 0; i--) { + TypeReference t = functionDeclaration.getParameters()[i].getType(); + if ("string".equals(t.getName()) || "String".equals(t.getName())) { + redirectStringType(functionDeclaration.getParameters()[i]); + FunctionDeclaration newFunction = functionDeclaration.copy(); + newFunction.getParameters()[i].getType().setName(String.class.getName()); + if (!ArrayUtils.contains(container.getMembers(), newFunction)) { + container.addMember(newFunction); + expandStringParameters(container, newFunction); + } + } + } + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + redirectStringType(variableDeclaration); + } + + private void redirectStringType(TypedDeclaration declaration) { + if (declaration.getType() != null && ("string".equals(declaration.getType().getName()) || "String".equals(declaration.getType().getName()))) { + declaration.getType().setName(JSweetDefTranslatorConfig.LANG_PACKAGE + ".String"); + } + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/SuperTypesMerger.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/SuperTypesMerger.java new file mode 100644 index 00000000..a55a2233 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/SuperTypesMerger.java @@ -0,0 +1,122 @@ +package org.jsweet.input.typescriptdef.visitor; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.commons.lang3.ArrayUtils; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Declaration; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.Type; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeParameterDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; + +public class SuperTypesMerger extends Scanner { + + public SuperTypesMerger(Context context) { + super(context); + } + + private int injectedTypeCount = 0; + + private class TypeParameterSubstitutor extends Scanner { + + Map typeArgs; + + public TypeParameterSubstitutor(Context context, Map typeArgs) { + super(context); + this.typeArgs = typeArgs; + } + + @Override + public void visitTypeReference(TypeReference typeReference) { + if (typeArgs.containsKey(typeReference.getName())) { + typeReference.setName(typeArgs.get(typeReference.getName())); + } + super.visitTypeReference(typeReference); + } + + } + + private void injectSuperTypes(TypeDeclaration target) { + if (target.getSuperTypes() != null && target.getSuperTypes().length > 1) { + TypeReference[] superTypes = ArrayUtils.subarray(target.getSuperTypes(), 1, target.getSuperTypes().length); + for (TypeReference superType : superTypes) { + TypeDeclaration source = (TypeDeclaration) lookupType(superType, null); + if (source != null) { + if (target == source) { + // this can happen when lower-casing module names + // (classes get merged) + // this is a sort of potential bug, so we should support + // it at some point + // example: Express interfaces + context.reportWarning("ignore injecting supertype that resolves to the same target type: " + + context.getTypeName(target)); + continue; + } + injectSuperTypes(source); + target.addMergedSuperType(superType); + injectedTypeCount++; + if (context.verbose) { + logger.debug("injecting supertype " + superType + " into " + target); + } + Map typeArgs = new HashMap(); + if (source.getTypeParameters() != null) { + for (int i = 0; i < source.getTypeParameters().length; i++) { + Type t = null; + if (superType.getTypeArguments() != null && i < superType.getTypeArguments().length) { + t = lookupType(superType.getTypeArguments()[i], null); + } + typeArgs.put(source.getTypeParameters()[i].getName(), + t == null ? "java.lang.Object" : t.getName()); + } + } + for (Declaration declaration : source.getMembers()) { + if (declaration.isAnonymous() + || declaration.isHidden() + || ((declaration instanceof FunctionDeclaration) && ((FunctionDeclaration) declaration) + .isConstructor())) { + continue; + } + if ((declaration instanceof VariableDeclaration) + && target.findVariable(declaration.getName()) != null) { + continue; + } + Declaration d = declaration.copy(); + target.addMember(d); + new TypeParameterSubstitutor(context, typeArgs).scan(d); + } + } + } + target.setSuperTypes(new TypeReference[] { target.getSuperTypes()[0] }); + } + } + + @Override + public void visitTypeDeclaration(TypeDeclaration typeDeclaration) { + injectSuperTypes(typeDeclaration); + } + + @Override + public void visitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration) { + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + } + + @Override + public void onScanEnded() { + if (injectedTypeCount > 0) { + logger.debug(injectedTypeCount + " supertype(s) injected."); + } + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TupleTypeCreator.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TupleTypeCreator.java new file mode 100644 index 00000000..b068fd14 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TupleTypeCreator.java @@ -0,0 +1,89 @@ +package org.jsweet.input.typescriptdef.visitor; + +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.ast.CompilationUnit; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Declaration; +import org.jsweet.input.typescriptdef.ast.DeclarationContainer; +import org.jsweet.input.typescriptdef.ast.DeclarationHelper; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.ModuleDeclaration; +import org.jsweet.input.typescriptdef.ast.ParameterDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeParameterDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; + +/** + * Generates tuple types on the fly if built in Tuple[2-6] is not enough + * + * @author Renaud Pawlak + * + */ +public class TupleTypeCreator extends Scanner { + + public TupleTypeCreator(Context context) { + super(context); + } + + @Override + public void visitTypeReference(TypeReference typeReference) { + if (typeReference.isTuple() && typeReference.getTypeArguments().length > 6) { + getOrCreateUnionType(typeReference); + } + super.visitTypeReference(typeReference); + } + + private TypeDeclaration getOrCreateUnionType(TypeReference reference) { + CompilationUnit compilUnit = getParent(CompilationUnit.class); + ModuleDeclaration targetModule = getOrCreateModule(compilUnit, JSweetDefTranslatorConfig.TUPLE_CLASSES_PACKAGE); + + String name = reference.getName(); + TypeDeclaration tupleType = targetModule.findType(name); + if (tupleType == null) { + tupleType = createTupleType(reference); + targetModule.addMember(tupleType); + context.registerType(name, tupleType); + } + + return tupleType; + } + + private ModuleDeclaration getOrCreateModule(DeclarationContainer container, String name) { + ModuleDeclaration m = DeclarationHelper.findModule(container, name); + if (m == null) { + m = new ModuleDeclaration(null, name, new Declaration[0]); + container.addMember(m); + context.registerModule(name, m); + } + return m; + } + + private TypeDeclaration createTupleType(TypeReference reference) { + TypeParameterDeclaration[] typeParameters = new TypeParameterDeclaration[reference.getTypeArguments().length]; + for (int i = 0; i < reference.getTypeArguments().length; i++) { + typeParameters[i] = new TypeParameterDeclaration(null, "T" + i); + } + + TypeDeclaration tupleType = new TypeDeclaration(null, "class", reference.getSimpleName(), typeParameters, null, + null); + for (int i = 0; i < reference.getTypeArguments().length; i++) { + tupleType.addMember( + new VariableDeclaration(null, "$" + i, new TypeReference(null, typeParameters[i], null), false, false)); + } + + ParameterDeclaration[] parameters = new ParameterDeclaration[reference.getTypeArguments().length]; + for (int i = 0; i < reference.getTypeArguments().length; i++) { + parameters[i] = new ParameterDeclaration(null, "$" + i, new TypeReference(null, typeParameters[i], null), + false, false); + } + tupleType.addMember( + new FunctionDeclaration(null, FunctionDeclaration.NEW_FUNCTION_RESERVED_NAME, null, parameters, null)); + + tupleType.setDocumentation("/** This tuple type was automatically generated in order to accept " + + reference.getTypeArguments().length + " types. @see Tuple2 */"); + return tupleType; + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeKindChooser.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeKindChooser.java new file mode 100644 index 00000000..11de912d --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeKindChooser.java @@ -0,0 +1,47 @@ +package org.jsweet.input.typescriptdef.visitor; + +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; + +/** + * This scanner decides whether a type should be translated as a Java class or a + * Java interface. + * + * @author Renaud Pawlak + */ +public class TypeKindChooser extends Scanner { + + public TypeKindChooser(Context context) { + super(context); + } + + @Override + public void visitTypeDeclaration(TypeDeclaration typeDeclaration) { + if (!typeDeclaration.isAnonymous() && !"enum".equals(typeDeclaration.getKind()) + && !typeDeclaration.isExternal()) { + if (!(typeDeclaration.getKind().equals("interface") + && (typeDeclaration.getSuperTypes() == null || typeDeclaration.getSuperTypes().length == 0) + && typeDeclaration.getMembers().length == 1 && ((typeDeclaration.getMembers()[0] instanceof FunctionDeclaration) && ((FunctionDeclaration) typeDeclaration + .getMembers()[0]).isAnonymous()))) { + if (typeDeclaration.getKind().equals("interface")) { + typeDeclaration.addStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_INTERFACE); + typeDeclaration.addModifier("abstract"); + } + typeDeclaration.setKind("class"); + } + } + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeMacroReplacer.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeMacroReplacer.java new file mode 100644 index 00000000..af644df3 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeMacroReplacer.java @@ -0,0 +1,134 @@ +package org.jsweet.input.typescriptdef.visitor; + +import java.util.Arrays; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; +import org.jsweet.input.typescriptdef.TypescriptDef2Java; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.QualifiedDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeMacroDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.ast.TypedDeclaration; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; +import org.jsweet.input.typescriptdef.util.Util; + +/** + * This scanner replaces all references to TypeMacro with the referenced type + * + * @author Louis Grignon + */ +public class TypeMacroReplacer extends Scanner { + + private int referencesCount = 0; + + public TypeMacroReplacer(Context context) { + super(context); + } + + @Override + public void visitTypeMacro(TypeMacroDeclaration typeMacroDeclaration) { + String aliasQualifiedName = getCurrentContainerName(); + TypeReference actualType = typeMacroDeclaration.getType(); + + logger.debug("replacing type macro " + aliasQualifiedName + " with type " + actualType); + + // type macros need to be looked up first for cross-namespace usages... + new Scanner(this) { + public void visitTypeReference(TypeReference typeReference) { + if (typeReference.isStringType()) { + return; + } + lookupType(typeReference, null, TypescriptDef2Java.generateMissingTypes, true); + super.visitTypeReference(typeReference); + } + }.scan(typeMacroDeclaration.getType()); + TypeReferenceRedirector r = new TypeReferenceRedirector(context, typeMacroDeclaration, aliasQualifiedName); + r.scan(context.compilationUnits); + + referencesCount++; + + super.visitTypeMacro(typeMacroDeclaration); + } + + /** + * This scanner reset TypeReferences which still reference type copied from + * other packages even though this class has been copied + */ + // TODO : extract base type reference substitutor + private static class TypeReferenceRedirector extends Scanner { + + private String aliasQualifiedName; + TypeMacroDeclaration typeMacroDeclaration; + + public TypeReferenceRedirector(Context context, TypeMacroDeclaration typeMacroDeclaration, + String aliasQualifiedName) { + super(context); + this.typeMacroDeclaration = typeMacroDeclaration; + this.aliasQualifiedName = aliasQualifiedName; + } + + @Override + public void visitTypeReference(TypeReference typeReference) { + if (isTypeMacro(typeReference)) { + TypedDeclaration parent = getParent(TypedDeclaration.class); + logger.trace("subtituting " + typeReference + " with " + typeMacroDeclaration.getType()); + TypeReference ref = typeMacroDeclaration.getType().copy(true); + if (typeReference.isQualified()) { + new Scanner(context) { + public void visitTypeReference(TypeReference typeReference) { + if (typeReference.getDeclaration() instanceof TypeDeclaration) { + typeReference + .setName(context.getTypeName((TypeDeclaration) typeReference.getDeclaration())); + } + super.visitTypeReference(typeReference); + } + }.scan(ref); + } + Util.substituteTypeReference(this, parent, typeReference, ref); + // substitute macro's type parameters if any... + Util.findTypeParameters(this.context, typeMacroDeclaration, parent, (typeRef, typeParameter) -> { + int tparamIndex = ArrayUtils.indexOf(typeMacroDeclaration.getTypeParameters(), typeParameter); + if (tparamIndex < 0 || tparamIndex >= typeReference.getTypeArguments().length) { + logger.error("cannot find type parameter corresponding type argument for type macro: " + typeRef + + " for " + typeParameter); + return; + } + TypeReference targ = typeReference.getTypeArguments()[tparamIndex]; + if (targ == null) { + logger.error("type argument is null: " + tparamIndex + " in " + + Arrays.asList(typeReference.getTypeArguments())); + return; + } + typeRef.setDeclaration(targ.getDeclaration()); + typeRef.setName(targ.getName()); + typeRef.setTypeArguments(targ.getTypeArguments()); + }); + } else { + super.visitTypeReference(typeReference); + } + } + + private boolean isTypeMacro(TypeReference type) { + if (type != null && StringUtils.equals(type.getSimpleName(), typeMacroDeclaration.getName())) { + QualifiedDeclaration decl = lookupTypeDeclaration(type.getName()); + if (decl != null && (decl.getDeclaration() instanceof TypeMacroDeclaration) + && decl.getQualifiedDeclarationName().equals(aliasQualifiedName)) { + return true; + } + } + return false; + } + } + + @Override + public void onScanEnded() { + if (referencesCount > 0) { + logger.debug(referencesCount + " type macros redirected."); + System.out.println(context.findDeclarations(VariableDeclaration.class, "*.fieldWithUnion")); + } + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeMerger.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeMerger.java new file mode 100644 index 00000000..b6f9ff72 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeMerger.java @@ -0,0 +1,151 @@ +package org.jsweet.input.typescriptdef.visitor; + +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map.Entry; + +import org.apache.commons.lang3.ArrayUtils; +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; + +public class TypeMerger extends Scanner { + + private int mergedTypeCount = 0; + + public TypeMerger(Context context) { + super(context); + } + + private boolean isCoreMergeCandidate(String moduleName) { + if (moduleName.endsWith("." + JSweetDefTranslatorConfig.GLOBALS_PACKAGE_NAME) + || moduleName.equals(JSweetDefTranslatorConfig.LANG_PACKAGE) + || moduleName.equals(JSweetDefTranslatorConfig.DOM_PACKAGE)) { + return true; + } else if (context.libModules.contains(moduleName)) { + return true; + } else { + return false; + } + } + + @Override + public void visitTypeDeclaration(TypeDeclaration typeDeclaration) { + if (typeDeclaration.isExternal()) { + return; + } + String modName = getCurrentModuleName(); + String libModule = context.getLibModule(modName); + if (typeDeclaration.getName() != null) { + if (isCoreMergeCandidate(modName)) { + TypeDeclaration targetType = null; + targetType = context + .getTypeDeclaration(JSweetDefTranslatorConfig.LANG_PACKAGE + "." + typeDeclaration.getName()); + if (targetType == null) { + targetType = context.getTypeDeclaration( + JSweetDefTranslatorConfig.DOM_PACKAGE + "." + typeDeclaration.getName()); + } + boolean coreTarget = targetType != null; + if (targetType == null) { + // this is for cross lib merge (will not be applied on a + // per-lib + // generation strategy) + if (libModule != null) { + String libRelativePath = context.getLibRelativePath(modName); + List dependencies = context.dependencyGraph.getDestinationElements(libModule); + if (dependencies == null) { + context.reportError("cannot find dependency for module " + libModule + " (type " + + typeDeclaration + "): check dependecy graph initialization"); + } else { + for (String targetLibModule : context.dependencyGraph.getDestinationElements(libModule)) { + if (targetLibModule == null) { + continue; + } + if (modName.equals(libRelativePath)) { + targetType = context + .getTypeDeclaration(targetLibModule + "." + typeDeclaration.getName()); + } else { + targetType = context.getTypeDeclaration( + targetLibModule + "." + libRelativePath + "." + typeDeclaration.getName()); + } + if (targetType != null) { + break; + } + } + } + } + } + + if (targetType == typeDeclaration) { + return; + } + + if (targetType != null) { + if (libModule == null && coreTarget || libModule != null + && libModule.equals(context.getLibModule(context.getTypeName(targetType)))) { + mergeTypes(typeDeclaration, targetType); + } else { + logger.debug("add @Mixin annotation for cross-lib type: " + modName + "." + + typeDeclaration.getName() + "@" + typeDeclaration.getLocation() + " ==> " + + context.getTypeName(targetType) + "@" + targetType.getLocation()); + typeDeclaration.addStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_MIXIN + "(target=" + + context.getTypeName(targetType) + ".class)"); + context.resiterMixin(libModule, typeDeclaration); + // TODO: redirect references + } + } + } else { + if (Collections.frequency(context.getTypeNames().values(), context.getTypeName(typeDeclaration)) > 1) { + if (!"interface".equals(typeDeclaration.getOriginalKind())) { + context.reportWarning("duplicate type is not an interface: " + typeDeclaration + " at " + + typeDeclaration.getLocation()); + return; + } + for (Entry e : new HashSet<>(context.getTypeNames().entrySet())) { + if (e.getKey() == typeDeclaration + || !e.getValue().equals(context.getTypeName(typeDeclaration))) { + continue; + } + if (!"interface".equals(e.getKey().getOriginalKind())) { + context.reportWarning("duplicate type is not an interface: " + e.getKey() + " at " + + e.getKey().getLocation()); + return; + } + mergeTypes(e.getKey(), typeDeclaration); + } + } + } + } + + } + + private void mergeTypes(TypeDeclaration source, TypeDeclaration target) { + if (source == target) { + return; + } + logger.debug("merging types: " + context.getTypeName(source) + "@" + source.getLocation() + " ==> " + + context.getTypeName(target) + "@" + target.getLocation()); + mergedTypeCount++; + target.addMembers(source.getMembers()); + if (source.getSuperTypes() != null) { + if (target.getSuperTypes() != null) { + target.setSuperTypes(ArrayUtils.addAll(target.getSuperTypes(), source.getSuperTypes())); + } else { + target.setSuperTypes(source.getSuperTypes()); + } + } + source.setHidden(true); + context.unregisterType(source); + + } + + @Override + public void onScanEnded() { + if (mergedTypeCount > 0) { + logger.debug(mergedTypeCount + " type(s) merged."); + } + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeParametersSubstitutor.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeParametersSubstitutor.java new file mode 100644 index 00000000..995b6dda --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeParametersSubstitutor.java @@ -0,0 +1,99 @@ +package org.jsweet.input.typescriptdef.visitor; + +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.Type; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeParameterDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeParameterizedElement; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.ast.UnionTypeReference; +import org.jsweet.input.typescriptdef.ast.UnionTypeReference.Selected; + +public class TypeParametersSubstitutor extends Scanner { + + public TypeParametersSubstitutor(Context context) { + super(context); + } + + @Override + public void visitTypeDeclaration(TypeDeclaration typeDeclaration) { + visitTypeParameterizedElement(typeDeclaration); + super.visitTypeDeclaration(typeDeclaration); + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + visitTypeParameterizedElement(functionDeclaration); + super.visitFunctionDeclaration(functionDeclaration); + } + + @Override + public void visitTypeReference(TypeReference typeReference) { + new PrimitiveTypeSubstitutor(context).scan(typeReference.getTypeArguments()); + if (typeReference.getTypeArguments() != null) { + Type t = lookupType(typeReference, null); + if (t != null && (t instanceof TypeDeclaration)) { + TypeDeclaration typeDecl = (TypeDeclaration) t; + if (typeDecl.getTypeParameters() != null + && typeDecl.getTypeParameters().length == typeReference.getTypeArguments().length) { + for (int i = 0; i < typeReference.getTypeArguments().length; i++) { + if ("any".equals(typeReference.getTypeArguments()[i].getName())) { + TypeReference bound = typeDecl.getTypeParameters()[i].getUpperBound(); + if (bound != null && bound.getName() != null) { + typeReference.getTypeArguments()[i].setName(bound.getName()); + } + } + } + } + } + } + super.visitTypeReference(typeReference); + } + + @Override + public void visitUnionTypeReference(UnionTypeReference unionTypeReference) { + if (unionTypeReference.getSelected() == Selected.NONE) { + new PrimitiveTypeSubstitutor(context).scan(unionTypeReference.getTypes()); + } + super.visitUnionTypeReference(unionTypeReference); + } + + private void visitTypeParameterizedElement(TypeParameterizedElement element) { + if (element.getTypeParameters() == null) { + return; + } + for (TypeParameterDeclaration t : element.getTypeParameters()) { + if (t.getUpperBound() != null && t.getUpperBound().isArray()) { + t.setUpperBound(t.getUpperBound().getComponentType()); + } + } + new PrimitiveTypeSubstitutor(context).scan(element.getTypeParameters()); + } + + private class PrimitiveTypeSubstitutor extends Scanner { + + public PrimitiveTypeSubstitutor(Context context) { + super(context); + } + + @Override + public void visitTypeReference(TypeReference typeReference) { + String name = typeReference.getName(); + switch (name) { + case "boolean": + name = "Boolean"; + break; + case "number": + name = "Double"; + break; + case "void": + name = "Void"; + } + typeReference.setName(name); + super.visitTypeReference(typeReference); + } + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeReferenceChecker.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeReferenceChecker.java new file mode 100644 index 00000000..087badfc --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeReferenceChecker.java @@ -0,0 +1,22 @@ +package org.jsweet.input.typescriptdef.visitor; + +import org.jsweet.input.typescriptdef.TypescriptDef2Java; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeReference; + +public class TypeReferenceChecker extends Scanner { + + public TypeReferenceChecker(Context context) { + super(context); + } + + @Override + public void visitTypeReference(TypeReference typeReference) { + if (!"this".equals(typeReference.getName()) && !typeReference.isTypeOf()) { + lookupType(typeReference, null, TypescriptDef2Java.generateMissingTypes, true); + } + super.visitTypeReference(typeReference); + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeReferenceExpander.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeReferenceExpander.java new file mode 100644 index 00000000..39731840 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/TypeReferenceExpander.java @@ -0,0 +1,68 @@ +package org.jsweet.input.typescriptdef.visitor; + +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.Type; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.util.Util; + +/** + * This scanner expands the partial type references to fully qualified type + * references, so that it is unambiguous to Java. It the case JSWeet is not in + * JDK replacement mode, it also forces core types in the JSWeet's lang package + * to reference java.lang package core types. + * + * @author Renaud Pawlak + */ +public class TypeReferenceExpander extends Scanner { + + private int typeCount = 0; + + public TypeReferenceExpander(Context context) { + super(context); + } + + @Override + public void visitTypeReference(TypeReference typeReference) { + if (typeReference.getName() != null) { + if (!JSweetDefTranslatorConfig.isJDKReplacementMode() && !"any".equals(typeReference.getName()) + && Util.coreTypeMap.containsKey(typeReference.getName())) { + String name = Util.coreTypeMap.get(typeReference.getName()); + typeCount++; + if (context.verbose) { + logger.debug("WARNING: rewriting type ref " + typeReference.getName() + " -> " + name + " at " + + getCurrentToken().getLocation()); + } + typeReference.setName(name); + } else { + if (typeReference.getName().contains(".")) { + Type t = lookupType(typeReference, null); + if (t instanceof TypeDeclaration && !((TypeDeclaration) t).isExternal()) { + TypeDeclaration typeDeclaration = (TypeDeclaration) t; + String typeName = context.getTypeName(typeDeclaration); + if (!typeName.equals(typeReference.getName())) { + typeCount++; + if (context.verbose) { + logger.debug("WARNING: rewriting type ref " + typeReference.getName() + " -> " + + typeName + " at " + getCurrentToken().getLocation()); + } + typeReference.setName(typeName); + } + } + } + } + } + + super.visitTypeReference(typeReference); + } + + @Override + public void onScanEnded() { + if (typeCount > 0) { + logger.debug(typeCount + " type reference(s) rewritten/expanded."); + } + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/UnionInterfacesCreator.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/UnionInterfacesCreator.java new file mode 100644 index 00000000..0cdd3605 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/UnionInterfacesCreator.java @@ -0,0 +1,113 @@ +package org.jsweet.input.typescriptdef.visitor; + +import java.util.List; + +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.ast.CompilationUnit; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Declaration; +import org.jsweet.input.typescriptdef.ast.DeclarationContainer; +import org.jsweet.input.typescriptdef.ast.DeclarationHelper; +import org.jsweet.input.typescriptdef.ast.ModuleDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeParameterDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.ast.TypedDeclaration; +import org.jsweet.input.typescriptdef.ast.UnionTypeReference; +import org.jsweet.input.typescriptdef.util.Util; + +/** + * Generates union types on the fly if built in Union for two types is + * not enough + * + * @author Louis Grignon + * + */ +public class UnionInterfacesCreator extends Scanner { + + public UnionInterfacesCreator(Context context) { + super(context); + } + + @Override + public void visitUnionTypeReference(UnionTypeReference unionTypeReference) { + + boolean substituted = false; + List possibleTypes = unionTypeReference.getTypes(); + if (possibleTypes.size() > 1) { + logger.trace("replace union in " + getCurrentContainerName() + "." + getParent() + " types: " + + possibleTypes); + TypeReference parameterizedUnion = getUnionTypeReference(possibleTypes); + substituted = Util.substituteTypeReference(this, getParent(TypedDeclaration.class), unionTypeReference, + parameterizedUnion); + + if (substituted) { + scan(parameterizedUnion); + } else { + logger.warn("cannot replace: " + getCurrentContainerName() + "." + getParent() + " ===> union::" + + possibleTypes); + } + } + + if (!substituted) { + super.visitUnionTypeReference(unionTypeReference); + } + } + + private TypeReference getUnionTypeReference(List possibleTypes) { + if (possibleTypes.size() > 2) { + TypeDeclaration unionType = getOrCreateUnionType(possibleTypes); + return new TypeReference(null, unionType, possibleTypes.toArray(new TypeReference[0])); + } else { + // use fully qualified name for Union references to avoid clashes + // with user types + TypeReference t = new TypeReference(null, context.getTypeDeclaration(JSweetDefTranslatorConfig.UNION_CLASS_NAME), + possibleTypes.toArray(new TypeReference[0])); + t.setName(JSweetDefTranslatorConfig.UNION_CLASS_NAME); + return t; + } + } + + private TypeDeclaration getOrCreateUnionType(List possibleTypes) { + CompilationUnit compilUnit = getParent(CompilationUnit.class); + ModuleDeclaration targetModule = getOrCreateModule(compilUnit, JSweetDefTranslatorConfig.UNION_PACKAGE); + + String name = "Union" + possibleTypes.size(); + TypeDeclaration unionType = targetModule.findType(name); + if (unionType == null) { + unionType = createUnionType(name, possibleTypes.size()); + targetModule.addMember(unionType); + context.registerType(JSweetDefTranslatorConfig.UNION_PACKAGE + "." + name, unionType); + } + + return unionType; + } + + private ModuleDeclaration getOrCreateModule(DeclarationContainer container, String name) { + ModuleDeclaration m = DeclarationHelper.findModule(container, name); + if (m == null) { + m = new ModuleDeclaration(null, name, new Declaration[0]); + container.addMember(m); + context.registerModule(name, m); + } + return m; + } + + private TypeDeclaration createUnionType(String name, int parameterCount) { + TypeParameterDeclaration[] typeParameters = new TypeParameterDeclaration[parameterCount]; + for (int i = 0; i < parameterCount; i++) { + typeParameters[i] = new TypeParameterDeclaration(null, "T" + (i + 1)); + } + + TypeReference superType = new TypeReference(null, "Union", new TypeReference[] { + new TypeReference(null, "any", null), new TypeReference(null, "any", null) }); + + TypeDeclaration unionType = new TypeDeclaration(null, "interface", name, typeParameters, + new TypeReference[] { superType }, null); + unionType.setDocumentation("/** This union type was automatically generated in order to accept " + + parameterCount + " types. @see Union */"); + return unionType; + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/UnionTypesEraser.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/UnionTypesEraser.java new file mode 100644 index 00000000..acda11a4 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/UnionTypesEraser.java @@ -0,0 +1,46 @@ +package org.jsweet.input.typescriptdef.visitor; + +import java.util.List; + +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.ast.TypedDeclaration; +import org.jsweet.input.typescriptdef.ast.UnionTypeReference; +import org.jsweet.input.typescriptdef.util.Util; + +/** + * Remove too big union types because it makes Java APIs look awfull. + * + * @author Renaud Pawlak + */ +public class UnionTypesEraser extends Scanner { + + public UnionTypesEraser(Context context) { + super(context); + } + + @Override + public void visitUnionTypeReference(UnionTypeReference unionTypeReference) { + + boolean substituted = false; + List possibleTypes = unionTypeReference.getTypes(); + if (possibleTypes.size() > 3) { + logger.trace("replace union in " + getCurrentContainerName() + "." + getParent() + " types: " + + possibleTypes); + TypeReference any = new TypeReference(null, "any", null); + substituted = Util.substituteTypeReference(this, getParent(TypedDeclaration.class), unionTypeReference, + any); + + if (!substituted) { + logger.warn("cannot replace: " + getCurrentContainerName() + "." + getParent() + " ===> union::" + + possibleTypes); + } + } + + if (!substituted) { + super.visitUnionTypeReference(unionTypeReference); + } + } + +} diff --git a/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/UnionTypesExpander.java b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/UnionTypesExpander.java new file mode 100644 index 00000000..3eba5bc5 --- /dev/null +++ b/jsweet-candy-generator/src/main/java/org/jsweet/input/typescriptdef/visitor/UnionTypesExpander.java @@ -0,0 +1,146 @@ +package org.jsweet.input.typescriptdef.visitor; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; + +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Declaration; +import org.jsweet.input.typescriptdef.ast.DeclarationContainer; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.Scanner; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.ast.UnionTypeReference; +import org.jsweet.input.typescriptdef.ast.UnionTypeReference.Selected; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; + +public class UnionTypesExpander extends Scanner { + + public UnionTypesExpander(Context context) { + super(context); + } + + class UnionScanner extends Scanner { + + Declaration declaration; + Selected target; + + public UnionScanner(Context context, Declaration declaration, Selected target) { + super(context); + this.declaration = declaration; + this.target = target; + expandedDeclarations.add(declaration); + } + + public void scan() { + this.scan(this.declaration); + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + scan(functionDeclaration.getTypeParameters()); + scan(functionDeclaration.getParameters()); + } + + @Override + public void visitUnionTypeReference(UnionTypeReference unionTypeReference) { + switch (unionTypeReference.getSelected()) { + case NONE: + unionTypeReference.setSelected(Selected.PENDING); + new UnionScanner(context, declaration.copy(), target.inverse()).scan(); + unionTypeReference.setSelected(target); + break; + case PENDING: + unionTypeReference.setSelected(target); + break; + default: + } + super.visitUnionTypeReference(unionTypeReference); + } + } + + class RevertUnionScanner extends Scanner { + + Declaration declaration; + + public RevertUnionScanner(Context context, Declaration declaration) { + super(context); + this.declaration = declaration; + } + + public void scan() { + this.scan(this.declaration); + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + scan(functionDeclaration.getTypeParameters()); + scan(functionDeclaration.getParameters()); + } + + @Override + public void visitUnionTypeReference(UnionTypeReference unionTypeReference) { + unionTypeReference.setSelected(Selected.NONE); + super.visitUnionTypeReference(unionTypeReference); + } + } + + private Declaration currentDeclaration; + private Set expandedDeclarations = new HashSet(); + + private void addExpandedDeclarations() { + DeclarationContainer parent = getParent(DeclarationContainer.class); + for (Declaration d : expandedDeclarations) { + if (d != this.currentDeclaration) { + if (context.verbose) { + logger.info("adding union-expanded declaration: " + parent + "." + d); + } + parent.addMember(d); + } + } + } + + @Override + public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) { + this.currentDeclaration = functionDeclaration; + expandedDeclarations.clear(); + new UnionScanner(context, functionDeclaration, Selected.LEFT).scan(); + if (expandedDeclarations.size() > 40) { + // too much complexity... we revert expansion + new RevertUnionScanner(context, functionDeclaration).scan(); + return; + } + for (Declaration d1 : new ArrayList<>(expandedDeclarations)) { + FunctionDeclaration f1 = (FunctionDeclaration) d1; + for (Declaration d2 : new ArrayList<>(expandedDeclarations)) { + FunctionDeclaration f2 = (FunctionDeclaration) d2; + if (f1 == f2) { + continue; + } + boolean equal = true; + for (int i = 0; i < f1.getParameters().length; i++) { + TypeReference t1 = f1.getParameters()[i].getType(); + TypeReference t2 = f2.getParameters()[i].getType(); + if (!t1.toString().equals(t2.toString())) { + equal = false; + break; + } + } + if (!equal) { + continue; + } + if (!f1.getType().toString().equals(f2.getType().toString())) { + continue; + } + expandedDeclarations.remove(f1); + break; + } + } + addExpandedDeclarations(); + } + + @Override + public void visitVariableDeclaration(VariableDeclaration variableDeclaration) { + } + +} diff --git a/jsweet-candy-generator/src/main/resources/DefinitelyTypedLicense b/jsweet-candy-generator/src/main/resources/DefinitelyTypedLicense new file mode 100644 index 00000000..91e06df8 --- /dev/null +++ b/jsweet-candy-generator/src/main/resources/DefinitelyTypedLicense @@ -0,0 +1,8 @@ +This project is licensed under the MIT license. +Copyrights are respective of each contributor listed at the beginning of each definition file. + +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. \ No newline at end of file diff --git a/jsweet-candy-generator/src/main/resources/TypeScriptLicense b/jsweet-candy-generator/src/main/resources/TypeScriptLicense new file mode 100644 index 00000000..490b5c70 --- /dev/null +++ b/jsweet-candy-generator/src/main/resources/TypeScriptLicense @@ -0,0 +1,53 @@ +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: + +You must give any other recipients of the Work or Derivative Works a copy of this License; and +You must cause any modified files to carry prominent notices stating that You changed the files; and +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 +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 \ No newline at end of file diff --git a/jsweet-candy-generator/src/main/resources/application.properties b/jsweet-candy-generator/src/main/resources/application.properties new file mode 100644 index 00000000..d2fe03eb --- /dev/null +++ b/jsweet-candy-generator/src/main/resources/application.properties @@ -0,0 +1,3 @@ +# application.properties +application.name=${pom.name} +application.version=${pom.version} \ No newline at end of file diff --git a/jsweet-candy-generator/src/main/resources/log4j.properties b/jsweet-candy-generator/src/main/resources/log4j.properties new file mode 100644 index 00000000..a1035bd2 --- /dev/null +++ b/jsweet-candy-generator/src/main/resources/log4j.properties @@ -0,0 +1,8 @@ +# Root logger option +log4j.rootLogger=DEBUG, stdout + +# Direct log messages to stdout +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.sss} %-5p %c{1}:%L - %m%n diff --git a/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/AbstractTest.java b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/AbstractTest.java new file mode 100644 index 00000000..89ed192b --- /dev/null +++ b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/AbstractTest.java @@ -0,0 +1,99 @@ +package org.jsweet.input.typescriptdef.test; + +import static java.util.Arrays.asList; + +import java.io.File; +import java.io.FileNotFoundException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + +import org.apache.log4j.Logger; +import org.jsweet.input.typescriptdef.TypescriptDef2Java; +import org.jsweet.input.typescriptdef.ast.CompilationUnit; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.parser.TypescriptDefParser; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.rules.TestName; + +public abstract class AbstractTest { + + protected final Logger logger = Logger.getLogger(getClass()); + + @Rule + public final TestName testNameRule = new TestName(); + + protected File getTestFile(String name) { + return new File("./src/test/java/" + getClass().getPackage().getName().replace('.', '/'), name + ".d.ts"); + } + + protected final String getCurrentTestName() { + return getClass().getSimpleName() + "." + testNameRule.getMethodName(); + } + + protected Context parseAndTranslateTestFile(String testFilePath) throws FileNotFoundException { + return parseAndTranslateTestFile(testFilePath, null); + } + + protected Context parseAndTranslateTestFile(String testFilePath, Consumer afterParse) + throws FileNotFoundException { + return parseAndTranslateTestFile(testFilePath, afterParse, false); + } + + protected Context parseTestFile(String testFilePath) throws FileNotFoundException { + return parseTestFile(testFilePath, false); + } + + protected Context parseTestFile(String testFilePath, boolean includeCoreLib) throws FileNotFoundException { + File testFile = getTestFile(testFilePath); + + TypescriptDefParser parser = TypescriptDefParser.parseFile(testFile); + Assert.assertEquals("unexpected syntax errors", 0, parser.errors.size()); + + List compilationUnits = new ArrayList<>(); + compilationUnits.add(parser.compilationUnit); + List dependencies = new ArrayList<>(); + if (includeCoreLib) { + try { + URL libCoreURL = getClass().getClassLoader().getResource(TypescriptDef2Java.TS_CORE_LIB_DIR); + File libCoreDir = new File(libCoreURL.toURI()); + for (File lib : libCoreDir.listFiles()) { + if (lib.isFile()) { + dependencies.add(lib); + compilationUnits.add(TypescriptDefParser.parseFile(lib).compilationUnit); + } + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + Context context = new Context(asList(testFile), dependencies, false); + context.verbose = false; + context.compilationUnits = compilationUnits; + return context; + } + + protected Context parseAndTranslateTestFile(String testFilePath, Consumer afterParse, + boolean includeCoreLib) throws FileNotFoundException { + Context context = parseTestFile(testFilePath, includeCoreLib); + if (afterParse != null) { + afterParse.accept(context); + } + translateAst(context); + return context; + } + + protected void translateAst(Context context) { + TypescriptDef2Java.translateAst(context); + Assert.assertEquals("unexpected translation errors", 0, context.getErrorCount()); + } + + @Before + public void setUp() { + logger.info("*********************** " + getCurrentTestName() + " ***********************"); + } + +} diff --git a/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/PackagingTest.java b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/PackagingTest.java new file mode 100644 index 00000000..9df2d37e --- /dev/null +++ b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/PackagingTest.java @@ -0,0 +1,186 @@ +package org.jsweet.input.typescriptdef.test; + +import static java.util.Arrays.asList; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.util.DirectedGraph; +import org.jsweet.input.typescriptdef.util.Tree; +import org.jsweet.input.typescriptdef.util.Tree.Matcher; +import org.jsweet.input.typescriptdef.util.Util; +import org.junit.Test; + +public class PackagingTest { + + + // angular2 => 3 modules + // angularjs => 7 modules + // atom => 2 modules + // bingmaps => 7 modules + // angular2 => modules + // business-rules-engine => 4 modules + // chrome => 3 modules + // cordova => 2 + plugins + // cordova-ionic => ? + // codemirror => 3 package merge + // d3 => plugins + // datejs => modules + // dojo => 64 modules + // durandal => legacy!! + // estree => 2 module merge + // firebase => merge + // freedom => globals merge + // gihub-electron => 4 module merge + // gsap => 3 toplevel merge + // highcharts => 2 tolevel merge + // iscroll => legacy + 2 toplevel merge + @Test + public void testTypings() { + File[] groupFiles = new File(JSweetDefTranslatorConfig.TS_LIBS_DIR_NAME).listFiles(); + Map counts = new HashMap<>(); + List projects = new ArrayList(); + List notContainingProjects = new ArrayList(); + for (File group : groupFiles) { + String[] files = group.list(); + boolean contains = false; + if (files != null) { + for (String s : files) { + if (s.equals(group.getName() + ".d.ts")) { + contains = true; + } + } + } + if (!contains) { + notContainingProjects.add(group.getName()); + } + int n = files == null ? 0 : files.length; + if (n > 1) { + projects.add(group.getName() + " (" + n + ")"); + } + Integer currentCount = counts.get(n); + if (currentCount == null) { + currentCount = 1; + } else { + currentCount++; + } + counts.put(n, currentCount); + } + System.out.println("=> " + counts); + System.out.println("=> " + ((((double) projects.size()) / groupFiles.length) * 100) + "%"); + System.out.println("=> " + projects); + System.out.println("=> " + ((((double) notContainingProjects.size()) / groupFiles.length) * 100) + "%" + " - " + + notContainingProjects); + } + + @Test + public void testDirectedGraph() { + DirectedGraph g = new DirectedGraph(); + g.add(7, 5, 3, 11, 8, 2, 9, 10); + g.buildEdges(new Comparator() { + @Override + public int compare(Integer o1, Integer o2) { + if (o1 == 5 && o2 == 3) { + return 1; + } + if (o1 == 9 && o2 == 11) { + return 1; + } + return 0; + } + }); + assertEquals(asList(5), g.getDestinationElements(3)); + List sorted = g.topologicalSort(null); + assertTrue(sorted.indexOf(5) > sorted.indexOf(3)); + assertTrue(sorted.indexOf(9) > sorted.indexOf(11)); + assertEquals(asList(5), g.getDestinationElements(3)); + } + + @Test + public void testTree() { + Tree root = new Tree(null); + Tree t = root.addChildElement("a"); + assertEquals(root, t.getParentTree()); + assertEquals(asList("a"), root.getChildElements()); + root.addPath(asList("a", "a")); + root.addPath(asList("a", "b")); + root.addPath(asList("a", "c")); + assertEquals(asList("a"), root.getChildElements()); + assertEquals(asList("a", "b", "c"), t.getChildElements()); + final StringBuffer output = new StringBuffer(); + new Tree.Scanner() { + protected boolean enter(Tree tree) { + output.append(tree.getElement()); + if ("c".equals(tree.getElement())) { + assertEquals(stack.size(), 2); + } + return true; + } + }.scan(root); + assertEquals("nullaabc", output.toString()); + } + + @Test + public void testMatcher() { + Tree root = new Tree("root"); + Tree t = root.addChildElement("a"); + assertEquals(root, t.getParentTree()); + assertEquals(asList("a"), root.getChildElements()); + root.addPath(asList("a", "a")); + root.addPath(asList("a", "b")); + root.addPath(asList("a", "c")); + + assertEquals(asList("a"), root.getChildElements()); + assertEquals(asList("a", "b", "c"), t.getChildElements()); + assertTrue(new Matcher("root", "a").matches(root)); + assertFalse(new Matcher("root", "c").matches(root)); + assertFalse(new Matcher("!root").matches(root)); + assertTrue(new Matcher("root", "!b").matches(root)); + assertTrue(new Matcher("root", "a", "a").matches(root)); + assertTrue(new Matcher("root", "a", "!d").matches(root)); + assertFalse(new Matcher("root", "a", "d").matches(root)); + + List path = asList("root", "a", "b"); + + assertTrue(new Matcher("root", "a").matches(path)); + assertFalse(new Matcher("root", "c").matches(path)); + assertFalse(new Matcher("!root").matches(path)); + assertTrue(new Matcher("root", "!b").matches(path)); + assertFalse(new Matcher("root", "a", "a").matches(path)); + assertTrue(new Matcher("root", "a", "!d").matches(path)); + assertFalse(new Matcher("root", "a", "d").matches(path)); + + } + + @Test + public void testPackageNameForTypings() { + assertEquals("def.angular2", + Util.getLibPackageNameFromTsDefFile(new File("typings/angular2/http.d.ts"))); + assertEquals("def.any_db", Util.getLibPackageNameFromTsDefFile(new File( + "typings/any-db/any-db.d.ts"))); + assertEquals("def.any_db_transaction", Util.getLibPackageNameFromTsDefFile(new File( + "typings/any-db-transaction/any-db-transaction.d.ts"))); + assertEquals("def.js_cookie", Util.getLibPackageNameFromTsDefFile(new File( + "typings/js-cookie/js-cookie.d.ts"))); + assertEquals("def.js_data", Util.getLibPackageNameFromTsDefFile(new File( + "typings/js-data/js-data.d.ts"))); + assertEquals("def.js_data_angular", Util.getLibPackageNameFromTsDefFile(new File( + "typings/js-data-angular/js-data-angular.d.ts"))); + assertEquals("def.jquery_cookie", Util.getLibPackageNameFromTsDefFile(new File( + "typings/jquery.cookie/jquery.cookie.d.ts"))); + assertEquals("def.angularjs", Util.getLibPackageNameFromTsDefFile(new File( + "typings/angularjs/angular.d.ts"))); + assertEquals("def.angularjs", Util.getLibPackageNameFromTsDefFile(new File( + "typings/angularjs/angular-route.d.ts"))); + + } + +} diff --git a/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/StructureTest.java b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/StructureTest.java new file mode 100644 index 00000000..67601297 --- /dev/null +++ b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/StructureTest.java @@ -0,0 +1,47 @@ +package org.jsweet.input.typescriptdef.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.io.FileNotFoundException; + +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.ModuleDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; +import org.junit.Test; + +public class StructureTest extends AbstractTest { + + @Test + public void globalsTest() throws FileNotFoundException { + Context context = parseAndTranslateTestFile("structure/globals-test", (c) -> { + assertNotNull(c.findFirstDeclaration(FunctionDeclaration.class, "m1.m11.f111")); + } , false); + + assertEquals(1, context.findDeclarations(ModuleDeclaration.class, "def.structure.m1").size()); + assertEquals(1, context.findDeclarations(ModuleDeclaration.class, "def.structure.m1.m11").size()); + + assertEquals(1, + context.findDeclarations(FunctionDeclaration.class, "def.structure.m1.m11.Globals.f111").size()); + + assertEquals(1, context.findDeclarations(FunctionDeclaration.class, "def.structure.m1.Utils.f").size()); + + assertEquals(0, context.findDeclarations(FunctionDeclaration.class, "def.structure.m1.Utils2.f").size()); + + } + + @Test + public void constructorInterfaceTest() throws FileNotFoundException { + Context context = parseAndTranslateTestFile("structure/constructor-interface-test", (c) -> { + assertNotNull(c.findFirstDeclaration(FunctionDeclaration.class, "test.Math.abs")); + } , false); + + assertEquals(1, context.findDeclarations(TypeDeclaration.class, "def.structure.test.Math").size()); + assertEquals(true, context.findFirstDeclaration(FunctionDeclaration.class, "def.structure.test.Math.abs") + .getDeclaration().hasModifier("static")); + assertEquals(0, context.findDeclarations(VariableDeclaration.class, "def.structure.test.Globals.Math").size()); + } + +} diff --git a/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/SyntaxTest.java b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/SyntaxTest.java new file mode 100644 index 00000000..8adbd6f5 --- /dev/null +++ b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/SyntaxTest.java @@ -0,0 +1,88 @@ +package org.jsweet.input.typescriptdef.test; + +import static org.junit.Assert.assertEquals; + +import java.io.FileNotFoundException; + +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.Declaration; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.QualifiedDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; +import org.junit.Assert; +import org.junit.Test; + +public class SyntaxTest extends AbstractTest { + + @Test + public void defaultTest() throws FileNotFoundException { + Context context = parseTestFile("syntax/default-test"); + assertEquals("boolean", context.findFirstDeclaration(FunctionDeclaration.class, "*.Array.isArray") + .getDeclaration().getType().getName()); + } + + @Test + public void enumTest() throws FileNotFoundException { + parseTestFile("syntax/enum-test"); + } + + @Test + public void comment1Test() throws FileNotFoundException { + Context context = parseTestFile("syntax/comment1-test"); + Declaration declaration = context.findFirstDeclaration(TypeDeclaration.class, "I").getDeclaration(); + Assert.assertTrue(declaration.getDocumentation() != null + && declaration.getDocumentation().contains("Comment I")); + declaration = context.findFirstDeclaration(TypeDeclaration.class, "Navigator").getDeclaration(); + Assert.assertNull(declaration.getDocumentation()); + declaration = context.findFirstDeclaration(VariableDeclaration.class, "Navigator.accelerometer") + .getDeclaration(); + Assert.assertTrue(declaration.getDocumentation() != null + && declaration.getDocumentation().contains("Comment 1")); + declaration = context.findFirstDeclaration(VariableDeclaration.class, "Navigator.camera").getDeclaration(); + Assert.assertNull(declaration.getDocumentation()); + } + + @Test + public void comment2Test() throws FileNotFoundException { + Context context = parseTestFile("syntax/comment2-test"); + for (QualifiedDeclaration declaration : context.findDeclarations(Declaration.class, "*")) { + if (!declaration.getDeclaration().isAnonymous()) { + Assert.assertNotNull("member '" + declaration.getDeclaration().getName() + + "' should have a documentation", declaration.getDeclaration().getDocumentation()); + } + } + } + + @Test + public void comment3Test() throws FileNotFoundException { + Context context = parseTestFile("syntax/comment3-test"); + for (QualifiedDeclaration declaration : context.findDeclarations(Declaration.class, "*")) { + Assert.assertTrue( + "member '" + declaration.getDeclaration().getName() + "' has wrong documentation", + declaration.getDeclaration().getDocumentation() != null + && declaration.getDeclaration().getDocumentation() + .contains("$" + declaration.getDeclaration().getName() + "$")); + } + } + + @Test + public void keywordTest() throws FileNotFoundException { + parseTestFile("syntax/keyword-test"); + } + + @Test + public void lfTest() throws FileNotFoundException { + parseTestFile("syntax/lf-test"); + } + + @Test + public void identifierTest() throws FileNotFoundException { + parseTestFile("syntax/identifier-test"); + } + + @Test + public void exportTest() throws FileNotFoundException { + parseTestFile("syntax/export-test"); + } +} diff --git a/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/TranslationTest.java b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/TranslationTest.java new file mode 100644 index 00000000..5fb801a6 --- /dev/null +++ b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/TranslationTest.java @@ -0,0 +1,509 @@ +package org.jsweet.input.typescriptdef.test; + +import static java.util.Arrays.asList; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.FileNotFoundException; +import java.util.List; + +import org.jsweet.JSweetDefTranslatorConfig; +import org.jsweet.input.typescriptdef.ast.ArrayTypeReference; +import org.jsweet.input.typescriptdef.ast.Context; +import org.jsweet.input.typescriptdef.ast.FunctionDeclaration; +import org.jsweet.input.typescriptdef.ast.FunctionalTypeReference; +import org.jsweet.input.typescriptdef.ast.ModuleDeclaration; +import org.jsweet.input.typescriptdef.ast.NamedElement; +import org.jsweet.input.typescriptdef.ast.ParameterDeclaration; +import org.jsweet.input.typescriptdef.ast.QualifiedDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeMacroDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeParameterDeclaration; +import org.jsweet.input.typescriptdef.ast.TypeReference; +import org.jsweet.input.typescriptdef.ast.UnionTypeReference; +import org.jsweet.input.typescriptdef.ast.VariableDeclaration; +import org.jsweet.input.typescriptdef.visitor.FunctionalInterfacesCreator; +import org.junit.Assert; +import org.junit.Test; + +public class TranslationTest extends AbstractTest { + + @Test + public void defaultTest() throws FileNotFoundException { + Context context = parseAndTranslateTestFile("types/default-test", (c) -> { + assertNotNull(c.findFirstDeclaration(TypeDeclaration.class, "*.DateConstructor")); + } , true); + + assertEquals(3, context.findDeclarations(ModuleDeclaration.class, "def.types.a.b.*").size()); + assertEquals(3, context.findDeclarations(ModuleDeclaration.class, "*.a.b.*").size()); + assertEquals(3, context.findDeclarations(ModuleDeclaration.class, "def.types.*.c*").size()); + assertEquals(1, context.findDeclarations(ModuleDeclaration.class, "*.c1").size()); + assertContains(context.findDeclarations(ModuleDeclaration.class, "*").stream().map(d -> d.getDeclaration()) + .toArray(size -> new NamedElement[size]), JSweetDefTranslatorConfig.LANG_PACKAGE); + assertContains(context.findDeclarations(ModuleDeclaration.class, "*").stream().map(d -> d.getDeclaration()) + .toArray(size -> new NamedElement[size]), JSweetDefTranslatorConfig.DOM_PACKAGE); + + ModuleDeclaration module = context.findFirstDeclaration(ModuleDeclaration.class, "def.types.m") + .getDeclaration(); + TypeDeclaration typedImpl = module.findType("TypedImpl"); + assertEquals(typedImpl, + context.findFirstDeclaration(TypeDeclaration.class, "def.types.m.TypedImpl").getDeclaration()); + TypeReference typedRef = typedImpl.getSuperTypes()[0]; + assertEquals("Typed", typedRef.getName()); + assertEquals("String", typedRef.getTypeArguments()[0].getName()); + assertEquals("any", typedRef.getTypeArguments()[1].getName()); + assertEquals("Double", typedRef.getTypeArguments()[2].getName()); + + assertNull(context.findFirstDeclaration(VariableDeclaration.class, "*.field-with-dashes")); + + VariableDeclaration var = context.findFirstDeclaration(VariableDeclaration.class, "*.field_with_dashes") + .getDeclaration(); + assertNotNull(var); + assertTrue(var.hasStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_NAME)); + assertTrue(var.getStringAnnotation(JSweetDefTranslatorConfig.ANNOTATION_NAME).contains("field-with-dashes")); + + assertNotNull(context.findFirstDeclaration(ModuleDeclaration.class, "*.module_with_dashes")); + assertNotNull(context.findFirstDeclaration(ModuleDeclaration.class, "*.module_with_slashes")); + + assertNull(context.findFirstDeclaration(TypeDeclaration.class, "*.DateConstructor")); + TypeDeclaration dateType = context.findFirstDeclaration(TypeDeclaration.class, "*.Date").getDeclaration(); + assertTrue(!dateType.getModifiers().contains("abstract")); + + assertNotNull(context.findFirstDeclaration(FunctionDeclaration.class, "def.types.events.Globals.myFunction")); + assertNull(context.findFirstDeclaration(VariableDeclaration.class, "def.types.Globals.myFunction2")); + assertNotNull(context.findFirstDeclaration(FunctionDeclaration.class, "def.types.Globals.myFunction2")); + + } + + @Test + public void typeMacroTest() throws FileNotFoundException { + String testFilePath = "types/type-macro-test"; + Context context = parseAndTranslateTestFile(testFilePath, (c) -> { + // TYPE PARAMETERS IN FUNCTIONAL TYPES + TypeMacroDeclaration m = c.findFirstDeclaration(TypeMacroDeclaration.class, "*.GenericType") + .getDeclaration(); + assertNotNull(((FunctionalTypeReference) m.getType()).getTypeParameters()); + assertEquals("T1", ((FunctionalTypeReference) m.getType()).getTypeParameters()[0].getName()); + assertEquals("T2", ((FunctionalTypeReference) m.getType()).getTypeParameters()[1].getName()); + }); + + String basePackage = "def.types.typemacrotests"; + + TypeMacroDeclaration typeMacro = context + .findFirstDeclaration(TypeMacroDeclaration.class, basePackage + ".HTMLElement").getDeclaration(); + TypeReference typeMacroTypeArg = typeMacro.getType().getTypeArguments()[0]; + + TypeDeclaration enclosingTypeDecl = context + .findFirstDeclaration(TypeDeclaration.class, basePackage + ".EnclosingInterface").getDeclaration(); + TypeReference fieldType = enclosingTypeDecl.findVariable("field").getType(); + assertEquals(enclosingTypeDecl.findVariable("field"), + context.findFirstDeclaration(VariableDeclaration.class, basePackage + ".EnclosingInterface.field") + .getDeclaration()); + + logger.info("resulting type macro: " + fieldType); + assertEquals(typeMacro.getType(), fieldType); + assertEquals(typeMacroTypeArg, fieldType.getTypeArguments()[0]); + + TypeReference fieldGenericsType = enclosingTypeDecl.findVariable("fieldGenerics").getType(); + logger.info("resulting type macro: " + fieldGenericsType); + assertEquals("BaseTypedElement", fieldGenericsType.getName()); + assertEquals(1, fieldGenericsType.getTypeArguments().length); + assertEquals(typeMacro.getType(), fieldGenericsType.getTypeArguments()[0]); + assertEquals(typeMacroTypeArg, fieldGenericsType.getTypeArguments()[0].getTypeArguments()[0]); + + // WITH PARAM AND RETURN + boolean foundMacro = false; + List> l = context.findDeclarations(FunctionDeclaration.class, + "*.methodWithParam"); + assertEquals(3, l.size()); + + l = context.findDeclarations(FunctionDeclaration.class, "*.methodWithReturn"); + assertEquals(1, l.size()); + FunctionDeclaration methodWithReturn = enclosingTypeDecl.findFirstFunction("methodWithReturn"); + assertEquals(typeMacro.getType(), methodWithReturn.getType()); + assertEquals(typeMacroTypeArg, methodWithReturn.getType().getTypeArguments()[0]); + + // WITH UNION + TypeReference fieldWithUnionType = enclosingTypeDecl.findVariable("fieldWithUnion").getType(); + assertEquals("Union3", fieldWithUnionType.getName()); + assertContains(fieldWithUnionType.getTypeArguments(), "String"); + assertContains(fieldWithUnionType.getTypeArguments(), "Double"); + foundMacro = false; + for (TypeReference typeArg : fieldWithUnionType.getTypeArguments()) { + if (typeArg.getName().equals("DOMElement") && typeArg.getTypeArguments().length == 1 + && typeArg.getTypeArguments()[0].getName().equals("HTMLAttributes")) { + foundMacro = true; + break; + } + } + assertTrue("did not find substituted macro in " + fieldWithUnionType, foundMacro); + + TypeReference fieldWithGenericsAndUnionType = enclosingTypeDecl.findVariable("fieldWithGenericsAndUnion") + .getType(); + assertEquals("BaseTypedElement", fieldWithGenericsAndUnionType.getName()); + assertEquals(1, fieldWithGenericsAndUnionType.getTypeArguments().length); + TypeReference fieldWithGenericTypeArg = fieldWithGenericsAndUnionType.getTypeArguments()[0]; + assertEquals("Union3", fieldWithGenericTypeArg.getName()); + assertContains(fieldWithGenericTypeArg.getTypeArguments(), "String"); + assertContains(fieldWithGenericTypeArg.getTypeArguments(), "Double"); + foundMacro = false; + for (TypeReference typeArg : fieldWithGenericTypeArg.getTypeArguments()) { + if (typeArg.getName().equals("DOMElement") && typeArg.getTypeArguments().length == 1 + && typeArg.getTypeArguments()[0].getName().equals("HTMLAttributes")) { + foundMacro = true; + break; + } + } + assertTrue("did not find substituted macro in " + fieldWithGenericsAndUnionType, foundMacro); + + VariableDeclaration d = context.findFirstDeclaration(VariableDeclaration.class, "*.reactNode").getDeclaration(); + assertNotNull(d); + // UNIONS ARE NOW LIMITED TO 3 + // assertEquals("Union6", d.getType().getName()); + // assertEquals("Array", d.getType().getTypeArguments()[4].getName()); + // assertEquals("Union5", + // d.getType().getTypeArguments()[4].getTypeArguments()[0].getName()); + assertEquals("any", d.getType().getName()); + + l = context.findDeclarations(FunctionDeclaration.class, "*.Test.forEach*"); + // TODO: I am not sure why it is so many functions... + // UNIONS ARE LIMITED + // assertEquals(30, l.size()); + for (QualifiedDeclaration f : l) { + for (QualifiedDeclaration f2 : l) { + assertFalse("duplicate method: " + f2, + f.getDeclaration().equals(f2.getDeclaration()) && f.getDeclaration() != f2.getDeclaration()); + } + } + + // TYPE PARAMETERS IN FUNCTIONAL TYPES + TypeMacroDeclaration m = context.findFirstDeclaration(TypeMacroDeclaration.class, "*.GenericType") + .getDeclaration(); + assertNotNull(m.getType().getTypeArguments()); + assertEquals("Array", m.getType().getTypeArguments()[0].getName()); + assertEquals("any", m.getType().getTypeArguments()[0].getTypeArguments()[0].getName()); + assertEquals("any", m.getType().getTypeArguments()[1].getName()); + + } + + @Test + public void importReferencesTest() throws FileNotFoundException { + // TODO : forbid modules of the same name, with different cases + + String testFilePath = "references/import-test"; + Context context = parseAndTranslateTestFile(testFilePath); + + String basePackage = "def.references"; + + TypeDeclaration referencedType = context.findFirstDeclaration(TypeDeclaration.class, basePackage + ".foo.A") + .getDeclaration(); + assertEquals(0, context.findDeclarations(ModuleDeclaration.class, basePackage + ".importtests.foo").size()); + + TypeDeclaration type = context.findFirstDeclaration(TypeDeclaration.class, basePackage + ".importtests.A") + .getDeclaration(); + VariableDeclaration field = type.findVariable("field"); + assertEquals(referencedType, field.getType().getDeclaration()); + + assertNull(context.findFirstDeclaration(ModuleDeclaration.class, basePackage + "._T1")); + assertNotNull(context.findFirstDeclaration(ModuleDeclaration.class, basePackage + ".t1")); + assertNotNull(context.findFirstDeclaration(TypeDeclaration.class, basePackage + ".t1.I")); + assertNotNull(context.findFirstDeclaration(ModuleDeclaration.class, basePackage + ".publicmodule")); + assertNull(context.findFirstDeclaration(ModuleDeclaration.class, basePackage + ".publicmodule.privatemodule")); + assertNotNull(context.findFirstDeclaration(TypeDeclaration.class, basePackage + ".publicmodule.TestExport")); + assertNotNull(context.findFirstDeclaration(VariableDeclaration.class, basePackage + ".publicmodule.Globals.v")); + assertNotNull(context.findFirstDeclaration(FunctionDeclaration.class, basePackage + ".publicmodule.Globals.f")); + QualifiedDeclaration f = context.findFirstDeclaration(FunctionDeclaration.class, + basePackage + ".Globals.publicModule"); + assertNotNull(f); + assertEquals(basePackage + ".publicmodule.TestExport", f.getDeclaration().getType().getName()); + assertNotNull(context.findFirstDeclaration(FunctionDeclaration.class, basePackage + ".Globals.publicModule2")); + } + + @Test + public void unionTypeTest() throws FileNotFoundException { + String testFilePath = "types/union-type-test"; + + Context context = parseAndTranslateTestFile(testFilePath, (c) -> { + assertEquals(1, c.findDeclarations(ModuleDeclaration.class, "UnionTypeTests").size()); + VariableDeclaration f1 = c.findFirstDeclaration(VariableDeclaration.class, "UnionTypeTests.I1.f") + .getDeclaration(); + assertTrue("type should be a union", f1.getType() instanceof UnionTypeReference); + VariableDeclaration f2 = c.findFirstDeclaration(VariableDeclaration.class, "UnionTypeTests.I2.f") + .getDeclaration(); + assertTrue("type should be a union", f2.getType() instanceof UnionTypeReference); + }); + + final String basePackage = "def.types.uniontypetests"; + assertEquals(1, context.findDeclarations(ModuleDeclaration.class, basePackage).size()); + TypeDeclaration type = context.findFirstDeclaration(TypeDeclaration.class, basePackage + ".I1") + .getDeclaration(); + assertEquals(1, type.getMembers().length); + VariableDeclaration f = type.findVariable("f"); + assertEquals(JSweetDefTranslatorConfig.UNION_CLASS_NAME, f.getType().getName()); + type = context.findFirstDeclaration(TypeDeclaration.class, basePackage + ".I2").getDeclaration(); + assertEquals(1, type.getMembers().length); + f = type.findVariable("f"); + assertEquals(JSweetDefTranslatorConfig.UNION_CLASS_NAME, f.getType().getName()); + assertContains(f.getType().getTypeArguments(), "String"); + assertContains(f.getType().getTypeArguments(), FunctionalInterfacesCreator.SUPPLIER); + type = context.findFirstDeclaration(TypeDeclaration.class, basePackage + ".I3").getDeclaration(); + assertEquals(2, type.getMembers().length); + f = type.findVariable("f"); + assertEquals(JSweetDefTranslatorConfig.UNION_CLASS_NAME, f.getType().getName()); + assertContains(f.getType().getTypeArguments(), "String"); + // generated object type + assertContains(f.getType().getTypeArguments(), "F"); + + // I. assert that B and A has union + TypeDeclaration typeA = context.findFirstDeclaration(TypeDeclaration.class, basePackage + ".A") + .getDeclaration(); + VariableDeclaration fieldA = typeA.findVariable("field"); + assertNotNull(fieldA.getType()); + assertEquals(JSweetDefTranslatorConfig.UNION_PACKAGE + ".Union3", + getTypeQualifiedName(context, fieldA.getType())); + assertContains(fieldA.getType().getTypeArguments(), "String"); + assertContains(fieldA.getType().getTypeArguments(), "Double"); + assertContains(fieldA.getType().getTypeArguments(), "Boolean"); + + TypeDeclaration typeB = context.findFirstDeclaration(TypeDeclaration.class, basePackage + ".B") + .getDeclaration(); + VariableDeclaration fieldB = typeB.findVariable("field"); + assertNotNull(fieldB.getType()); + assertEquals(JSweetDefTranslatorConfig.UNION_PACKAGE + ".Union3", + getTypeQualifiedName(context, fieldB.getType())); + assertContains(fieldB.getType().getTypeArguments(), "String"); + assertContains(fieldB.getType().getTypeArguments(), "Double"); + assertContains(fieldB.getType().getTypeArguments(), "Boolean"); + + // II. type param + TypeDeclaration typeC = context.findFirstDeclaration(TypeDeclaration.class, basePackage + ".C") + .getDeclaration(); + TypeParameterDeclaration[] typeParamsC = typeC.getTypeParameters(); + assertEquals(1, typeParamsC.length); + + // UNIONS ARE NOW LIMITED TO 3 + // assertEquals(JSweetDefTranslatorConfig.UNION_PACKAGE + ".Union4", + // getTypeQualifiedName(context, typeParamsC[0].getUpperBound())); + // assertContains(typeParamsC[0].getUpperBound().getTypeArguments(), + // "String"); + // assertContains(typeParamsC[0].getUpperBound().getTypeArguments(), + // "Double"); + // assertContains(typeParamsC[0].getUpperBound().getTypeArguments(), + // "Boolean"); + // assertContains(typeParamsC[0].getUpperBound().getTypeArguments(), + // "A"); + assertEquals("any", getTypeQualifiedName(context, typeParamsC[0].getUpperBound())); + + TypeDeclaration typeD = context.findFirstDeclaration(TypeDeclaration.class, basePackage + ".D") + .getDeclaration(); + TypeReference typeDSuper = typeD.getSuperTypes()[0]; + assertEquals("C", typeDSuper.getName()); + assertEquals(1, typeDSuper.getTypeArguments().length); + assertEquals(JSweetDefTranslatorConfig.UNION_CLASS_NAME, + getTypeQualifiedName(context, typeDSuper.getTypeArguments()[0])); + assertContains(typeDSuper.getTypeArguments()[0].getTypeArguments(), "A"); + assertContains(typeDSuper.getTypeArguments()[0].getTypeArguments(), "Boolean"); + + // III. variables + VariableDeclaration variable = context + .findFirstDeclaration(VariableDeclaration.class, basePackage + ".Globals.variable").getDeclaration(); + assertEquals(JSweetDefTranslatorConfig.UNION_CLASS_NAME, getTypeQualifiedName(context, variable.getType())); + assertContains(variable.getType().getTypeArguments(), "String"); + assertContains(variable.getType().getTypeArguments(), "Double"); + + VariableDeclaration variableGenerics = context + .findFirstDeclaration(VariableDeclaration.class, basePackage + ".Globals.variableGenerics") + .getDeclaration(); + assertEquals("C", variableGenerics.getType().getName()); + assertEquals(1, variableGenerics.getType().getTypeArguments().length); + assertEquals(JSweetDefTranslatorConfig.UNION_CLASS_NAME, + getTypeQualifiedName(context, variableGenerics.getType().getTypeArguments()[0])); + assertContains(variableGenerics.getType().getTypeArguments()[0].getTypeArguments(), "String"); + assertContains(variableGenerics.getType().getTypeArguments()[0].getTypeArguments(), "Double"); + + // IV. functions + List> functionsWithParams = context + .findDeclarations(FunctionDeclaration.class, basePackage + ".Globals.foo"); + assertEquals(2, functionsWithParams.size()); + + boolean objectSignatureFound = false; + boolean numberSignatureFound = false; + for (QualifiedDeclaration func : functionsWithParams) { + if (func.getDeclaration().getParameters().length == 1 + && func.getDeclaration().getParameters()[0].getType().getName().equals("A")) { + objectSignatureFound = true; + } + + if (func.getDeclaration().getParameters().length == 1 + && func.getDeclaration().getParameters()[0].getType().getName().equals("number")) { + numberSignatureFound = true; + } + + } + assertTrue("expanded object signature not found in " + functionsWithParams, objectSignatureFound); + assertTrue("expanded number signature not found in " + functionsWithParams, numberSignatureFound); + + List> functionsWithReturnType = context + .findDeclarations(FunctionDeclaration.class, basePackage + ".Globals.bar"); + assertEquals(1, functionsWithReturnType.size()); + + assertEquals(JSweetDefTranslatorConfig.UNION_PACKAGE + ".Union", + getTypeQualifiedName(context, functionsWithReturnType.get(0).getDeclaration().getType())); + assertEquals(2, functionsWithReturnType.get(0).getDeclaration().getType().getTypeArguments().length); + assertContains(functionsWithReturnType.get(0).getDeclaration().getType().getTypeArguments(), "A"); + assertContains(functionsWithReturnType.get(0).getDeclaration().getType().getTypeArguments(), "Boolean"); + + } + + @Test + public void functionalInterfaceTest() throws FileNotFoundException { + String testFilePath = "types/functional-interface-test"; + Context context = parseAndTranslateTestFile(testFilePath); + final String basePackage = "def.types.functionalinterfacetests"; + TypeDeclaration list = context.findFirstDeclaration(TypeDeclaration.class, basePackage + ".List") + .getDeclaration(); + assertContains(list.getSuperTypes(), "Iterable"); + TypeDeclaration listIterator = context + .findFirstDeclaration(TypeDeclaration.class, basePackage + ".ListIterator").getDeclaration(); + assertEquals("only one method is allowed", 1, listIterator.getMembers().length); + assertContains(listIterator.getMembers(), JSweetDefTranslatorConfig.ANONYMOUS_FUNCTION_NAME); + } + + // TODO : externalize, We shouldn't need to do this at all + private String getTypeQualifiedName(Context context, TypeReference type) { + if (type.getDeclaration() != null) { + return context.getTypeName((TypeDeclaration) type.getDeclaration()); + } else { + return type.getName(); + } + } + + @Test + public void objectTypeTest() throws FileNotFoundException { + String testFilePath = "types/object-type-test"; + Context context = parseAndTranslateTestFile(testFilePath); + + final String basePackage = "def.types.objecttypetests"; + + // I. assert that B inherits ObjectType from A + TypeDeclaration typeA = context.findFirstDeclaration(TypeDeclaration.class, basePackage + ".A") + .getDeclaration(); + VariableDeclaration fieldA = typeA.findVariable("field"); + assertNotNull(fieldA.getType()); + assertNotNull(fieldA.getType().getDeclaration()); + assertTrue(fieldA.getType().getDeclaration() instanceof TypeDeclaration); + assertEquals(basePackage + ".A.Field", + context.getTypeName((TypeDeclaration) fieldA.getType().getDeclaration())); + assertContains(typeA.getMembers(), "Field"); + assertContains(typeA.findType("Field").getMembers(), "a"); + assertContains(typeA.findType("Field").getMembers(), "b"); + + TypeDeclaration typeB = context.findFirstDeclaration(TypeDeclaration.class, basePackage + ".B") + .getDeclaration(); + VariableDeclaration fieldB = typeB.findVariable("field"); + assertNotNull(fieldB.getType()); + assertNotNull(fieldB.getType().getDeclaration()); + assertTrue(fieldB.getType().getDeclaration() instanceof TypeDeclaration); + assertEquals(basePackage + ".A.Field", + context.getTypeName((TypeDeclaration) fieldB.getType().getDeclaration())); + assertFalse(contains(typeB.getMembers(), "Field")); + + // II. type param + TypeDeclaration typeC = context.findFirstDeclaration(TypeDeclaration.class, basePackage + ".C") + .getDeclaration(); + TypeParameterDeclaration[] typeParamsC = typeC.getTypeParameters(); + assertEquals(1, typeParamsC.length); + assertContains(typeC.getMembers(), "T"); + assertEquals("T", typeParamsC[0].getUpperBound().getName()); + assertContains(typeC.findType("T").getMembers(), "a"); + assertContains(typeC.findType("T").getMembers(), "b"); + + // III. variables + String globalsClassName = basePackage + ".Globals"; + ModuleDeclaration module = context.findFirstDeclaration(ModuleDeclaration.class, basePackage).getDeclaration(); + VariableDeclaration variable = context + .findFirstDeclaration(VariableDeclaration.class, globalsClassName + ".variable").getDeclaration(); + assertEquals("Variable", variable.getType().getName()); + assertContains(module.getMembers(), "Variable"); + assertContains(module.findType("Variable").getMembers(), "a"); + assertContains(module.findType("Variable").getMembers(), "b"); + + VariableDeclaration variableGenerics = context + .findFirstDeclaration(VariableDeclaration.class, globalsClassName + ".variableGenerics") + .getDeclaration(); + assertEquals("C", variableGenerics.getType().getName()); + assertEquals("VariableGenerics", variableGenerics.getType().getTypeArguments()[0].getName()); + assertContains(module.getMembers(), "VariableGenerics"); + assertContains(module.findType("VariableGenerics").getMembers(), "a"); + assertContains(module.findType("VariableGenerics").getMembers(), "b"); + // TODO: VariableGenerics is used as a type argument and should then + // extends the upper bounds of the type parameters + // assertContains(module.findType("VariableGenerics").getSuperTypes(), + // "C.T"); + + // / IV. functions + FunctionDeclaration function = context + .findFirstDeclaration(FunctionDeclaration.class, globalsClassName + ".foo").getDeclaration(); + assertEquals(1, function.getParameters().length); + ParameterDeclaration functionParam = function.getParameters()[0]; + assertEquals("P", functionParam.getType().getName()); + assertContains(module.getMembers(), "P"); + assertContains(module.findType("P").getMembers(), "a"); + assertContains(module.findType("P").getMembers(), "b"); + + // TODO : test deduplicate object type parameters with same name and + // members inside a single class + + FunctionDeclaration function2 = context + .findFirstDeclaration(FunctionDeclaration.class, globalsClassName + ".bar").getDeclaration(); + assertEquals("Bar", function2.getType().getName()); + assertContains(module.getMembers(), "Bar"); + assertContains(module.findType("Bar").getMembers(), "a"); + assertContains(module.findType("Bar").getMembers(), "b"); + + } + + private boolean contains(NamedElement[] elements, String name) { + for (NamedElement decl : elements) { + if (decl.getName().equals(name)) { + return true; + } + } + + return false; + } + + private void assertContains(NamedElement[] elements, String name) { + if (!contains(elements, name)) { + fail(name + " not found in " + asList(elements)); + } + } + + @Test + public void typeTest() throws FileNotFoundException { + + String testFilePath = "types/type-test"; + Context context = parseAndTranslateTestFile(testFilePath); + + TypeDeclaration d = context.findFirstDeclaration(TypeDeclaration.class, "def.types.TestStringTypes") + .getDeclaration(); + FunctionDeclaration f = d.findFirstFunction("m1"); + + Assert.assertEquals("parameter of function m1 should be a string type 'abc'", "jsweet.util.StringTypes.abc", + f.getParameters()[0].getType().getName()); + f = d.findFirstFunction("m2"); + Assert.assertEquals("parameter of function m2 should be a string type, 'abc'", "jsweet.util.StringTypes.abc", + f.getParameters()[0].getType().getName()); + + f = context.findFirstDeclaration(FunctionDeclaration.class, "def.types.I.items").getDeclaration(); + assertEquals(JSweetDefTranslatorConfig.TUPLE_CLASSES_PACKAGE + "." + + JSweetDefTranslatorConfig.TUPLE_CLASSES_PREFIX + "2", + ((ArrayTypeReference) f.getType()).getComponentType().getName()); + + } + +} diff --git a/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/references/import-test.d.ts b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/references/import-test.d.ts new file mode 100644 index 00000000..d4dbe953 --- /dev/null +++ b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/references/import-test.d.ts @@ -0,0 +1,55 @@ +declare module "foo" { + interface A { + field?: number; + method(p: any): boolean; + f: A; + } + + interface B extends A { + f1 : B; + f2: A; + } + + type Alias = A; +} + +declare module ImportTests { + + import Foo = require('foo'); + + class A { + field: Foo.A; + fieldAlias: Foo.Alias; + } +} + +import T1 = _T1; + +declare module _T1 { + + interface I {} + +} + +declare module publicModule { + + module privateModule { + var v : number; + interface TestExport { + } + function f(): TestExport; + } + + function privateModule(): privateModule.TestExport; + + export = privateModule; + +} + +declare module publicModule2 { + + function privateFunction(): string; + + export = privateFunction; + +} \ No newline at end of file diff --git a/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/structure/constructor-interface-test.d.ts b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/structure/constructor-interface-test.d.ts new file mode 100644 index 00000000..20fe40ce --- /dev/null +++ b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/structure/constructor-interface-test.d.ts @@ -0,0 +1,15 @@ + +export namespace test { + + interface Math { + /** + * Returns the absolute value of a number (the value without regard to whether it is positive or negative). + * For example, the absolute value of -5 is the same as the absolute value of 5. + * @param x A numeric expression for which the absolute value is needed. + */ + abs(x: number): number; + } + /** An intrinsic object that provides basic mathematics functionality and constants. */ + declare const Math: Math; + +} \ No newline at end of file diff --git a/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/structure/globals-test.d.ts b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/structure/globals-test.d.ts new file mode 100644 index 00000000..1d1e9537 --- /dev/null +++ b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/structure/globals-test.d.ts @@ -0,0 +1,25 @@ + +export namespace m1 { + + export namespace m11 { + + export function f111(): void; + + } + + export namespace Utils { + + export function f(): void; + + } + + export namespace Utils2 { + + export function f(): C; + + class C { + } + + } + +} \ No newline at end of file diff --git a/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/comment1-test.d.ts b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/comment1-test.d.ts new file mode 100644 index 00000000..46069ecd --- /dev/null +++ b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/comment1-test.d.ts @@ -0,0 +1,124 @@ + +/********************************** + * Main comment + **********************************/ + +interface NodeListOf extends NodeList, T, U { + /** + * test + */ + length: { + } + item(index: number /** Buffer **/): TNode; + /** + * test + */ + /** + * test + */ + [index: number]: TNode; + v1: number; + v2: number; + /** + * test + * + v3: string; + v4: string; + /** + * test + */ +} + +enum StatusEnum { + connected /** Buffer **/, connecting, // test comment + failed, waiting, offline +} + +enum Enum { + a = 0, + b = 1 + /** + * test + */ +} + +enum Enum2 { + a = 0, + b = 1, + /** + * test + */ +} + +enum StatusEnum2 { + /** + * test2 + connected, + /** + * test3 + */ + connecting, + failed, waiting, offline, + /** + * test4 + */ +} + +/** + * Comment I + */ +interface I { + + // type inference + + spread(onFulfill: Function, onReject?: (reason: any) => U): Promise; + /* + // TODO or something like this? + spread(onFulfill: (...values: W[]) => Promise.Thenable, onReject?: (reason: any) => Promise.Thenable): Promise; + spread(onFulfill: (...values: W[]) => Promise.Thenable, onReject?: (reason: any) => U): Promise; + spread(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => Promise.Thenable): Promise; + spread(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => U): Promise; + */ + /** + * Same as calling `Promise.all(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + all(): Promise; + + hasBackdrop?: boolean // default: true + clickOutsideToClose?: boolean; // default: false + escapeToClose?: boolean; // default: true + + /** + * Stop recording on all processes. Child processes typically are caching trace data and + * only rarely flush and send trace data back to the main process. That is because it may + * be an expensive operation to send the trace data over IPC, and we would like to avoid + * much runtime overhead of tracing. So, to end tracing, we must asynchronously ask all + * child processes to flush any pending trace data. + * @param resultFilePath Trace data will be written into this file if it is not empty, + * or into a temporary file. + * @param callback Called once all child processes have acked to the stopRecording request. + */ + export function stopRecording(resultFilePath: string, callback: + /** + * @param filePath A file that contains the traced data. + */ + (filePath: string) => void + ): void; + +} + +interface /*PhoneGapNavigator extends*/ Navigator { + /** Comment 1 */ + accelerometer: Accelerometer; + camera: Camera; + capture: Capture; + compass: Compass; + connection: Connection; + contacts: Contacts; + device: Device; + globalization: Globalization; + notification: Notification; + splashscreen: Splashscreen; +} + +// end of file comment \ No newline at end of file diff --git a/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/comment2-test.d.ts b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/comment2-test.d.ts new file mode 100644 index 00000000..5194d70b --- /dev/null +++ b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/comment2-test.d.ts @@ -0,0 +1,107 @@ +/** + * Main doc + */ +interface GoogleApiPageSpeedOnlineRuleResource { + /** + * Localized name of the rule, intended for presentation to a user. + */ + localizedRuleName: string; + /** + * The score (0-100) for this rule. The rule score indicates how well a page implements the recommendations for the given rule. + */ + ruleScore: number; + /** + * The impact (unbounded floating point value) that implementing the suggestions for this rule would have on making the page faster. + */ + ruleImpact: number; + /** + * List of blocks of URLs. Each block may contain a heading and a list of URLs. Each URL may optionally include additional details. + */ + urlBlocks: { + /** + * Heading to be displayed with the list of URLs. + */ + header: { + /** + * A localized format string with $N placeholders, where N is the 1-indexed argument number. + */ + format: string; + /** + * List of arguments for the format string. + */ + args: { + /** + * Type of argument. One of URL, STRING_LITERAL, INT_LITERAL, BYTES, or DURATION. + */ + type: string; + /** + * Argument value, as a localized string. + */ + value: string; + }[]; + } + /** + * List of entries that provide information about URLs in the URL block. Optional. + */ + urls: { + /** + * A format string that gives information about the URL, and a list of arguments for that format string. + */ + result: { + /** + * A localized format string with $N placeholders, where N is the 1-indexed argument number. For example: 'Minifying the resource at URL $1 can save $2 bytes'. + */ + format: string; + /** + * List of arguments for the format string. + */ + args: { + /** + * Type of argument. One of URL, STRING_LITERAL, INT_LITERAL, BYTES, or DURATION. + */ + type: string; + /** + * Argument value, as a localized string. + */ + value: string; + }[]; + } + /** + * List of entries that provide additional details about a single URL. Optional. + */ + details: { + /** + * A localized format string with $N placeholders, where N is the 1-indexed argument number. + */ + format: string; + /** + * List of arguments for the format string. + */ + args: { + /** + * Type of argument. One of URL, STRING_LITERAL, INT_LITERAL, BYTES, or DURATION. + */ + type: string; + /** + * Argument value, as a localized string. + */ + value: string; + }[]; + }[]; + }[]; + }[]; +} + +/** + * Another doc + */ +module m { + /** + * Yet another doc + */ + interface I { + } +} + /** + * + */ \ No newline at end of file diff --git a/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/comment3-test.d.ts b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/comment3-test.d.ts new file mode 100644 index 00000000..5d34cf01 --- /dev/null +++ b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/comment3-test.d.ts @@ -0,0 +1,44 @@ + + +/** + * $I1$ + */ +interface I1 { +} + +/** + * $f1$ + */ +declare function f1(): string; + +/** + * $I2$ + */ +interface I2 { +} + +/** + * $m$ + */ + +module m { + + /** + * $I3$ + */ + + interface I3 { + + /** + * $f2$ + */ + f2(); + + /** + * $v1$ + */ + v1: number; + + } + +} diff --git a/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/default-test.d.ts b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/default-test.d.ts new file mode 100644 index 00000000..3fe1457b --- /dev/null +++ b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/default-test.d.ts @@ -0,0 +1,134 @@ + +module 'm' { + + interface Typed {} + + class TypedImpl extends Typed {} + + // test + + type T = string | number; + + /////////////////////////////////////////////////////////////////////////// + // SCEService + // see http://docs.angularjs.org/api/ng.$sce + /////////////////////////////////////////////////////////////////////////// + + /** + * titi 1 + */ + interface ISCEService { + getTrusted(type: string, mayBeTrusted: any): any; + } + + interface Tinytest { + add(name:string, func:Function):any; + addAsync(name:string, func:Function):any; + } + + interface Array { + isArray(arg: any): arg is Array; + } + + /** + * titi 2 + */ + enum StatusEnum { + connected, + connecting, + failed, + waiting, + offline + } + + export = i; + + /** the * promise of the original server interaction that created this instance. ** **/ + interface I2<{ test: string; }> extends I { + + /** The notify function can either be passed a string or an object. */ + + (translationId: string[], interpolateParams?: any, interpolationId?: string): ng.IPromise<{ [key: string]: string }>; + + var test: string; + + a(b: any, c : number): string; + + b(f : ((n: number) => void )[]) : t.x.y; + + [a : number] : T; + + (b: any, c: number): string; + + a2(b: { p1: P1; f(x:number):string; } [], c : number): string; + + function getLevel(nameOrValue: string): webdriver.logging.Level; + + sendKeys(...var_args: string[]): webdriver.promise.Promise; + } + + module logging { + var Preferences: any; + + class LevelName extends webdriver.logging.LevelName { } + class Type extends webdriver.logging.Type { } + class Level extends webdriver.logging.Level { } + class Entry extends webdriver.logging.Entry { } + + /** + * titi 3 + */ + function getLevel(nameOrValue: string): webdriver.logging.Level; + function getLevel(nameOrValue: number): webdriver.logging.Level; + } +} + +interface I { + a, b, c, +} + +module m2 { + rest: T; + + import * as i from m; +} + + +// TODO: support object_type @tsdef\angular-http-auth\angular-http-auth.d.ts + + +enum StatusEnum { + connected, connecting, + failed, waiting, offline +} + +interface NodeListOf extends NodeList, T, U { + length: { + } + item(index: number): TNode; + [index: number]: TNode; + static : number; + static: number; + extends: string; + extends : string; +} + +class Model extends ModelBase { + + object(...keyValuePairs: any[][]): T; + + /** + * Do not use, prefer TypeScript's extend functionality. + **/ + private static extend(properties: any, classProperties?: any): any; + + attributes: any; + changed: any[]; + cid: string; + collection: Collection; +} + +namespace n { + +} + diff --git a/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/enum-test.d.ts b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/enum-test.d.ts new file mode 100644 index 00000000..089fe722 --- /dev/null +++ b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/enum-test.d.ts @@ -0,0 +1,32 @@ + +enum StatusEnum { + connected, connecting, + failed, waiting, offline +} + +enum Enum { + a = 0, + b = 1, + c= -1 +} + +enum StatusEnum2 { + connected, connecting, + failed, waiting, offline, +} + +enum Enum { + a = +1, + b = 0xFF +} + +export const enum FormType +{ + Undefined = 0, + Create = 1, + Update = 2, + ReadOnly = 3, + Disabled = 4, + BulkEdit = 6 +} + diff --git a/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/export-test.d.ts b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/export-test.d.ts new file mode 100644 index 00000000..5e58d3fb --- /dev/null +++ b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/export-test.d.ts @@ -0,0 +1,14 @@ + +interface Buffer {} + +interface SlowBuffer {} + +declare module "buffer" { + export var INSPECT_MAX_BYTES: number; + var BuffType: typeof Buffer; + var SlowBuffType: typeof SlowBuffer; + // selective export (syntax-only supported) + export { BuffType as Buffer, SlowBuffType as SlowBuffer }; + export { Buffer }; +} + diff --git a/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/identifier-test.d.ts b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/identifier-test.d.ts new file mode 100644 index 00000000..d1cd8773 --- /dev/null +++ b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/identifier-test.d.ts @@ -0,0 +1,14 @@ + + +interface I { + + "[": number; // = 219, + "\\": number; // = 220, + "]": number; // = 221, + + + '[': number; // = 219, + '\\': number; // = 220, + ']': number; // = 221, + +} \ No newline at end of file diff --git a/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/keyword-test.d.ts b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/keyword-test.d.ts new file mode 100644 index 00000000..df60acc1 --- /dev/null +++ b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/keyword-test.d.ts @@ -0,0 +1,59 @@ + +declare type Tween = TweenLite | TweenMax; + +declare module "dijit/_BidiSupport" { + + static static ( vertices:Array, angle:number, point:Vector ):void; + + var exp: dijit._BidiSupport; + static: number; + static: number; + + extends: string; + extends : string; + extends : string; + + export = exp; + export =exp; + + interface: any; + + type Type = string; // 'all'|'directories'|'files' + type Mask = string; + + function(target: T): IBinding; + function(target: T): IBinding; + + /** Return a function that executes *fn* at most every *timeout* ms. */ + debounce void>(timeout: number, fn: T, invokeAsap?: boolean, ctx?: any): T; + + // The type of the event. + type : string; + type: string; + + export import Perf = ReactPerf; + + typeof():string; + +} + + class Disposable { + constructor(disposalAction: any) + dispose(): void; + } + + interface I { + /** + * + */ + instanceof: number; + /** + * + */ + int: number; + /** + * + */ + interface: number; + } + \ No newline at end of file diff --git a/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/lf-test.d.ts b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/lf-test.d.ts new file mode 100644 index 00000000..7d575cc5 --- /dev/null +++ b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/syntax/lf-test.d.ts @@ -0,0 +1,24 @@ +interface IUtil extends IUtilAnimation, IUtilArc, IObservable, IUtilDomEvent, IUtilDomMisc, + IUtilDomRequest, IUtilDomStyle, IUtilClass, IUtilMisc { + ease: IUtilAnimEase; + array: IUtilArray; + object: IUtilObject; + string: IUtilString; + mkdir: ((path: string, callback?: (err?: NodeJS.ErrnoException) => void) => void) + | ((path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void) => void) + | ((path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void) => void); + + field: string|number| + any; + + field: string|number| + { a:string; } + + getDocument( + source: string, + pdfDataRangeTransport?, + passwordCallback?: (fn: (password: string) => void, reason: string) => string, + progressCallback?: (progressData: PDFProgressData) => void) + : PDFPromise; + +} diff --git a/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/default-test.d.ts b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/default-test.d.ts new file mode 100644 index 00000000..552efe94 --- /dev/null +++ b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/default-test.d.ts @@ -0,0 +1,127 @@ + +declare module 'm' { + + interface Typed { } + + class TypedImpl extends Typed { } + + // test + + type T = string | number; + + /////////////////////////////////////////////////////////////////////////// + // SCEService + // see http://docs.angularjs.org/api/ng.$sce + /////////////////////////////////////////////////////////////////////////// + + /** + * titi 1 + */ + interface ISCEService { + getTrusted(type: string, mayBeTrusted: any): any; + 'field-with-dashes': string; + } + + interface Tinytest { + add(name: string, func: Function): any; + addAsync(name: string, func: Function): any; + } + + /** + * titi 2 + */ + enum StatusEnum { + connected, + connecting, + failed, + waiting, + offline + } + + export = i; + + class C { + } + +} + +// TODO: support object_type @tsdef\angular-http-auth\angular-http-auth.d.ts + + +enum StatusEnum { + connected, connecting, + failed, waiting, offline +} + +interface NodeListOf extends NodeList, T, U { + length: { + } + item(index: number): TNode; + [index: number]: TNode; + static: number; + static: number; + extends: string; + extends: string; +} + +declare module "module-with-dashes" { + var v; +} + +declare module "module/with/slashes" { + var v; +} + + +declare module a.b { + module c1 { + var v; + } + module c2 { + var v; + } + module c3 { + var v; + } +} + +module datetest { + + interface Date { + /** Returns a string representation of a date. The format of the string depends on the locale. */ + toString(): string; + /** Returns a date as a string value. */ + toDateString(): string; + /** Returns a time as a string value. */ + toTimeString(): string; + } + + interface DateConstructor { + new (): Date; + new (value: number): Date; + new (value: string): Date; + } + + declare var Date: DateConstructor; +} + +module events { + export interface EventEmitter { + addListener(event: string, listener: Function): this; + on(event: string, listener: Function): this; + once(event: string, listener: Function): this; + removeListener(event: string, listener: Function): this; + removeAllListeners(event?: string): this; + setMaxListeners(n: number): this; + getMaxListeners(): number; + listeners(event: string): Function[]; + emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; + } + + export function myFunction(s : string) : string; +} + +declare var myFunction2: typeof events.myFunction; + + diff --git a/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/functional-interface-test.d.ts b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/functional-interface-test.d.ts new file mode 100644 index 00000000..e0d0b948 --- /dev/null +++ b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/functional-interface-test.d.ts @@ -0,0 +1,17 @@ +declare module FunctionalInterfaceTests { + + // this is a functional interface + interface ListIterator { + // translates to $apply + (value: T, index: number, list: List): TResult; + } + + interface Collection { } + + // translates to a class that implements the java.lang.Iterable interface + interface List extends Collection { + [index: number]: T; + length: number; + } + +} \ No newline at end of file diff --git a/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/object-type-test.d.ts b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/object-type-test.d.ts new file mode 100644 index 00000000..039570c2 --- /dev/null +++ b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/object-type-test.d.ts @@ -0,0 +1,28 @@ +declare module ObjectTypeTests { + + class A { + field: { a: string; b: number }; + } + + class B extends A { + field: { a: string; b: number }; + } + + class C { + + } + + var variable: { a: string; b: number }; + var variableGenerics: C<{ a: string; b: number }>; + + function foo(p: { a: string; b: number }): void; + + function bar(): { a: string; b: number }; + + interface I { + // notice the comma that seems to be allowed + connect(options: { port: number, host: string }, connectionListener?: B): A; + } + +} + \ No newline at end of file diff --git a/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/type-macro-test.d.ts b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/type-macro-test.d.ts new file mode 100644 index 00000000..9a9640da --- /dev/null +++ b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/type-macro-test.d.ts @@ -0,0 +1,77 @@ +declare module TypeMacroTests { + + interface BaseTypedElement

{ + type: string; + props: P; + } + + interface ClassicElement

extends BaseTypedElement

{ + type: string; + ref: string; + } + + interface DOMElement

extends ClassicElement

{ + type: string; + ref: string | ((component: DOMElement

) => any); + } + + interface HTMLAttributes { } + interface Component {} + interface ComponentClass {} + + type HTMLElement = DOMElement; + type HTMLElementAlias = HTMLElement | string; + type HTMLElementComplex = HTMLElementAlias | number | void; + type Ref = string | ((instance: T) => any); + type ClassType, C extends ComponentClass

> = + C & + (new() => T) & + (new() => { props: P }); + + interface ClassAttributes { + ref?: Ref; + l : String|LatLngLiteral; + } + + interface EnclosingInterface { + field: HTMLElement; + fieldGenerics: BaseTypedElement; + + fieldWithUnion: HTMLElementComplex; + fieldWithGenericsAndUnion: BaseTypedElement; + + methodWithParam(p: HTMLElement, ...p2: HTMLElementComplex[]): void; + methodWithReturn(): HTMLElement; + l : String|LatLngLiteral; + } + + interface ReactElement {} + interface Array {} + + type GenericType = , T2>(p1:T1, p2:T2)=>void; + + type ReactText = string | number; + type ReactChild = ReactElement | ReactText; + + // Should be Array but type aliases cannot be recursive + type ReactFragment = {} | Array; + type ReactNode = ReactChild | ReactFragment | boolean; + + export type LatLngLiteral = { lat: number; lng: number } + + // + // Top Level API + // ---------------------------------------------------------------------- + + function createElement

( + type: string, + props?: P, + ...children: ReactNode[]): DOMElement

; + var reactNode : ReactNode; + + interface Test { + forEach(children: ReactNode, fn: (child: ReactChild, index: number) => any): void; + } + +} + \ No newline at end of file diff --git a/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/type-test.d.ts b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/type-test.d.ts new file mode 100644 index 00000000..b1af4665 --- /dev/null +++ b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/type-test.d.ts @@ -0,0 +1,30 @@ + +type LatLngExpression = string | number[] | ({ lat: number; lng: number }) + +interface I { + items():[string,V][]; +} + +interface TestStringTypes { + + m1(abc:"abc"); + + m2(abc:'abc'); + +} + +interface Array { +} + +interface I2 extends I> { +} + +export module config { + interface IPromise {} + + export var Promise: { new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): IPromise; }; + + interface I { + toPromise>(promiseCtor: { new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): TPromise; }): TPromise; + } +} diff --git a/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/union-type-test.d.ts b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/union-type-test.d.ts new file mode 100644 index 00000000..80461498 --- /dev/null +++ b/jsweet-candy-generator/src/test/java/org/jsweet/input/typescriptdef/test/types/union-type-test.d.ts @@ -0,0 +1,38 @@ +declare module UnionTypeTests { + + class A { + field: string | number | boolean; + } + + class B extends A { + field: string | number | boolean; + } + + class C { + field: T; + } + + class D extends C { + } + + var variable: string | number; + var variableGenerics: C; + + function foo(p: number | A | void): void; + + function bar(): boolean | A | void; + + interface I1 { + f : string | number; + } + + interface I2 { + f : string | (() => string); + } + + interface I3 { + f : string | { () : string }; + } + +} + \ No newline at end of file diff --git a/jsweet-candy-generator/src/test/resources/lib.core/lib.core.d.ts b/jsweet-candy-generator/src/test/resources/lib.core/lib.core.d.ts new file mode 100644 index 00000000..fb931a81 --- /dev/null +++ b/jsweet-candy-generator/src/test/resources/lib.core/lib.core.d.ts @@ -0,0 +1,3922 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft 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 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +/// +///////////////////////////// +/// ECMAScript APIs +///////////////////////////// + +declare const NaN: number; +declare const Infinity: number; + +/** + * Evaluates JavaScript code and executes it. + * @param x A String value that contains valid JavaScript code. + */ +declare function eval(x: string): any; + +/** + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ +declare function parseInt(s: string, radix?: number): number; + +/** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ +declare function parseFloat(string: string): number; + +/** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). + * @param number A numeric value. + */ +declare function isNaN(number: number): boolean; + +/** + * Determines whether a supplied number is finite. + * @param number Any numeric value. + */ +declare function isFinite(number: number): boolean; + +/** + * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). + * @param encodedURI A value representing an encoded URI. + */ +declare function decodeURI(encodedURI: string): string; + +/** + * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). + * @param encodedURIComponent A value representing an encoded URI component. + */ +declare function decodeURIComponent(encodedURIComponent: string): string; + +/** + * Encodes a text string as a valid Uniform Resource Identifier (URI) + * @param uri A value representing an encoded URI. + */ +declare function encodeURI(uri: string): string; + +/** + * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). + * @param uriComponent A value representing an encoded URI component. + */ +declare function encodeURIComponent(uriComponent: string): string; + +interface PropertyDescriptor { + configurable?: boolean; + enumerable?: boolean; + value?: any; + writable?: boolean; + get? (): any; + set? (v: any): void; +} + +interface PropertyDescriptorMap { + [s: string]: PropertyDescriptor; +} + +interface Object { + /** The initial value of Object.prototype.constructor is the standard built-in Object constructor. */ + constructor: Function; + + /** Returns a string representation of an object. */ + toString(): string; + + /** Returns a date converted to a string using the current locale. */ + toLocaleString(): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): Object; + + /** + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ + hasOwnProperty(v: string): boolean; + + /** + * Determines whether an object exists in another object's prototype chain. + * @param v Another object whose prototype chain is to be checked. + */ + isPrototypeOf(v: Object): boolean; + + /** + * Determines whether a specified property is enumerable. + * @param v A property name. + */ + propertyIsEnumerable(v: string): boolean; +} + +interface ObjectConstructor { + new (value?: any): Object; + (): any; + (value: any): any; + + /** A reference to the prototype for a class of objects. */ + readonly prototype: Object; + + /** + * Returns the prototype of an object. + * @param o The object that references the prototype. + */ + getPrototypeOf(o: any): any; + + /** + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ + getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; + + /** + * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly + * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. + * @param o Object that contains the own properties. + */ + getOwnPropertyNames(o: any): string[]; + + /** + * Creates an object that has the specified prototype, and that optionally contains specified properties. + * @param o Object to use as a prototype. May be null + * @param properties JavaScript object that contains one or more property descriptors. + */ + create(o: any, properties?: PropertyDescriptorMap): any; + + /** + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor property. + */ + defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; + + /** + * Adds one or more properties to an object, and/or modifies attributes of existing properties. + * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. + * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. + */ + defineProperties(o: any, properties: PropertyDescriptorMap): any; + + /** + * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + seal(o: T): T; + + /** + * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + freeze(o: T): T; + + /** + * Prevents the addition of new properties to an object. + * @param o Object to make non-extensible. + */ + preventExtensions(o: T): T; + + /** + * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. + * @param o Object to test. + */ + isSealed(o: any): boolean; + + /** + * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. + * @param o Object to test. + */ + isFrozen(o: any): boolean; + + /** + * Returns a value that indicates whether new properties can be added to an object. + * @param o Object to test. + */ + isExtensible(o: any): boolean; + + /** + * Returns the names of the enumerable properties and methods of an object. + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ + keys(o: any): string[]; +} + +/** + * Provides functionality common to all JavaScript objects. + */ +declare const Object: ObjectConstructor; + +/** + * Creates a new function. + */ +interface Function { + /** + * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. + * @param thisArg The object to be used as the this object. + * @param argArray A set of arguments to be passed to the function. + */ + apply(thisArg: any, argArray?: any): any; + + /** + * Calls a method of an object, substituting another object for the current object. + * @param thisArg The object to be used as the current object. + * @param argArray A list of arguments to be passed to the method. + */ + call(thisArg: any, ...argArray: any[]): any; + + /** + * For a given function, creates a bound function that has the same body as the original function. + * The this object of the bound function is associated with the specified object, and has the specified initial parameters. + * @param thisArg An object to which the this keyword can refer inside the new function. + * @param argArray A list of arguments to be passed to the new function. + */ + bind(thisArg: any, ...argArray: any[]): any; + + prototype: any; + readonly length: number; + + // Non-standard extensions + arguments: any; + caller: Function; +} + +interface FunctionConstructor { + /** + * Creates a new function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): Function; + (...args: string[]): Function; + readonly prototype: Function; +} + +declare const Function: FunctionConstructor; + +interface IArguments { + [index: number]: any; + length: number; + callee: Function; +} + +interface String { + /** Returns a string representation of a string. */ + toString(): string; + + /** + * Returns the character at the specified index. + * @param pos The zero-based index of the desired character. + */ + charAt(pos: number): string; + + /** + * Returns the Unicode value of the character at the specified location. + * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. + */ + charCodeAt(index: number): number; + + /** + * Returns a string that contains the concatenation of two or more strings. + * @param strings The strings to append to the end of the string. + */ + concat(...strings: string[]): string; + + /** + * Returns the position of the first occurrence of a substring. + * @param searchString The substring to search for in the string + * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. + */ + indexOf(searchString: string, position?: number): number; + + /** + * Returns the last occurrence of a substring in the string. + * @param searchString The substring to search for. + * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. + */ + lastIndexOf(searchString: string, position?: number): number; + + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + */ + localeCompare(that: string): number; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ + match(regexp: string): RegExpMatchArray; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. + */ + match(regexp: RegExp): RegExpMatchArray; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A string that represents the regular expression. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ + replace(searchValue: string, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A string that represents the regular expression. + * @param replacer A function that returns the replacement text. + */ + replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ + replace(searchValue: RegExp, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replacer A function that returns the replacement text. + */ + replace(searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: string): number; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: RegExp): number; + + /** + * Returns a section of a string. + * @param start The index to the beginning of the specified portion of stringObj. + * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. + * If this value is not specified, the substring continues to the end of stringObj. + */ + slice(start?: number, end?: number): string; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: string, limit?: number): string[]; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: RegExp, limit?: number): string[]; + + /** + * Returns the substring at the specified location within a String object. + * @param start The zero-based index number indicating the beginning of the substring. + * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. + * If end is omitted, the characters from start through the end of the original string are returned. + */ + substring(start: number, end?: number): string; + + /** Converts all the alphabetic characters in a string to lowercase. */ + toLowerCase(): string; + + /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ + toLocaleLowerCase(): string; + + /** Converts all the alphabetic characters in a string to uppercase. */ + toUpperCase(): string; + + /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ + toLocaleUpperCase(): string; + + /** Removes the leading and trailing white space and line terminator characters from a string. */ + trim(): string; + + /** Returns the length of a String object. */ + readonly length: number; + + // IE extensions + /** + * Gets a substring beginning at the specified location and having the specified length. + * @param from The starting position of the desired substring. The index of the first character in the string is zero. + * @param length The number of characters to include in the returned substring. + */ + substr(from: number, length?: number): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): string; + + readonly [index: number]: string; +} + +interface StringConstructor { + new (value?: any): String; + (value?: any): string; + readonly prototype: String; + fromCharCode(...codes: number[]): string; +} + +/** + * Allows manipulation and formatting of text strings and determination and location of substrings within strings. + */ +declare const String: StringConstructor; + +interface Boolean { + /** Returns the primitive value of the specified object. */ + valueOf(): boolean; +} + +interface BooleanConstructor { + new (value?: any): Boolean; + (value?: any): boolean; + readonly prototype: Boolean; +} + +declare const Boolean: BooleanConstructor; + +interface Number { + /** + * Returns a string representation of an object. + * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. + */ + toString(radix?: number): string; + + /** + * Returns a string representing a number in fixed-point notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toFixed(fractionDigits?: number): string; + + /** + * Returns a string containing a number represented in exponential notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toExponential(fractionDigits?: number): string; + + /** + * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. + * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. + */ + toPrecision(precision?: number): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): number; +} + +interface NumberConstructor { + new (value?: any): Number; + (value?: any): number; + readonly prototype: Number; + + /** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */ + readonly MAX_VALUE: number; + + /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ + readonly MIN_VALUE: number; + + /** + * A value that is not a number. + * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. + */ + readonly NaN: number; + + /** + * A value that is less than the largest negative number that can be represented in JavaScript. + * JavaScript displays NEGATIVE_INFINITY values as -infinity. + */ + readonly NEGATIVE_INFINITY: number; + + /** + * A value greater than the largest number that can be represented in JavaScript. + * JavaScript displays POSITIVE_INFINITY values as infinity. + */ + readonly POSITIVE_INFINITY: number; +} + +/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ +declare const Number: NumberConstructor; + +interface TemplateStringsArray extends Array { + readonly raw: string[]; +} + +interface Math { + /** The mathematical constant e. This is Euler's number, the base of natural logarithms. */ + readonly E: number; + /** The natural logarithm of 10. */ + readonly LN10: number; + /** The natural logarithm of 2. */ + readonly LN2: number; + /** The base-2 logarithm of e. */ + readonly LOG2E: number; + /** The base-10 logarithm of e. */ + readonly LOG10E: number; + /** Pi. This is the ratio of the circumference of a circle to its diameter. */ + readonly PI: number; + /** The square root of 0.5, or, equivalently, one divided by the square root of 2. */ + readonly SQRT1_2: number; + /** The square root of 2. */ + readonly SQRT2: number; + /** + * Returns the absolute value of a number (the value without regard to whether it is positive or negative). + * For example, the absolute value of -5 is the same as the absolute value of 5. + * @param x A numeric expression for which the absolute value is needed. + */ + abs(x: number): number; + /** + * Returns the arc cosine (or inverse cosine) of a number. + * @param x A numeric expression. + */ + acos(x: number): number; + /** + * Returns the arcsine of a number. + * @param x A numeric expression. + */ + asin(x: number): number; + /** + * Returns the arctangent of a number. + * @param x A numeric expression for which the arctangent is needed. + */ + atan(x: number): number; + /** + * Returns the angle (in radians) from the X axis to a point. + * @param y A numeric expression representing the cartesian y-coordinate. + * @param x A numeric expression representing the cartesian x-coordinate. + */ + atan2(y: number, x: number): number; + /** + * Returns the smallest number greater than or equal to its numeric argument. + * @param x A numeric expression. + */ + ceil(x: number): number; + /** + * Returns the cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cos(x: number): number; + /** + * Returns e (the base of natural logarithms) raised to a power. + * @param x A numeric expression representing the power of e. + */ + exp(x: number): number; + /** + * Returns the greatest number less than or equal to its numeric argument. + * @param x A numeric expression. + */ + floor(x: number): number; + /** + * Returns the natural logarithm (base e) of a number. + * @param x A numeric expression. + */ + log(x: number): number; + /** + * Returns the larger of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + max(...values: number[]): number; + /** + * Returns the smaller of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + min(...values: number[]): number; + /** + * Returns the value of a base expression taken to a specified power. + * @param x The base value of the expression. + * @param y The exponent value of the expression. + */ + pow(x: number, y: number): number; + /** Returns a pseudorandom number between 0 and 1. */ + random(): number; + /** + * Returns a supplied numeric expression rounded to the nearest number. + * @param x The value to be rounded to the nearest number. + */ + round(x: number): number; + /** + * Returns the sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sin(x: number): number; + /** + * Returns the square root of a number. + * @param x A numeric expression. + */ + sqrt(x: number): number; + /** + * Returns the tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tan(x: number): number; +} +/** An intrinsic object that provides basic mathematics functionality and constants. */ +declare const Math: Math; + +/** Enables basic storage and retrieval of dates and times. */ +interface Date { + /** Returns a string representation of a date. The format of the string depends on the locale. */ + toString(): string; + /** Returns a date as a string value. */ + toDateString(): string; + /** Returns a time as a string value. */ + toTimeString(): string; + /** Returns a value as a string value appropriate to the host environment's current locale. */ + toLocaleString(): string; + /** Returns a date as a string value appropriate to the host environment's current locale. */ + toLocaleDateString(): string; + /** Returns a time as a string value appropriate to the host environment's current locale. */ + toLocaleTimeString(): string; + /** Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. */ + valueOf(): number; + /** Gets the time value in milliseconds. */ + getTime(): number; + /** Gets the year, using local time. */ + getFullYear(): number; + /** Gets the year using Universal Coordinated Time (UTC). */ + getUTCFullYear(): number; + /** Gets the month, using local time. */ + getMonth(): number; + /** Gets the month of a Date object using Universal Coordinated Time (UTC). */ + getUTCMonth(): number; + /** Gets the day-of-the-month, using local time. */ + getDate(): number; + /** Gets the day-of-the-month, using Universal Coordinated Time (UTC). */ + getUTCDate(): number; + /** Gets the day of the week, using local time. */ + getDay(): number; + /** Gets the day of the week using Universal Coordinated Time (UTC). */ + getUTCDay(): number; + /** Gets the hours in a date, using local time. */ + getHours(): number; + /** Gets the hours value in a Date object using Universal Coordinated Time (UTC). */ + getUTCHours(): number; + /** Gets the minutes of a Date object, using local time. */ + getMinutes(): number; + /** Gets the minutes of a Date object using Universal Coordinated Time (UTC). */ + getUTCMinutes(): number; + /** Gets the seconds of a Date object, using local time. */ + getSeconds(): number; + /** Gets the seconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCSeconds(): number; + /** Gets the milliseconds of a Date, using local time. */ + getMilliseconds(): number; + /** Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCMilliseconds(): number; + /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ + getTimezoneOffset(): number; + /** + * Sets the date and time value in the Date object. + * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. + */ + setTime(time: number): number; + /** + * Sets the milliseconds value in the Date object using local time. + * @param ms A numeric value equal to the millisecond value. + */ + setMilliseconds(ms: number): number; + /** + * Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). + * @param ms A numeric value equal to the millisecond value. + */ + setUTCMilliseconds(ms: number): number; + + /** + * Sets the seconds value in the Date object using local time. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setSeconds(sec: number, ms?: number): number; + /** + * Sets the seconds value in the Date object using Universal Coordinated Time (UTC). + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCSeconds(sec: number, ms?: number): number; + /** + * Sets the minutes value in the Date object using local time. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setMinutes(min: number, sec?: number, ms?: number): number; + /** + * Sets the minutes value in the Date object using Universal Coordinated Time (UTC). + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCMinutes(min: number, sec?: number, ms?: number): number; + /** + * Sets the hour value in the Date object using local time. + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setHours(hours: number, min?: number, sec?: number, ms?: number): number; + /** + * Sets the hours value in the Date object using Universal Coordinated Time (UTC). + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCHours(hours: number, min?: number, sec?: number, ms?: number): number; + /** + * Sets the numeric day-of-the-month value of the Date object using local time. + * @param date A numeric value equal to the day of the month. + */ + setDate(date: number): number; + /** + * Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). + * @param date A numeric value equal to the day of the month. + */ + setUTCDate(date: number): number; + /** + * Sets the month value in the Date object using local time. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used. + */ + setMonth(month: number, date?: number): number; + /** + * Sets the month value in the Date object using Universal Coordinated Time (UTC). + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used. + */ + setUTCMonth(month: number, date?: number): number; + /** + * Sets the year of the Date object using local time. + * @param year A numeric value for the year. + * @param month A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified. + * @param date A numeric value equal for the day of the month. + */ + setFullYear(year: number, month?: number, date?: number): number; + /** + * Sets the year value in the Date object using Universal Coordinated Time (UTC). + * @param year A numeric value equal to the year. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied. + * @param date A numeric value equal to the day of the month. + */ + setUTCFullYear(year: number, month?: number, date?: number): number; + /** Returns a date converted to a string using Universal Coordinated Time (UTC). */ + toUTCString(): string; + /** Returns a date as a string value in ISO format. */ + toISOString(): string; + /** Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. */ + toJSON(key?: any): string; +} + +interface DateConstructor { + new (): Date; + new (value: number): Date; + new (value: string): Date; + new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; + (): string; + readonly prototype: Date; + /** + * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. + * @param s A date string + */ + parse(s: string): number; + /** + * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. + * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. + * @param month The month as an number between 0 and 11 (January to December). + * @param date The date as an number between 1 and 31. + * @param hours Must be supplied if minutes is supplied. An number from 0 to 23 (midnight to 11pm) that specifies the hour. + * @param minutes Must be supplied if seconds is supplied. An number from 0 to 59 that specifies the minutes. + * @param seconds Must be supplied if milliseconds is supplied. An number from 0 to 59 that specifies the seconds. + * @param ms An number from 0 to 999 that specifies the milliseconds. + */ + UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; + now(): number; +} + +declare const Date: DateConstructor; + +interface RegExpMatchArray extends Array { + index?: number; + input?: string; +} + +interface RegExpExecArray extends Array { + index: number; + input: string; +} + +interface RegExp { + /** + * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. + * @param string The String object or string literal on which to perform the search. + */ + exec(string: string): RegExpExecArray; + + /** + * Returns a Boolean value that indicates whether or not a pattern exists in a searched string. + * @param string String on which to perform the search. + */ + test(string: string): boolean; + + /** Returns a copy of the text of the regular expression pattern. Read-only. The regExp argument is a Regular expression object. It can be a variable name or a literal. */ + readonly source: string; + + /** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */ + readonly global: boolean; + + /** Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. */ + readonly ignoreCase: boolean; + + /** Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. */ + readonly multiline: boolean; + + lastIndex: number; + + // Non-standard extensions + compile(): RegExp; +} + +interface RegExpConstructor { + new (pattern: string, flags?: string): RegExp; + (pattern: string, flags?: string): RegExp; + readonly prototype: RegExp; + + // Non-standard extensions + $1: string; + $2: string; + $3: string; + $4: string; + $5: string; + $6: string; + $7: string; + $8: string; + $9: string; + lastMatch: string; +} + +declare const RegExp: RegExpConstructor; + +interface Error { + name: string; + message: string; +} + +interface ErrorConstructor { + new (message?: string): Error; + (message?: string): Error; + readonly prototype: Error; +} + +declare const Error: ErrorConstructor; + +interface EvalError extends Error { +} + +interface EvalErrorConstructor { + new (message?: string): EvalError; + (message?: string): EvalError; + readonly prototype: EvalError; +} + +declare const EvalError: EvalErrorConstructor; + +interface RangeError extends Error { +} + +interface RangeErrorConstructor { + new (message?: string): RangeError; + (message?: string): RangeError; + readonly prototype: RangeError; +} + +declare const RangeError: RangeErrorConstructor; + +interface ReferenceError extends Error { +} + +interface ReferenceErrorConstructor { + new (message?: string): ReferenceError; + (message?: string): ReferenceError; + readonly prototype: ReferenceError; +} + +declare const ReferenceError: ReferenceErrorConstructor; + +interface SyntaxError extends Error { +} + +interface SyntaxErrorConstructor { + new (message?: string): SyntaxError; + (message?: string): SyntaxError; + readonly prototype: SyntaxError; +} + +declare const SyntaxError: SyntaxErrorConstructor; + +interface TypeError extends Error { +} + +interface TypeErrorConstructor { + new (message?: string): TypeError; + (message?: string): TypeError; + readonly prototype: TypeError; +} + +declare const TypeError: TypeErrorConstructor; + +interface URIError extends Error { +} + +interface URIErrorConstructor { + new (message?: string): URIError; + (message?: string): URIError; + readonly prototype: URIError; +} + +declare const URIError: URIErrorConstructor; + +interface JSON { + /** + * Converts a JavaScript Object Notation (JSON) string into an object. + * @param text A valid JSON string. + * @param reviver A function that transforms the results. This function is called for each member of the object. + * If a member contains nested objects, the nested objects are transformed before the parent object is. + */ + parse(text: string, reviver?: (key: any, value: any) => any): any; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + */ + stringify(value: any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + */ + stringify(value: any, replacer: (key: string, value: any) => any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer Array that transforms the results. + */ + stringify(value: any, replacer: any[]): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ + stringify(value: any, replacer: (key: string, value: any) => any, space: string | number): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer Array that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ + stringify(value: any, replacer: any[], space: string | number): string; +} +/** + * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. + */ +declare const JSON: JSON; + + +///////////////////////////// +/// ECMAScript Array API (specially handled by compiler) +///////////////////////////// + +interface ReadonlyArray { + /** + * Gets the length of the array. This is a number one higher than the highest element defined in an array. + */ + readonly length: number; + /** + * Returns a string representation of an array. + */ + toString(): string; + toLocaleString(): string; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat>(...items: U[]): T[]; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: T[]): T[]; + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): T[]; + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + */ + indexOf(searchElement: T, fromIndex?: number): number; + + /** + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ + lastIndexOf(searchElement: T, fromIndex?: number): number; + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): boolean; + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): boolean; + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: T, index: number, array: ReadonlyArray) => void, thisArg?: any): void; + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: T, index: number, array: ReadonlyArray) => U, thisArg?: any): U[]; + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): T[]; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: ReadonlyArray) => U, initialValue: U): U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: ReadonlyArray) => U, initialValue: U): U; + + readonly [n: number]: T; +} + +interface Array { + /** + * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. + */ + length: number; + /** + * Returns a string representation of an array. + */ + toString(): string; + toLocaleString(): string; + /** + * Appends new elements to an array, and returns the new length of the array. + * @param items New elements of the Array. + */ + push(...items: T[]): number; + /** + * Removes the last element from an array and returns it. + */ + pop(): T; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: (T | T[])[]): T[]; + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + /** + * Reverses the elements in an Array. + */ + reverse(): T[]; + /** + * Removes the first element from an array and returns it. + */ + shift(): T; + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): T[]; + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: T, b: T) => number): T[]; + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + */ + splice(start: number): T[]; + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @param items Elements to insert into the array in place of the deleted elements. + */ + splice(start: number, deleteCount: number, ...items: T[]): T[]; + /** + * Inserts new elements at the start of an array. + * @param items Elements to insert at the start of the Array. + */ + unshift(...items: T[]): number; + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + */ + indexOf(searchElement: T, fromIndex?: number): number; + /** + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ + lastIndexOf(searchElement: T, fromIndex?: number): number; + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + [n: number]: T; +} + +interface ArrayConstructor { + new (arrayLength?: number): any[]; + new (arrayLength: number): T[]; + new (...items: T[]): T[]; + (arrayLength?: number): any[]; + (arrayLength: number): T[]; + (...items: T[]): T[]; + isArray(arg: any): arg is Array; + readonly prototype: Array; +} + +declare const Array: ArrayConstructor; + +interface TypedPropertyDescriptor { + enumerable?: boolean; + configurable?: boolean; + writable?: boolean; + value?: T; + get?: () => T; + set?: (value: T) => void; +} + +declare type ClassDecorator = (target: TFunction) => TFunction | void; +declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void; +declare type MethodDecorator = (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor | void; +declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void; + +declare type PromiseConstructorLike = new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void) => PromiseLike; + +interface PromiseLike { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; +} + +interface ArrayLike { + readonly length: number; + readonly [n: number]: T; +} + +/** + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ +interface ArrayBuffer { + /** + * Read-only. The length of the ArrayBuffer (in bytes). + */ + readonly byteLength: number; + + /** + * Returns a section of an ArrayBuffer. + */ + slice(begin:number, end?:number): ArrayBuffer; +} + +interface ArrayBufferConstructor { + readonly prototype: ArrayBuffer; + new (byteLength: number): ArrayBuffer; + isView(arg: any): arg is ArrayBufferView; +} +declare const ArrayBuffer: ArrayBufferConstructor; + +interface ArrayBufferView { + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; +} + +interface DataView { + readonly buffer: ArrayBuffer; + readonly byteLength: number; + readonly byteOffset: number; + /** + * Gets the Float32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Float64 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat64(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Int8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt8(byteOffset: number): number; + + /** + * Gets the Int16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt16(byteOffset: number, littleEndian?: boolean): number; + /** + * Gets the Int32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Uint8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint8(byteOffset: number): number; + + /** + * Gets the Uint16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint16(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Uint32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Stores an Float32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Float64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Int8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setInt8(byteOffset: number, value: number): void; + + /** + * Stores an Int16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Int32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Uint8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setUint8(byteOffset: number, value: number): void; + + /** + * Stores an Uint16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Uint32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; +} + +interface DataViewConstructor { + new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; +} +declare const DataView: DataViewConstructor; + +/** + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Int8Array { + /** + * The size in bytes of each element in the array. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int8Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + readonly length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int8Array; + + /** + * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} +interface Int8ArrayConstructor { + readonly prototype: Int8Array; + new (length: number): Int8Array; + new (array: ArrayLike): Int8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; + + /** + * The size in bytes of each element in the array. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + +} +declare const Int8Array: Int8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array { + /** + * The size in bytes of each element in the array. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + readonly length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8Array; + + /** + * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ArrayConstructor { + readonly prototype: Uint8Array; + new (length: number): Uint8Array; + new (array: ArrayLike): Uint8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; + + /** + * The size in bytes of each element in the array. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + +} +declare const Uint8Array: Uint8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + /** + * The size in bytes of each element in the array. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8ClampedArray; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + readonly length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8ClampedArray; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8ClampedArray, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + + /** + * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8ClampedArray; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ClampedArrayConstructor { + readonly prototype: Uint8ClampedArray; + new (length: number): Uint8ClampedArray; + new (array: ArrayLike): Uint8ClampedArray; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + + /** + * The size in bytes of each element in the array. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8ClampedArray; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; +} +declare const Uint8ClampedArray: Uint8ClampedArrayConstructor; + +/** + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array { + /** + * The size in bytes of each element in the array. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int16Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + readonly length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int16Array; + + /** + * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Int16ArrayConstructor { + readonly prototype: Int16Array; + new (length: number): Int16Array; + new (array: ArrayLike): Int16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; + + /** + * The size in bytes of each element in the array. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + +} +declare const Int16Array: Int16ArrayConstructor; + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array { + /** + * The size in bytes of each element in the array. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint16Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + readonly length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint16Array; + + /** + * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint16ArrayConstructor { + readonly prototype: Uint16Array; + new (length: number): Uint16Array; + new (array: ArrayLike): Uint16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; + + /** + * The size in bytes of each element in the array. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + +} +declare const Uint16Array: Uint16ArrayConstructor; +/** + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array { + /** + * The size in bytes of each element in the array. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int32Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + readonly length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int32Array; + + /** + * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Int32ArrayConstructor { + readonly prototype: Int32Array; + new (length: number): Int32Array; + new (array: ArrayLike): Int32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; + + /** + * The size in bytes of each element in the array. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; +} +declare const Int32Array: Int32ArrayConstructor; + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array { + /** + * The size in bytes of each element in the array. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint32Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + readonly length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint32Array; + + /** + * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint32ArrayConstructor { + readonly prototype: Uint32Array; + new (length: number): Uint32Array; + new (array: ArrayLike): Uint32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; + + /** + * The size in bytes of each element in the array. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; +} +declare const Uint32Array: Uint32ArrayConstructor; + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ +interface Float32Array { + /** + * The size in bytes of each element in the array. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float32Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + readonly length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float32Array; + + /** + * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Float32ArrayConstructor { + readonly prototype: Float32Array; + new (length: number): Float32Array; + new (array: ArrayLike): Float32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; + + /** + * The size in bytes of each element in the array. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + +} +declare const Float32Array: Float32ArrayConstructor; + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Float64Array { + /** + * The size in bytes of each element in the array. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float64Array; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float64Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + readonly length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float64Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float64Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float64Array; + + /** + * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float64Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Float64ArrayConstructor { + readonly prototype: Float64Array; + new (length: number): Float64Array; + new (array: ArrayLike): Float64Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; + + /** + * The size in bytes of each element in the array. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; +} +declare const Float64Array: Float64ArrayConstructor; diff --git a/jsweet-candy-generator/src/test/resources/lib.core/lib.core.ext.d.ts b/jsweet-candy-generator/src/test/resources/lib.core/lib.core.ext.d.ts new file mode 100644 index 00000000..cab3e76a --- /dev/null +++ b/jsweet-candy-generator/src/test/resources/lib.core/lib.core.ext.d.ts @@ -0,0 +1,52 @@ +/** + * @External + */ +declare class RuntimeException { +} + +interface Error extends RuntimeException { +} + +/** + * @External + */ +interface Iterable { +} + +//interface String extends RuntimeException { +//} + +interface Object { + /** + * Gets the value for the given key. Generates this[key]. + * + * @see jsweet.util.Globals#$get(java.lang.String) + * @see jsweet.util.Globals#$set(java.lang.String,java.lang.Object) + * @see jsweet.util.Globals#$delete(java.lang.String) + */ + $get(key:String):Object; + /** + * Sets the value for the given key. Generates this[key]=value. + * + * @see jsweet.util.Globals#$get(java.lang.String) + * @see jsweet.util.Globals#$set(java.lang.String,java.lang.Object) + * @see jsweet.util.Globals#$delete(java.lang.String) + */ + $set(key:String,value:Object):void; + /** + * Deletes the value of the given key. Generates delete this[key]. + * + * @see jsweet.util.Globals#$get(java.lang.String) + * @see jsweet.util.Globals#$set(java.lang.String,java.lang.Object) + * @see jsweet.util.Globals#$delete(java.lang.String) + */ + $delete(key: String):void; + $super(...params : any[]):Object; +} + +interface Array { + + reduce(callbackfn: (reducedValue: R, currentValue: T) => R, initialValue?: R): R; + +} + diff --git a/jsweet-candy-generator/src/test/resources/lib.core/lib.dom.d.ts b/jsweet-candy-generator/src/test/resources/lib.core/lib.dom.d.ts new file mode 100644 index 00000000..0bf60c57 --- /dev/null +++ b/jsweet-candy-generator/src/test/resources/lib.core/lib.dom.d.ts @@ -0,0 +1,13208 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft 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 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +/// +///////////////////////////// +/// ECMAScript Internationalization API +///////////////////////////// + +declare module Intl { + interface CollatorOptions { + usage?: string; + localeMatcher?: string; + numeric?: boolean; + caseFirst?: string; + sensitivity?: string; + ignorePunctuation?: boolean; + } + + interface ResolvedCollatorOptions { + locale: string; + usage: string; + sensitivity: string; + ignorePunctuation: boolean; + collation: string; + caseFirst: string; + numeric: boolean; + } + + interface Collator { + compare(x: string, y: string): number; + resolvedOptions(): ResolvedCollatorOptions; + } + var Collator: { + new (locales?: string[], options?: CollatorOptions): Collator; + new (locale?: string, options?: CollatorOptions): Collator; + (locales?: string[], options?: CollatorOptions): Collator; + (locale?: string, options?: CollatorOptions): Collator; + supportedLocalesOf(locales: string[], options?: CollatorOptions): string[]; + supportedLocalesOf(locale: string, options?: CollatorOptions): string[]; + } + + interface NumberFormatOptions { + localeMatcher?: string; + style?: string; + currency?: string; + currencyDisplay?: string; + useGrouping?: boolean; + minimumIntegerDigits?: number; + minimumFractionDigits?: number; + maximumFractionDigits?: number; + minimumSignificantDigits?: number; + maximumSignificantDigits?: number; + } + + interface ResolvedNumberFormatOptions { + locale: string; + numberingSystem: string; + style: string; + currency?: string; + currencyDisplay?: string; + minimumIntegerDigits: number; + minimumFractionDigits: number; + maximumFractionDigits: number; + minimumSignificantDigits?: number; + maximumSignificantDigits?: number; + useGrouping: boolean; + } + + interface NumberFormat { + format(value: number): string; + resolvedOptions(): ResolvedNumberFormatOptions; + } + var NumberFormat: { + new (locales?: string[], options?: NumberFormatOptions): NumberFormat; + new (locale?: string, options?: NumberFormatOptions): NumberFormat; + (locales?: string[], options?: NumberFormatOptions): NumberFormat; + (locale?: string, options?: NumberFormatOptions): NumberFormat; + supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[]; + supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[]; + } + + interface DateTimeFormatOptions { + localeMatcher?: string; + weekday?: string; + era?: string; + year?: string; + month?: string; + day?: string; + hour?: string; + minute?: string; + second?: string; + timeZoneName?: string; + formatMatcher?: string; + hour12?: boolean; + timeZone?: string; + } + + interface ResolvedDateTimeFormatOptions { + locale: string; + calendar: string; + numberingSystem: string; + timeZone: string; + hour12?: boolean; + weekday?: string; + era?: string; + year?: string; + month?: string; + day?: string; + hour?: string; + minute?: string; + second?: string; + timeZoneName?: string; + } + + interface DateTimeFormat { + format(date?: Date | number): string; + resolvedOptions(): ResolvedDateTimeFormatOptions; + } + var DateTimeFormat: { + new (locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat; + new (locale?: string, options?: DateTimeFormatOptions): DateTimeFormat; + (locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat; + (locale?: string, options?: DateTimeFormatOptions): DateTimeFormat; + supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[]; + supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[]; + } +} + +interface String { + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. + * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. + */ + localeCompare(that: string, locales: string[], options?: Intl.CollatorOptions): number; + + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. + * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. + */ + localeCompare(that: string, locale: string, options?: Intl.CollatorOptions): number; +} + +interface Number { + /** + * Converts a number to a string by using the current or specified locale. + * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locales?: string[], options?: Intl.NumberFormatOptions): string; + + /** + * Converts a number to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locale?: string, options?: Intl.NumberFormatOptions): string; +} + +interface Date { + /** + * Converts a date and time to a string by using the current or specified locale. + * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; + /** + * Converts a date to a string by using the current or specified locale. + * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleDateString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; + + /** + * Converts a time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleTimeString(locale?: string[], options?: Intl.DateTimeFormatOptions): string; + + /** + * Converts a date and time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string; + + /** + * Converts a date to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleDateString(locale?: string, options?: Intl.DateTimeFormatOptions): string; + + /** + * Converts a time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleTimeString(locale?: string, options?: Intl.DateTimeFormatOptions): string; +} + + +///////////////////////////// +/// IE DOM APIs +///////////////////////////// + +interface Algorithm { + name?: string; +} + +interface AriaRequestEventInit extends EventInit { + attributeName?: string; + attributeValue?: string; +} + +interface ClipboardEventInit extends EventInit { + data?: string; + dataType?: string; +} + +interface CommandEventInit extends EventInit { + commandName?: string; + detail?: string; +} + +interface CompositionEventInit extends UIEventInit { + data?: string; +} + +interface ConfirmSiteSpecificExceptionsInformation extends ExceptionInformation { + arrayOfDomainStrings?: string[]; +} + +interface CustomEventInit extends EventInit { + detail?: any; +} + +interface DeviceAccelerationDict { + x?: number; + y?: number; + z?: number; +} + +interface DeviceRotationRateDict { + alpha?: number; + beta?: number; + gamma?: number; +} + +interface EventInit { + bubbles?: boolean; + cancelable?: boolean; +} + +interface ExceptionInformation { + domain?: string; +} + +interface FocusEventInit extends UIEventInit { + relatedTarget?: EventTarget; +} + +interface HashChangeEventInit extends EventInit { + newURL?: string; + oldURL?: string; +} + +interface KeyAlgorithm { + name?: string; +} + +interface KeyboardEventInit extends SharedKeyboardAndMouseEventInit { + key?: string; + location?: number; + repeat?: boolean; +} + +interface MouseEventInit extends SharedKeyboardAndMouseEventInit { + screenX?: number; + screenY?: number; + clientX?: number; + clientY?: number; + button?: number; + buttons?: number; + relatedTarget?: EventTarget; +} + +interface MsZoomToOptions { + contentX?: number; + contentY?: number; + viewportX?: string; + viewportY?: string; + scaleFactor?: number; + animate?: string; +} + +interface MutationObserverInit { + childList?: boolean; + attributes?: boolean; + characterData?: boolean; + subtree?: boolean; + attributeOldValue?: boolean; + characterDataOldValue?: boolean; + attributeFilter?: string[]; +} + +interface ObjectURLOptions { + oneTimeOnly?: boolean; +} + +interface PointerEventInit extends MouseEventInit { + pointerId?: number; + width?: number; + height?: number; + pressure?: number; + tiltX?: number; + tiltY?: number; + pointerType?: string; + isPrimary?: boolean; +} + +interface PositionOptions { + enableHighAccuracy?: boolean; + timeout?: number; + maximumAge?: number; +} + +interface SharedKeyboardAndMouseEventInit extends UIEventInit { + ctrlKey?: boolean; + shiftKey?: boolean; + altKey?: boolean; + metaKey?: boolean; + keyModifierStateAltGraph?: boolean; + keyModifierStateCapsLock?: boolean; + keyModifierStateFn?: boolean; + keyModifierStateFnLock?: boolean; + keyModifierStateHyper?: boolean; + keyModifierStateNumLock?: boolean; + keyModifierStateOS?: boolean; + keyModifierStateScrollLock?: boolean; + keyModifierStateSuper?: boolean; + keyModifierStateSymbol?: boolean; + keyModifierStateSymbolLock?: boolean; +} + +interface StoreExceptionsInformation extends ExceptionInformation { + siteName?: string; + explanationString?: string; + detailURI?: string; +} + +interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation { + arrayOfDomainStrings?: string[]; +} + +interface UIEventInit extends EventInit { + view?: Window; + detail?: number; +} + +interface WebGLContextAttributes { + alpha?: boolean; + depth?: boolean; + stencil?: boolean; + antialias?: boolean; + premultipliedAlpha?: boolean; + preserveDrawingBuffer?: boolean; +} + +interface WebGLContextEventInit extends EventInit { + statusMessage?: string; +} + +interface WheelEventInit extends MouseEventInit { + deltaX?: number; + deltaY?: number; + deltaZ?: number; + deltaMode?: number; +} + +interface EventListener { + (evt: Event): void; +} + +interface ANGLE_instanced_arrays { + drawArraysInstancedANGLE(mode: number, first: number, count: number, primcount: number): void; + drawElementsInstancedANGLE(mode: number, count: number, type: number, offset: number, primcount: number): void; + vertexAttribDivisorANGLE(index: number, divisor: number): void; + VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: number; +} + +declare var ANGLE_instanced_arrays: { + prototype: ANGLE_instanced_arrays; + new(): ANGLE_instanced_arrays; + VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: number; +} + +interface AnalyserNode extends AudioNode { + fftSize: number; + frequencyBinCount: number; + maxDecibels: number; + minDecibels: number; + smoothingTimeConstant: number; + getByteFrequencyData(array: Uint8Array): void; + getByteTimeDomainData(array: Uint8Array): void; + getFloatFrequencyData(array: Float32Array): void; + getFloatTimeDomainData(array: Float32Array): void; +} + +declare var AnalyserNode: { + prototype: AnalyserNode; + new(): AnalyserNode; +} + +interface AnimationEvent extends Event { + animationName: string; + elapsedTime: number; + initAnimationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, animationNameArg: string, elapsedTimeArg: number): void; +} + +declare var AnimationEvent: { + prototype: AnimationEvent; + new(): AnimationEvent; +} + +interface ApplicationCache extends EventTarget { + oncached: (ev: Event) => any; + onchecking: (ev: Event) => any; + ondownloading: (ev: Event) => any; + onerror: (ev: Event) => any; + onnoupdate: (ev: Event) => any; + onobsolete: (ev: Event) => any; + onprogress: (ev: ProgressEvent) => any; + onupdateready: (ev: Event) => any; + status: number; + abort(): void; + swapCache(): void; + update(): void; + CHECKING: number; + DOWNLOADING: number; + IDLE: number; + OBSOLETE: number; + UNCACHED: number; + UPDATEREADY: number; + addEventListener(type: "cached", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "checking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "downloading", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "noupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "obsolete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "updateready", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ApplicationCache: { + prototype: ApplicationCache; + new(): ApplicationCache; + CHECKING: number; + DOWNLOADING: number; + IDLE: number; + OBSOLETE: number; + UNCACHED: number; + UPDATEREADY: number; +} + +interface AriaRequestEvent extends Event { + attributeName: string; + attributeValue: string; +} + +declare var AriaRequestEvent: { + prototype: AriaRequestEvent; + new(type: string, eventInitDict?: AriaRequestEventInit): AriaRequestEvent; +} + +interface Attr extends Node { + name: string; + ownerElement: Element; + specified: boolean; + value: string; +} + +declare var Attr: { + prototype: Attr; + new(): Attr; +} + +interface AudioBuffer { + duration: number; + length: number; + numberOfChannels: number; + sampleRate: number; + getChannelData(channel: number): Float32Array; +} + +declare var AudioBuffer: { + prototype: AudioBuffer; + new(): AudioBuffer; +} + +interface AudioBufferSourceNode extends AudioNode { + buffer: AudioBuffer; + loop: boolean; + loopEnd: number; + loopStart: number; + onended: (ev: Event) => any; + playbackRate: AudioParam; + start(when?: number, offset?: number, duration?: number): void; + stop(when?: number): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var AudioBufferSourceNode: { + prototype: AudioBufferSourceNode; + new(): AudioBufferSourceNode; +} + +interface AudioContext extends EventTarget { + currentTime: number; + destination: AudioDestinationNode; + listener: AudioListener; + sampleRate: number; + state: string; + createAnalyser(): AnalyserNode; + createBiquadFilter(): BiquadFilterNode; + createBuffer(numberOfChannels: number, length: number, sampleRate: number): AudioBuffer; + createBufferSource(): AudioBufferSourceNode; + createChannelMerger(numberOfInputs?: number): ChannelMergerNode; + createChannelSplitter(numberOfOutputs?: number): ChannelSplitterNode; + createConvolver(): ConvolverNode; + createDelay(maxDelayTime?: number): DelayNode; + createDynamicsCompressor(): DynamicsCompressorNode; + createGain(): GainNode; + createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; + createOscillator(): OscillatorNode; + createPanner(): PannerNode; + createPeriodicWave(real: Float32Array, imag: Float32Array): PeriodicWave; + createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; + createStereoPanner(): StereoPannerNode; + createWaveShaper(): WaveShaperNode; + decodeAudioData(audioData: ArrayBuffer, successCallback: DecodeSuccessCallback, errorCallback?: DecodeErrorCallback): void; +} + +declare var AudioContext: { + prototype: AudioContext; + new(): AudioContext; +} + +interface AudioDestinationNode extends AudioNode { + maxChannelCount: number; +} + +declare var AudioDestinationNode: { + prototype: AudioDestinationNode; + new(): AudioDestinationNode; +} + +interface AudioListener { + dopplerFactor: number; + speedOfSound: number; + setOrientation(x: number, y: number, z: number, xUp: number, yUp: number, zUp: number): void; + setPosition(x: number, y: number, z: number): void; + setVelocity(x: number, y: number, z: number): void; +} + +declare var AudioListener: { + prototype: AudioListener; + new(): AudioListener; +} + +interface AudioNode extends EventTarget { + channelCount: number; + channelCountMode: string; + channelInterpretation: string; + context: AudioContext; + numberOfInputs: number; + numberOfOutputs: number; + connect(destination: AudioNode, output?: number, input?: number): void; + disconnect(output?: number): void; + disconnect(destination: AudioNode, output?: number, input?: number): void; + disconnect(destination: AudioParam, output?: number): void; +} + +declare var AudioNode: { + prototype: AudioNode; + new(): AudioNode; +} + +interface AudioParam { + defaultValue: number; + value: number; + cancelScheduledValues(startTime: number): void; + exponentialRampToValueAtTime(value: number, endTime: number): void; + linearRampToValueAtTime(value: number, endTime: number): void; + setTargetAtTime(target: number, startTime: number, timeConstant: number): void; + setValueAtTime(value: number, startTime: number): void; + setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): void; +} + +declare var AudioParam: { + prototype: AudioParam; + new(): AudioParam; +} + +interface AudioProcessingEvent extends Event { + inputBuffer: AudioBuffer; + outputBuffer: AudioBuffer; + playbackTime: number; +} + +declare var AudioProcessingEvent: { + prototype: AudioProcessingEvent; + new(): AudioProcessingEvent; +} + +interface AudioTrack { + enabled: boolean; + id: string; + kind: string; + label: string; + language: string; + sourceBuffer: SourceBuffer; +} + +declare var AudioTrack: { + prototype: AudioTrack; + new(): AudioTrack; +} + +interface AudioTrackList extends EventTarget { + length: number; + onaddtrack: (ev: TrackEvent) => any; + onchange: (ev: Event) => any; + onremovetrack: (ev: TrackEvent) => any; + getTrackById(id: string): AudioTrack; + item(index: number): AudioTrack; + addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "removetrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + [index: number]: AudioTrack; +} + +declare var AudioTrackList: { + prototype: AudioTrackList; + new(): AudioTrackList; +} + +interface BarProp { + visible: boolean; +} + +declare var BarProp: { + prototype: BarProp; + new(): BarProp; +} + +interface BeforeUnloadEvent extends Event { + returnValue: any; +} + +declare var BeforeUnloadEvent: { + prototype: BeforeUnloadEvent; + new(): BeforeUnloadEvent; +} + +interface BiquadFilterNode extends AudioNode { + Q: AudioParam; + detune: AudioParam; + frequency: AudioParam; + gain: AudioParam; + type: string; + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; +} + +declare var BiquadFilterNode: { + prototype: BiquadFilterNode; + new(): BiquadFilterNode; +} + +interface Blob { + size: number; + type: string; + msClose(): void; + msDetachStream(): any; + slice(start?: number, end?: number, contentType?: string): Blob; +} + +declare var Blob: { + prototype: Blob; + new (blobParts?: any[], options?: BlobPropertyBag): Blob; +} + +interface CDATASection extends Text { +} + +declare var CDATASection: { + prototype: CDATASection; + new(): CDATASection; +} + +interface CSS { + supports(property: string, value?: string): boolean; +} +declare var CSS: CSS; + +interface CSSConditionRule extends CSSGroupingRule { + conditionText: string; +} + +declare var CSSConditionRule: { + prototype: CSSConditionRule; + new(): CSSConditionRule; +} + +interface CSSFontFaceRule extends CSSRule { + style: CSSStyleDeclaration; +} + +declare var CSSFontFaceRule: { + prototype: CSSFontFaceRule; + new(): CSSFontFaceRule; +} + +interface CSSGroupingRule extends CSSRule { + cssRules: CSSRuleList; + deleteRule(index?: number): void; + insertRule(rule: string, index?: number): number; +} + +declare var CSSGroupingRule: { + prototype: CSSGroupingRule; + new(): CSSGroupingRule; +} + +interface CSSImportRule extends CSSRule { + href: string; + media: MediaList; + styleSheet: CSSStyleSheet; +} + +declare var CSSImportRule: { + prototype: CSSImportRule; + new(): CSSImportRule; +} + +interface CSSKeyframeRule extends CSSRule { + keyText: string; + style: CSSStyleDeclaration; +} + +declare var CSSKeyframeRule: { + prototype: CSSKeyframeRule; + new(): CSSKeyframeRule; +} + +interface CSSKeyframesRule extends CSSRule { + cssRules: CSSRuleList; + name: string; + appendRule(rule: string): void; + deleteRule(rule: string): void; + findRule(rule: string): CSSKeyframeRule; +} + +declare var CSSKeyframesRule: { + prototype: CSSKeyframesRule; + new(): CSSKeyframesRule; +} + +interface CSSMediaRule extends CSSConditionRule { + media: MediaList; +} + +declare var CSSMediaRule: { + prototype: CSSMediaRule; + new(): CSSMediaRule; +} + +interface CSSNamespaceRule extends CSSRule { + namespaceURI: string; + prefix: string; +} + +declare var CSSNamespaceRule: { + prototype: CSSNamespaceRule; + new(): CSSNamespaceRule; +} + +interface CSSPageRule extends CSSRule { + pseudoClass: string; + selector: string; + selectorText: string; + style: CSSStyleDeclaration; +} + +declare var CSSPageRule: { + prototype: CSSPageRule; + new(): CSSPageRule; +} + +interface CSSRule { + cssText: string; + parentRule: CSSRule; + parentStyleSheet: CSSStyleSheet; + type: number; + CHARSET_RULE: number; + FONT_FACE_RULE: number; + IMPORT_RULE: number; + KEYFRAMES_RULE: number; + KEYFRAME_RULE: number; + MEDIA_RULE: number; + NAMESPACE_RULE: number; + PAGE_RULE: number; + STYLE_RULE: number; + SUPPORTS_RULE: number; + UNKNOWN_RULE: number; + VIEWPORT_RULE: number; +} + +declare var CSSRule: { + prototype: CSSRule; + new(): CSSRule; + CHARSET_RULE: number; + FONT_FACE_RULE: number; + IMPORT_RULE: number; + KEYFRAMES_RULE: number; + KEYFRAME_RULE: number; + MEDIA_RULE: number; + NAMESPACE_RULE: number; + PAGE_RULE: number; + STYLE_RULE: number; + SUPPORTS_RULE: number; + UNKNOWN_RULE: number; + VIEWPORT_RULE: number; +} + +interface CSSRuleList { + length: number; + item(index: number): CSSRule; + [index: number]: CSSRule; +} + +declare var CSSRuleList: { + prototype: CSSRuleList; + new(): CSSRuleList; +} + +interface CSSStyleDeclaration { + alignContent: string; + alignItems: string; + alignSelf: string; + alignmentBaseline: string; + animation: string; + animationDelay: string; + animationDirection: string; + animationDuration: string; + animationFillMode: string; + animationIterationCount: string; + animationName: string; + animationPlayState: string; + animationTimingFunction: string; + backfaceVisibility: string; + background: string; + backgroundAttachment: string; + backgroundClip: string; + backgroundColor: string; + backgroundImage: string; + backgroundOrigin: string; + backgroundPosition: string; + backgroundPositionX: string; + backgroundPositionY: string; + backgroundRepeat: string; + backgroundSize: string; + baselineShift: string; + border: string; + borderBottom: string; + borderBottomColor: string; + borderBottomLeftRadius: string; + borderBottomRightRadius: string; + borderBottomStyle: string; + borderBottomWidth: string; + borderCollapse: string; + borderColor: string; + borderImage: string; + borderImageOutset: string; + borderImageRepeat: string; + borderImageSlice: string; + borderImageSource: string; + borderImageWidth: string; + borderLeft: string; + borderLeftColor: string; + borderLeftStyle: string; + borderLeftWidth: string; + borderRadius: string; + borderRight: string; + borderRightColor: string; + borderRightStyle: string; + borderRightWidth: string; + borderSpacing: string; + borderStyle: string; + borderTop: string; + borderTopColor: string; + borderTopLeftRadius: string; + borderTopRightRadius: string; + borderTopStyle: string; + borderTopWidth: string; + borderWidth: string; + bottom: string; + boxShadow: string; + boxSizing: string; + breakAfter: string; + breakBefore: string; + breakInside: string; + captionSide: string; + clear: string; + clip: string; + clipPath: string; + clipRule: string; + color: string; + colorInterpolationFilters: string; + columnCount: any; + columnFill: string; + columnGap: any; + columnRule: string; + columnRuleColor: any; + columnRuleStyle: string; + columnRuleWidth: any; + columnSpan: string; + columnWidth: any; + columns: string; + content: string; + counterIncrement: string; + counterReset: string; + cssFloat: string; + cssText: string; + cursor: string; + direction: string; + display: string; + dominantBaseline: string; + emptyCells: string; + enableBackground: string; + fill: string; + fillOpacity: string; + fillRule: string; + filter: string; + flex: string; + flexBasis: string; + flexDirection: string; + flexFlow: string; + flexGrow: string; + flexShrink: string; + flexWrap: string; + floodColor: string; + floodOpacity: string; + font: string; + fontFamily: string; + fontFeatureSettings: string; + fontSize: string; + fontSizeAdjust: string; + fontStretch: string; + fontStyle: string; + fontVariant: string; + fontWeight: string; + glyphOrientationHorizontal: string; + glyphOrientationVertical: string; + height: string; + imeMode: string; + justifyContent: string; + kerning: string; + left: string; + length: number; + letterSpacing: string; + lightingColor: string; + lineHeight: string; + listStyle: string; + listStyleImage: string; + listStylePosition: string; + listStyleType: string; + margin: string; + marginBottom: string; + marginLeft: string; + marginRight: string; + marginTop: string; + marker: string; + markerEnd: string; + markerMid: string; + markerStart: string; + mask: string; + maxHeight: string; + maxWidth: string; + minHeight: string; + minWidth: string; + msContentZoomChaining: string; + msContentZoomLimit: string; + msContentZoomLimitMax: any; + msContentZoomLimitMin: any; + msContentZoomSnap: string; + msContentZoomSnapPoints: string; + msContentZoomSnapType: string; + msContentZooming: string; + msFlowFrom: string; + msFlowInto: string; + msFontFeatureSettings: string; + msGridColumn: any; + msGridColumnAlign: string; + msGridColumnSpan: any; + msGridColumns: string; + msGridRow: any; + msGridRowAlign: string; + msGridRowSpan: any; + msGridRows: string; + msHighContrastAdjust: string; + msHyphenateLimitChars: string; + msHyphenateLimitLines: any; + msHyphenateLimitZone: any; + msHyphens: string; + msImeAlign: string; + msOverflowStyle: string; + msScrollChaining: string; + msScrollLimit: string; + msScrollLimitXMax: any; + msScrollLimitXMin: any; + msScrollLimitYMax: any; + msScrollLimitYMin: any; + msScrollRails: string; + msScrollSnapPointsX: string; + msScrollSnapPointsY: string; + msScrollSnapType: string; + msScrollSnapX: string; + msScrollSnapY: string; + msScrollTranslation: string; + msTextCombineHorizontal: string; + msTextSizeAdjust: any; + msTouchAction: string; + msTouchSelect: string; + msUserSelect: string; + msWrapFlow: string; + msWrapMargin: any; + msWrapThrough: string; + opacity: string; + order: string; + orphans: string; + outline: string; + outlineColor: string; + outlineStyle: string; + outlineWidth: string; + overflow: string; + overflowX: string; + overflowY: string; + padding: string; + paddingBottom: string; + paddingLeft: string; + paddingRight: string; + paddingTop: string; + pageBreakAfter: string; + pageBreakBefore: string; + pageBreakInside: string; + parentRule: CSSRule; + perspective: string; + perspectiveOrigin: string; + pointerEvents: string; + position: string; + quotes: string; + right: string; + rubyAlign: string; + rubyOverhang: string; + rubyPosition: string; + stopColor: string; + stopOpacity: string; + stroke: string; + strokeDasharray: string; + strokeDashoffset: string; + strokeLinecap: string; + strokeLinejoin: string; + strokeMiterlimit: string; + strokeOpacity: string; + strokeWidth: string; + tableLayout: string; + textAlign: string; + textAlignLast: string; + textAnchor: string; + textDecoration: string; + textFillColor: string; + textIndent: string; + textJustify: string; + textKashida: string; + textKashidaSpace: string; + textOverflow: string; + textShadow: string; + textTransform: string; + textUnderlinePosition: string; + top: string; + touchAction: string; + transform: string; + transformOrigin: string; + transformStyle: string; + transition: string; + transitionDelay: string; + transitionDuration: string; + transitionProperty: string; + transitionTimingFunction: string; + unicodeBidi: string; + verticalAlign: string; + visibility: string; + webkitAlignContent: string; + webkitAlignItems: string; + webkitAlignSelf: string; + webkitAnimation: string; + webkitAnimationDelay: string; + webkitAnimationDirection: string; + webkitAnimationDuration: string; + webkitAnimationFillMode: string; + webkitAnimationIterationCount: string; + webkitAnimationName: string; + webkitAnimationPlayState: string; + webkitAnimationTimingFunction: string; + webkitAppearance: string; + webkitBackfaceVisibility: string; + webkitBackground: string; + webkitBackgroundAttachment: string; + webkitBackgroundClip: string; + webkitBackgroundColor: string; + webkitBackgroundImage: string; + webkitBackgroundOrigin: string; + webkitBackgroundPosition: string; + webkitBackgroundPositionX: string; + webkitBackgroundPositionY: string; + webkitBackgroundRepeat: string; + webkitBackgroundSize: string; + webkitBorderBottomLeftRadius: string; + webkitBorderBottomRightRadius: string; + webkitBorderImage: string; + webkitBorderImageOutset: string; + webkitBorderImageRepeat: string; + webkitBorderImageSlice: string; + webkitBorderImageSource: string; + webkitBorderImageWidth: string; + webkitBorderRadius: string; + webkitBorderTopLeftRadius: string; + webkitBorderTopRightRadius: string; + webkitBoxAlign: string; + webkitBoxDirection: string; + webkitBoxFlex: string; + webkitBoxOrdinalGroup: string; + webkitBoxOrient: string; + webkitBoxPack: string; + webkitBoxSizing: string; + webkitColumnBreakAfter: string; + webkitColumnBreakBefore: string; + webkitColumnBreakInside: string; + webkitColumnCount: any; + webkitColumnGap: any; + webkitColumnRule: string; + webkitColumnRuleColor: any; + webkitColumnRuleStyle: string; + webkitColumnRuleWidth: any; + webkitColumnSpan: string; + webkitColumnWidth: any; + webkitColumns: string; + webkitFilter: string; + webkitFlex: string; + webkitFlexBasis: string; + webkitFlexDirection: string; + webkitFlexFlow: string; + webkitFlexGrow: string; + webkitFlexShrink: string; + webkitFlexWrap: string; + webkitJustifyContent: string; + webkitOrder: string; + webkitPerspective: string; + webkitPerspectiveOrigin: string; + webkitTapHighlightColor: string; + webkitTextFillColor: string; + webkitTextSizeAdjust: any; + webkitTransform: string; + webkitTransformOrigin: string; + webkitTransformStyle: string; + webkitTransition: string; + webkitTransitionDelay: string; + webkitTransitionDuration: string; + webkitTransitionProperty: string; + webkitTransitionTimingFunction: string; + webkitUserSelect: string; + webkitWritingMode: string; + whiteSpace: string; + widows: string; + width: string; + wordBreak: string; + wordSpacing: string; + wordWrap: string; + writingMode: string; + zIndex: string; + zoom: string; + getPropertyPriority(propertyName: string): string; + getPropertyValue(propertyName: string): string; + item(index: number): string; + removeProperty(propertyName: string): string; + setProperty(propertyName: string, value: string, priority?: string): void; + [index: number]: string; +} + +declare var CSSStyleDeclaration: { + prototype: CSSStyleDeclaration; + new(): CSSStyleDeclaration; +} + +interface CSSStyleRule extends CSSRule { + readOnly: boolean; + selectorText: string; + style: CSSStyleDeclaration; +} + +declare var CSSStyleRule: { + prototype: CSSStyleRule; + new(): CSSStyleRule; +} + +interface CSSStyleSheet extends StyleSheet { + cssRules: CSSRuleList; + cssText: string; + href: string; + id: string; + imports: StyleSheetList; + isAlternate: boolean; + isPrefAlternate: boolean; + ownerRule: CSSRule; + owningElement: Element; + pages: StyleSheetPageList; + readOnly: boolean; + rules: CSSRuleList; + addImport(bstrURL: string, lIndex?: number): number; + addPageRule(bstrSelector: string, bstrStyle: string, lIndex?: number): number; + addRule(bstrSelector: string, bstrStyle?: string, lIndex?: number): number; + deleteRule(index?: number): void; + insertRule(rule: string, index?: number): number; + removeImport(lIndex: number): void; + removeRule(lIndex: number): void; +} + +declare var CSSStyleSheet: { + prototype: CSSStyleSheet; + new(): CSSStyleSheet; +} + +interface CSSSupportsRule extends CSSConditionRule { +} + +declare var CSSSupportsRule: { + prototype: CSSSupportsRule; + new(): CSSSupportsRule; +} + +interface CanvasGradient { + addColorStop(offset: number, color: string): void; +} + +declare var CanvasGradient: { + prototype: CanvasGradient; + new(): CanvasGradient; +} + +interface CanvasPattern { +} + +declare var CanvasPattern: { + prototype: CanvasPattern; + new(): CanvasPattern; +} + +interface CanvasRenderingContext2D { + canvas: HTMLCanvasElement; + fillStyle: string | CanvasGradient | CanvasPattern; + font: string; + globalAlpha: number; + globalCompositeOperation: string; + lineCap: string; + lineDashOffset: number; + lineJoin: string; + lineWidth: number; + miterLimit: number; + msFillRule: string; + msImageSmoothingEnabled: boolean; + shadowBlur: number; + shadowColor: string; + shadowOffsetX: number; + shadowOffsetY: number; + strokeStyle: string | CanvasGradient | CanvasPattern; + textAlign: string; + textBaseline: string; + arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; + arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; + beginPath(): void; + bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; + clearRect(x: number, y: number, w: number, h: number): void; + clip(fillRule?: string): void; + closePath(): void; + createImageData(imageDataOrSw: number | ImageData, sh?: number): ImageData; + createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; + createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern; + createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; + fill(fillRule?: string): void; + fillRect(x: number, y: number, w: number, h: number): void; + fillText(text: string, x: number, y: number, maxWidth?: number): void; + getImageData(sx: number, sy: number, sw: number, sh: number): ImageData; + getLineDash(): number[]; + isPointInPath(x: number, y: number, fillRule?: string): boolean; + lineTo(x: number, y: number): void; + measureText(text: string): TextMetrics; + moveTo(x: number, y: number): void; + putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number): void; + quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; + rect(x: number, y: number, w: number, h: number): void; + restore(): void; + rotate(angle: number): void; + save(): void; + scale(x: number, y: number): void; + setLineDash(segments: number[]): void; + setTransform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; + stroke(): void; + strokeRect(x: number, y: number, w: number, h: number): void; + strokeText(text: string, x: number, y: number, maxWidth?: number): void; + transform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; + translate(x: number, y: number): void; +} + +declare var CanvasRenderingContext2D: { + prototype: CanvasRenderingContext2D; + new(): CanvasRenderingContext2D; +} + +interface ChannelMergerNode extends AudioNode { +} + +declare var ChannelMergerNode: { + prototype: ChannelMergerNode; + new(): ChannelMergerNode; +} + +interface ChannelSplitterNode extends AudioNode { +} + +declare var ChannelSplitterNode: { + prototype: ChannelSplitterNode; + new(): ChannelSplitterNode; +} + +interface CharacterData extends Node, ChildNode { + data: string; + length: number; + appendData(arg: string): void; + deleteData(offset: number, count: number): void; + insertData(offset: number, arg: string): void; + replaceData(offset: number, count: number, arg: string): void; + substringData(offset: number, count: number): string; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var CharacterData: { + prototype: CharacterData; + new(): CharacterData; +} + +interface ClientRect { + bottom: number; + height: number; + left: number; + right: number; + top: number; + width: number; +} + +declare var ClientRect: { + prototype: ClientRect; + new(): ClientRect; +} + +interface ClientRectList { + length: number; + item(index: number): ClientRect; + [index: number]: ClientRect; +} + +declare var ClientRectList: { + prototype: ClientRectList; + new(): ClientRectList; +} + +interface ClipboardEvent extends Event { + clipboardData: DataTransfer; +} + +declare var ClipboardEvent: { + prototype: ClipboardEvent; + new(type: string, eventInitDict?: ClipboardEventInit): ClipboardEvent; +} + +interface CloseEvent extends Event { + code: number; + reason: string; + wasClean: boolean; + initCloseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, wasCleanArg: boolean, codeArg: number, reasonArg: string): void; +} + +declare var CloseEvent: { + prototype: CloseEvent; + new(): CloseEvent; +} + +interface CommandEvent extends Event { + commandName: string; + detail: string; +} + +declare var CommandEvent: { + prototype: CommandEvent; + new(type: string, eventInitDict?: CommandEventInit): CommandEvent; +} + +interface Comment extends CharacterData { + text: string; +} + +declare var Comment: { + prototype: Comment; + new(): Comment; +} + +interface CompositionEvent extends UIEvent { + data: string; + locale: string; + initCompositionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, locale: string): void; +} + +declare var CompositionEvent: { + prototype: CompositionEvent; + new(typeArg: string, eventInitDict?: CompositionEventInit): CompositionEvent; +} + +interface Console { + assert(test?: boolean, message?: string, ...optionalParams: any[]): void; + clear(): void; + count(countTitle?: string): void; + debug(message?: string, ...optionalParams: any[]): void; + dir(value?: any, ...optionalParams: any[]): void; + dirxml(value: any): void; + error(message?: any, ...optionalParams: any[]): void; + group(groupTitle?: string): void; + groupCollapsed(groupTitle?: string): void; + groupEnd(): void; + info(message?: any, ...optionalParams: any[]): void; + log(message?: any, ...optionalParams: any[]): void; + msIsIndependentlyComposed(element: Element): boolean; + profile(reportName?: string): void; + profileEnd(): void; + select(element: Element): void; + time(timerName?: string): void; + timeEnd(timerName?: string): void; + trace(message?: any, ...optionalParams: any[]): void; + warn(message?: any, ...optionalParams: any[]): void; +} + +declare var Console: { + prototype: Console; + new(): Console; +} + +interface ConvolverNode extends AudioNode { + buffer: AudioBuffer; + normalize: boolean; +} + +declare var ConvolverNode: { + prototype: ConvolverNode; + new(): ConvolverNode; +} + +interface Coordinates { + accuracy: number; + altitude: number; + altitudeAccuracy: number; + heading: number; + latitude: number; + longitude: number; + speed: number; +} + +declare var Coordinates: { + prototype: Coordinates; + new(): Coordinates; +} + +interface Crypto extends Object, RandomSource { + subtle: SubtleCrypto; +} + +declare var Crypto: { + prototype: Crypto; + new(): Crypto; +} + +interface CryptoKey { + algorithm: KeyAlgorithm; + extractable: boolean; + type: string; + usages: string[]; +} + +declare var CryptoKey: { + prototype: CryptoKey; + new(): CryptoKey; +} + +interface CryptoKeyPair { + privateKey: CryptoKey; + publicKey: CryptoKey; +} + +declare var CryptoKeyPair: { + prototype: CryptoKeyPair; + new(): CryptoKeyPair; +} + +interface CustomEvent extends Event { + detail: any; + initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: any): void; +} + +declare var CustomEvent: { + prototype: CustomEvent; + new(typeArg: string, eventInitDict?: CustomEventInit): CustomEvent; +} + +interface DOMError { + name: string; + toString(): string; +} + +declare var DOMError: { + prototype: DOMError; + new(): DOMError; +} + +interface DOMException { + code: number; + message: string; + name: string; + toString(): string; + ABORT_ERR: number; + DATA_CLONE_ERR: number; + DOMSTRING_SIZE_ERR: number; + HIERARCHY_REQUEST_ERR: number; + INDEX_SIZE_ERR: number; + INUSE_ATTRIBUTE_ERR: number; + INVALID_ACCESS_ERR: number; + INVALID_CHARACTER_ERR: number; + INVALID_MODIFICATION_ERR: number; + INVALID_NODE_TYPE_ERR: number; + INVALID_STATE_ERR: number; + NAMESPACE_ERR: number; + NETWORK_ERR: number; + NOT_FOUND_ERR: number; + NOT_SUPPORTED_ERR: number; + NO_DATA_ALLOWED_ERR: number; + NO_MODIFICATION_ALLOWED_ERR: number; + PARSE_ERR: number; + QUOTA_EXCEEDED_ERR: number; + SECURITY_ERR: number; + SERIALIZE_ERR: number; + SYNTAX_ERR: number; + TIMEOUT_ERR: number; + TYPE_MISMATCH_ERR: number; + URL_MISMATCH_ERR: number; + VALIDATION_ERR: number; + WRONG_DOCUMENT_ERR: number; +} + +declare var DOMException: { + prototype: DOMException; + new(): DOMException; + ABORT_ERR: number; + DATA_CLONE_ERR: number; + DOMSTRING_SIZE_ERR: number; + HIERARCHY_REQUEST_ERR: number; + INDEX_SIZE_ERR: number; + INUSE_ATTRIBUTE_ERR: number; + INVALID_ACCESS_ERR: number; + INVALID_CHARACTER_ERR: number; + INVALID_MODIFICATION_ERR: number; + INVALID_NODE_TYPE_ERR: number; + INVALID_STATE_ERR: number; + NAMESPACE_ERR: number; + NETWORK_ERR: number; + NOT_FOUND_ERR: number; + NOT_SUPPORTED_ERR: number; + NO_DATA_ALLOWED_ERR: number; + NO_MODIFICATION_ALLOWED_ERR: number; + PARSE_ERR: number; + QUOTA_EXCEEDED_ERR: number; + SECURITY_ERR: number; + SERIALIZE_ERR: number; + SYNTAX_ERR: number; + TIMEOUT_ERR: number; + TYPE_MISMATCH_ERR: number; + URL_MISMATCH_ERR: number; + VALIDATION_ERR: number; + WRONG_DOCUMENT_ERR: number; +} + +interface DOMImplementation { + createDocument(namespaceURI: string, qualifiedName: string, doctype: DocumentType): Document; + createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; + createHTMLDocument(title: string): Document; + hasFeature(feature: string, version: string): boolean; +} + +declare var DOMImplementation: { + prototype: DOMImplementation; + new(): DOMImplementation; +} + +interface DOMParser { + parseFromString(source: string, mimeType: string): Document; +} + +declare var DOMParser: { + prototype: DOMParser; + new(): DOMParser; +} + +interface DOMSettableTokenList extends DOMTokenList { + value: string; +} + +declare var DOMSettableTokenList: { + prototype: DOMSettableTokenList; + new(): DOMSettableTokenList; +} + +interface DOMStringList { + length: number; + contains(str: string): boolean; + item(index: number): string; + [index: number]: string; +} + +declare var DOMStringList: { + prototype: DOMStringList; + new(): DOMStringList; +} + +interface DOMStringMap { + [name: string]: string; +} + +declare var DOMStringMap: { + prototype: DOMStringMap; + new(): DOMStringMap; +} + +interface DOMTokenList { + length: number; + add(...token: string[]): void; + contains(token: string): boolean; + item(index: number): string; + remove(...token: string[]): void; + toString(): string; + toggle(token: string, force?: boolean): boolean; + [index: number]: string; +} + +declare var DOMTokenList: { + prototype: DOMTokenList; + new(): DOMTokenList; +} + +interface DataCue extends TextTrackCue { + data: ArrayBuffer; +} + +declare var DataCue: { + prototype: DataCue; + new(): DataCue; +} + +interface DataTransfer { + dropEffect: string; + effectAllowed: string; + files: FileList; + items: DataTransferItemList; + types: DOMStringList; + clearData(format?: string): boolean; + getData(format: string): string; + setData(format: string, data: string): boolean; +} + +declare var DataTransfer: { + prototype: DataTransfer; + new(): DataTransfer; +} + +interface DataTransferItem { + kind: string; + type: string; + getAsFile(): File; + getAsString(_callback: FunctionStringCallback): void; +} + +declare var DataTransferItem: { + prototype: DataTransferItem; + new(): DataTransferItem; +} + +interface DataTransferItemList { + length: number; + add(data: File): DataTransferItem; + clear(): void; + item(index: number): DataTransferItem; + remove(index: number): void; + [index: number]: DataTransferItem; +} + +declare var DataTransferItemList: { + prototype: DataTransferItemList; + new(): DataTransferItemList; +} + +interface DeferredPermissionRequest { + id: number; + type: string; + uri: string; + allow(): void; + deny(): void; +} + +declare var DeferredPermissionRequest: { + prototype: DeferredPermissionRequest; + new(): DeferredPermissionRequest; +} + +interface DelayNode extends AudioNode { + delayTime: AudioParam; +} + +declare var DelayNode: { + prototype: DelayNode; + new(): DelayNode; +} + +interface DeviceAcceleration { + x: number; + y: number; + z: number; +} + +declare var DeviceAcceleration: { + prototype: DeviceAcceleration; + new(): DeviceAcceleration; +} + +interface DeviceMotionEvent extends Event { + acceleration: DeviceAcceleration; + accelerationIncludingGravity: DeviceAcceleration; + interval: number; + rotationRate: DeviceRotationRate; + initDeviceMotionEvent(type: string, bubbles: boolean, cancelable: boolean, acceleration: DeviceAccelerationDict, accelerationIncludingGravity: DeviceAccelerationDict, rotationRate: DeviceRotationRateDict, interval: number): void; +} + +declare var DeviceMotionEvent: { + prototype: DeviceMotionEvent; + new(): DeviceMotionEvent; +} + +interface DeviceOrientationEvent extends Event { + absolute: boolean; + alpha: number; + beta: number; + gamma: number; + initDeviceOrientationEvent(type: string, bubbles: boolean, cancelable: boolean, alpha: number, beta: number, gamma: number, absolute: boolean): void; +} + +declare var DeviceOrientationEvent: { + prototype: DeviceOrientationEvent; + new(): DeviceOrientationEvent; +} + +interface DeviceRotationRate { + alpha: number; + beta: number; + gamma: number; +} + +declare var DeviceRotationRate: { + prototype: DeviceRotationRate; + new(): DeviceRotationRate; +} + +interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEvent { + /** + * Sets or gets the URL for the current document. + */ + URL: string; + /** + * Gets the URL for the document, stripped of any character encoding. + */ + URLUnencoded: string; + /** + * Gets the object that has the focus when the parent document has focus. + */ + activeElement: Element; + /** + * Sets or gets the color of all active links in the document. + */ + alinkColor: string; + /** + * Returns a reference to the collection of elements contained by the object. + */ + all: HTMLCollection; + /** + * Retrieves a collection of all a objects that have a name and/or id property. Objects in this collection are in HTML source order. + */ + anchors: HTMLCollection; + /** + * Retrieves a collection of all applet objects in the document. + */ + applets: HTMLCollection; + /** + * Deprecated. Sets or retrieves a value that indicates the background color behind the object. + */ + bgColor: string; + /** + * Specifies the beginning and end of the document body. + */ + body: HTMLElement; + characterSet: string; + /** + * Gets or sets the character set used to encode the object. + */ + charset: string; + /** + * Gets a value that indicates whether standards-compliant mode is switched on for the object. + */ + compatMode: string; + cookie: string; + /** + * Gets the default character set from the current regional language settings. + */ + defaultCharset: string; + defaultView: Window; + /** + * Sets or gets a value that indicates whether the document can be edited. + */ + designMode: string; + /** + * Sets or retrieves a value that indicates the reading order of the object. + */ + dir: string; + /** + * Gets an object representing the document type declaration associated with the current document. + */ + doctype: DocumentType; + /** + * Gets a reference to the root node of the document. + */ + documentElement: HTMLElement; + /** + * Sets or gets the security domain of the document. + */ + domain: string; + /** + * Retrieves a collection of all embed objects in the document. + */ + embeds: HTMLCollection; + /** + * Sets or gets the foreground (text) color of the document. + */ + fgColor: string; + /** + * Retrieves a collection, in source order, of all form objects in the document. + */ + forms: HTMLCollection; + fullscreenElement: Element; + fullscreenEnabled: boolean; + head: HTMLHeadElement; + hidden: boolean; + /** + * Retrieves a collection, in source order, of img objects in the document. + */ + images: HTMLCollection; + /** + * Gets the implementation object of the current document. + */ + implementation: DOMImplementation; + /** + * Returns the character encoding used to create the webpage that is loaded into the document object. + */ + inputEncoding: string; + /** + * Gets the date that the page was last modified, if the page supplies one. + */ + lastModified: string; + /** + * Sets or gets the color of the document links. + */ + linkColor: string; + /** + * Retrieves a collection of all a objects that specify the href property and all area objects in the document. + */ + links: HTMLCollection; + /** + * Contains information about the current URL. + */ + location: Location; + media: string; + msCSSOMElementFloatMetrics: boolean; + msCapsLockWarningOff: boolean; + msHidden: boolean; + msVisibilityState: string; + /** + * Fires when the user aborts the download. + * @param ev The event. + */ + onabort: (ev: Event) => any; + /** + * Fires when the object is set as the active element. + * @param ev The event. + */ + onactivate: (ev: UIEvent) => any; + /** + * Fires immediately before the object is set as the active element. + * @param ev The event. + */ + onbeforeactivate: (ev: UIEvent) => any; + /** + * Fires immediately before the activeElement is changed from the current object to another object in the parent document. + * @param ev The event. + */ + onbeforedeactivate: (ev: UIEvent) => any; + /** + * Fires when the object loses the input focus. + * @param ev The focus event. + */ + onblur: (ev: FocusEvent) => any; + /** + * Occurs when playback is possible, but would require further buffering. + * @param ev The event. + */ + oncanplay: (ev: Event) => any; + oncanplaythrough: (ev: Event) => any; + /** + * Fires when the contents of the object or selection have changed. + * @param ev The event. + */ + onchange: (ev: Event) => any; + /** + * Fires when the user clicks the left mouse button on the object + * @param ev The mouse event. + */ + onclick: (ev: MouseEvent) => any; + /** + * Fires when the user clicks the right mouse button in the client area, opening the context menu. + * @param ev The mouse event. + */ + oncontextmenu: (ev: PointerEvent) => any; + /** + * Fires when the user double-clicks the object. + * @param ev The mouse event. + */ + ondblclick: (ev: MouseEvent) => any; + /** + * Fires when the activeElement is changed from the current object to another object in the parent document. + * @param ev The UI Event + */ + ondeactivate: (ev: UIEvent) => any; + /** + * Fires on the source object continuously during a drag operation. + * @param ev The event. + */ + ondrag: (ev: DragEvent) => any; + /** + * Fires on the source object when the user releases the mouse at the close of a drag operation. + * @param ev The event. + */ + ondragend: (ev: DragEvent) => any; + /** + * Fires on the target element when the user drags the object to a valid drop target. + * @param ev The drag event. + */ + ondragenter: (ev: DragEvent) => any; + /** + * Fires on the target object when the user moves the mouse out of a valid drop target during a drag operation. + * @param ev The drag event. + */ + ondragleave: (ev: DragEvent) => any; + /** + * Fires on the target element continuously while the user drags the object over a valid drop target. + * @param ev The event. + */ + ondragover: (ev: DragEvent) => any; + /** + * Fires on the source object when the user starts to drag a text selection or selected object. + * @param ev The event. + */ + ondragstart: (ev: DragEvent) => any; + ondrop: (ev: DragEvent) => any; + /** + * Occurs when the duration attribute is updated. + * @param ev The event. + */ + ondurationchange: (ev: Event) => any; + /** + * Occurs when the media element is reset to its initial state. + * @param ev The event. + */ + onemptied: (ev: Event) => any; + /** + * Occurs when the end of playback is reached. + * @param ev The event + */ + onended: (ev: Event) => any; + /** + * Fires when an error occurs during object loading. + * @param ev The event. + */ + onerror: (ev: Event) => any; + /** + * Fires when the object receives focus. + * @param ev The event. + */ + onfocus: (ev: FocusEvent) => any; + onfullscreenchange: (ev: Event) => any; + onfullscreenerror: (ev: Event) => any; + oninput: (ev: Event) => any; + /** + * Fires when the user presses a key. + * @param ev The keyboard event + */ + onkeydown: (ev: KeyboardEvent) => any; + /** + * Fires when the user presses an alphanumeric key. + * @param ev The event. + */ + onkeypress: (ev: KeyboardEvent) => any; + /** + * Fires when the user releases a key. + * @param ev The keyboard event + */ + onkeyup: (ev: KeyboardEvent) => any; + /** + * Fires immediately after the browser loads the object. + * @param ev The event. + */ + onload: (ev: Event) => any; + /** + * Occurs when media data is loaded at the current playback position. + * @param ev The event. + */ + onloadeddata: (ev: Event) => any; + /** + * Occurs when the duration and dimensions of the media have been determined. + * @param ev The event. + */ + onloadedmetadata: (ev: Event) => any; + /** + * Occurs when Internet Explorer begins looking for media data. + * @param ev The event. + */ + onloadstart: (ev: Event) => any; + /** + * Fires when the user clicks the object with either mouse button. + * @param ev The mouse event. + */ + onmousedown: (ev: MouseEvent) => any; + /** + * Fires when the user moves the mouse over the object. + * @param ev The mouse event. + */ + onmousemove: (ev: MouseEvent) => any; + /** + * Fires when the user moves the mouse pointer outside the boundaries of the object. + * @param ev The mouse event. + */ + onmouseout: (ev: MouseEvent) => any; + /** + * Fires when the user moves the mouse pointer into the object. + * @param ev The mouse event. + */ + onmouseover: (ev: MouseEvent) => any; + /** + * Fires when the user releases a mouse button while the mouse is over the object. + * @param ev The mouse event. + */ + onmouseup: (ev: MouseEvent) => any; + /** + * Fires when the wheel button is rotated. + * @param ev The mouse event + */ + onmousewheel: (ev: MouseWheelEvent) => any; + onmscontentzoom: (ev: UIEvent) => any; + onmsgesturechange: (ev: MSGestureEvent) => any; + onmsgesturedoubletap: (ev: MSGestureEvent) => any; + onmsgestureend: (ev: MSGestureEvent) => any; + onmsgesturehold: (ev: MSGestureEvent) => any; + onmsgesturestart: (ev: MSGestureEvent) => any; + onmsgesturetap: (ev: MSGestureEvent) => any; + onmsinertiastart: (ev: MSGestureEvent) => any; + onmsmanipulationstatechanged: (ev: MSManipulationEvent) => any; + onmspointercancel: (ev: MSPointerEvent) => any; + onmspointerdown: (ev: MSPointerEvent) => any; + onmspointerenter: (ev: MSPointerEvent) => any; + onmspointerleave: (ev: MSPointerEvent) => any; + onmspointermove: (ev: MSPointerEvent) => any; + onmspointerout: (ev: MSPointerEvent) => any; + onmspointerover: (ev: MSPointerEvent) => any; + onmspointerup: (ev: MSPointerEvent) => any; + /** + * Occurs when an item is removed from a Jump List of a webpage running in Site Mode. + * @param ev The event. + */ + onmssitemodejumplistitemremoved: (ev: MSSiteModeEvent) => any; + /** + * Occurs when a user clicks a button in a Thumbnail Toolbar of a webpage running in Site Mode. + * @param ev The event. + */ + onmsthumbnailclick: (ev: MSSiteModeEvent) => any; + /** + * Occurs when playback is paused. + * @param ev The event. + */ + onpause: (ev: Event) => any; + /** + * Occurs when the play method is requested. + * @param ev The event. + */ + onplay: (ev: Event) => any; + /** + * Occurs when the audio or video has started playing. + * @param ev The event. + */ + onplaying: (ev: Event) => any; + onpointerlockchange: (ev: Event) => any; + onpointerlockerror: (ev: Event) => any; + /** + * Occurs to indicate progress while downloading media data. + * @param ev The event. + */ + onprogress: (ev: ProgressEvent) => any; + /** + * Occurs when the playback rate is increased or decreased. + * @param ev The event. + */ + onratechange: (ev: Event) => any; + /** + * Fires when the state of the object has changed. + * @param ev The event + */ + onreadystatechange: (ev: ProgressEvent) => any; + /** + * Fires when the user resets a form. + * @param ev The event. + */ + onreset: (ev: Event) => any; + /** + * Fires when the user repositions the scroll box in the scroll bar on the object. + * @param ev The event. + */ + onscroll: (ev: UIEvent) => any; + /** + * Occurs when the seek operation ends. + * @param ev The event. + */ + onseeked: (ev: Event) => any; + /** + * Occurs when the current playback position is moved. + * @param ev The event. + */ + onseeking: (ev: Event) => any; + /** + * Fires when the current selection changes. + * @param ev The event. + */ + onselect: (ev: UIEvent) => any; + onselectstart: (ev: Event) => any; + /** + * Occurs when the download has stopped. + * @param ev The event. + */ + onstalled: (ev: Event) => any; + /** + * Fires when the user clicks the Stop button or leaves the Web page. + * @param ev The event. + */ + onstop: (ev: Event) => any; + onsubmit: (ev: Event) => any; + /** + * Occurs if the load operation has been intentionally halted. + * @param ev The event. + */ + onsuspend: (ev: Event) => any; + /** + * Occurs to indicate the current playback position. + * @param ev The event. + */ + ontimeupdate: (ev: Event) => any; + ontouchcancel: (ev: TouchEvent) => any; + ontouchend: (ev: TouchEvent) => any; + ontouchmove: (ev: TouchEvent) => any; + ontouchstart: (ev: TouchEvent) => any; + /** + * Occurs when the volume is changed, or playback is muted or unmuted. + * @param ev The event. + */ + onvolumechange: (ev: Event) => any; + /** + * Occurs when playback stops because the next frame of a video resource is not available. + * @param ev The event. + */ + onwaiting: (ev: Event) => any; + onwebkitfullscreenchange: (ev: Event) => any; + onwebkitfullscreenerror: (ev: Event) => any; + plugins: HTMLCollection; + pointerLockElement: Element; + /** + * Retrieves a value that indicates the current state of the object. + */ + readyState: string; + /** + * Gets the URL of the location that referred the user to the current page. + */ + referrer: string; + /** + * Gets the root svg element in the document hierarchy. + */ + rootElement: SVGSVGElement; + /** + * Retrieves a collection of all script objects in the document. + */ + scripts: HTMLCollection; + security: string; + /** + * Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. + */ + styleSheets: StyleSheetList; + /** + * Contains the title of the document. + */ + title: string; + visibilityState: string; + /** + * Sets or gets the color of the links that the user has visited. + */ + vlinkColor: string; + webkitCurrentFullScreenElement: Element; + webkitFullscreenElement: Element; + webkitFullscreenEnabled: boolean; + webkitIsFullScreen: boolean; + xmlEncoding: string; + xmlStandalone: boolean; + /** + * Gets or sets the version attribute specified in the declaration of an XML document. + */ + xmlVersion: string; + currentScript: HTMLScriptElement; + adoptNode(source: Node): Node; + captureEvents(): void; + clear(): void; + /** + * Closes an output stream and forces the sent data to display. + */ + close(): void; + /** + * Creates an attribute object with a specified name. + * @param name String that sets the attribute object's name. + */ + createAttribute(name: string): Attr; + createAttributeNS(namespaceURI: string, qualifiedName: string): Attr; + createCDATASection(data: string): CDATASection; + /** + * Creates a comment object with the specified data. + * @param data Sets the comment object's data. + */ + createComment(data: string): Comment; + /** + * Creates a new document. + */ + createDocumentFragment(): DocumentFragment; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "a"): HTMLAnchorElement; + createElement(tagName: "abbr"): HTMLPhraseElement; + createElement(tagName: "acronym"): HTMLPhraseElement; + createElement(tagName: "address"): HTMLBlockElement; + createElement(tagName: "applet"): HTMLAppletElement; + createElement(tagName: "area"): HTMLAreaElement; + createElement(tagName: "audio"): HTMLAudioElement; + createElement(tagName: "b"): HTMLPhraseElement; + createElement(tagName: "base"): HTMLBaseElement; + createElement(tagName: "basefont"): HTMLBaseFontElement; + createElement(tagName: "bdo"): HTMLPhraseElement; + createElement(tagName: "big"): HTMLPhraseElement; + createElement(tagName: "blockquote"): HTMLBlockElement; + createElement(tagName: "body"): HTMLBodyElement; + createElement(tagName: "br"): HTMLBRElement; + createElement(tagName: "button"): HTMLButtonElement; + createElement(tagName: "canvas"): HTMLCanvasElement; + createElement(tagName: "caption"): HTMLTableCaptionElement; + createElement(tagName: "center"): HTMLBlockElement; + createElement(tagName: "cite"): HTMLPhraseElement; + createElement(tagName: "code"): HTMLPhraseElement; + createElement(tagName: "col"): HTMLTableColElement; + createElement(tagName: "colgroup"): HTMLTableColElement; + createElement(tagName: "datalist"): HTMLDataListElement; + createElement(tagName: "dd"): HTMLDDElement; + createElement(tagName: "del"): HTMLModElement; + createElement(tagName: "dfn"): HTMLPhraseElement; + createElement(tagName: "dir"): HTMLDirectoryElement; + createElement(tagName: "div"): HTMLDivElement; + createElement(tagName: "dl"): HTMLDListElement; + createElement(tagName: "dt"): HTMLDTElement; + createElement(tagName: "em"): HTMLPhraseElement; + createElement(tagName: "embed"): HTMLEmbedElement; + createElement(tagName: "fieldset"): HTMLFieldSetElement; + createElement(tagName: "font"): HTMLFontElement; + createElement(tagName: "form"): HTMLFormElement; + createElement(tagName: "frame"): HTMLFrameElement; + createElement(tagName: "frameset"): HTMLFrameSetElement; + createElement(tagName: "h1"): HTMLHeadingElement; + createElement(tagName: "h2"): HTMLHeadingElement; + createElement(tagName: "h3"): HTMLHeadingElement; + createElement(tagName: "h4"): HTMLHeadingElement; + createElement(tagName: "h5"): HTMLHeadingElement; + createElement(tagName: "h6"): HTMLHeadingElement; + createElement(tagName: "head"): HTMLHeadElement; + createElement(tagName: "hr"): HTMLHRElement; + createElement(tagName: "html"): HTMLHtmlElement; + createElement(tagName: "i"): HTMLPhraseElement; + createElement(tagName: "iframe"): HTMLIFrameElement; + createElement(tagName: "img"): HTMLImageElement; + createElement(tagName: "input"): HTMLInputElement; + createElement(tagName: "ins"): HTMLModElement; + createElement(tagName: "isindex"): HTMLIsIndexElement; + createElement(tagName: "kbd"): HTMLPhraseElement; + createElement(tagName: "keygen"): HTMLBlockElement; + createElement(tagName: "label"): HTMLLabelElement; + createElement(tagName: "legend"): HTMLLegendElement; + createElement(tagName: "li"): HTMLLIElement; + createElement(tagName: "link"): HTMLLinkElement; + createElement(tagName: "listing"): HTMLBlockElement; + createElement(tagName: "map"): HTMLMapElement; + createElement(tagName: "marquee"): HTMLMarqueeElement; + createElement(tagName: "menu"): HTMLMenuElement; + createElement(tagName: "meta"): HTMLMetaElement; + createElement(tagName: "nextid"): HTMLNextIdElement; + createElement(tagName: "nobr"): HTMLPhraseElement; + createElement(tagName: "object"): HTMLObjectElement; + createElement(tagName: "ol"): HTMLOListElement; + createElement(tagName: "optgroup"): HTMLOptGroupElement; + createElement(tagName: "option"): HTMLOptionElement; + createElement(tagName: "p"): HTMLParagraphElement; + createElement(tagName: "param"): HTMLParamElement; + createElement(tagName: "plaintext"): HTMLBlockElement; + createElement(tagName: "pre"): HTMLPreElement; + createElement(tagName: "progress"): HTMLProgressElement; + createElement(tagName: "q"): HTMLQuoteElement; + createElement(tagName: "rt"): HTMLPhraseElement; + createElement(tagName: "ruby"): HTMLPhraseElement; + createElement(tagName: "s"): HTMLPhraseElement; + createElement(tagName: "samp"): HTMLPhraseElement; + createElement(tagName: "script"): HTMLScriptElement; + createElement(tagName: "select"): HTMLSelectElement; + createElement(tagName: "small"): HTMLPhraseElement; + createElement(tagName: "source"): HTMLSourceElement; + createElement(tagName: "span"): HTMLSpanElement; + createElement(tagName: "strike"): HTMLPhraseElement; + createElement(tagName: "strong"): HTMLPhraseElement; + createElement(tagName: "style"): HTMLStyleElement; + createElement(tagName: "sub"): HTMLPhraseElement; + createElement(tagName: "sup"): HTMLPhraseElement; + createElement(tagName: "table"): HTMLTableElement; + createElement(tagName: "tbody"): HTMLTableSectionElement; + createElement(tagName: "td"): HTMLTableDataCellElement; + createElement(tagName: "textarea"): HTMLTextAreaElement; + createElement(tagName: "tfoot"): HTMLTableSectionElement; + createElement(tagName: "th"): HTMLTableHeaderCellElement; + createElement(tagName: "thead"): HTMLTableSectionElement; + createElement(tagName: "title"): HTMLTitleElement; + createElement(tagName: "tr"): HTMLTableRowElement; + createElement(tagName: "track"): HTMLTrackElement; + createElement(tagName: "tt"): HTMLPhraseElement; + createElement(tagName: "u"): HTMLPhraseElement; + createElement(tagName: "ul"): HTMLUListElement; + createElement(tagName: "var"): HTMLPhraseElement; + createElement(tagName: "video"): HTMLVideoElement; + createElement(tagName: "x-ms-webview"): MSHTMLWebViewElement; + createElement(tagName: "xmp"): HTMLBlockElement; + createElement(tagName: string): HTMLElement; + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "a"): SVGAElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "circle"): SVGCircleElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "clipPath"): SVGClipPathElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "componentTransferFunction"): SVGComponentTransferFunctionElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "defs"): SVGDefsElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "desc"): SVGDescElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "ellipse"): SVGEllipseElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feBlend"): SVGFEBlendElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feColorMatrix"): SVGFEColorMatrixElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feComponentTransfer"): SVGFEComponentTransferElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feComposite"): SVGFECompositeElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feConvolveMatrix"): SVGFEConvolveMatrixElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feDiffuseLighting"): SVGFEDiffuseLightingElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feDisplacementMap"): SVGFEDisplacementMapElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feDistantLight"): SVGFEDistantLightElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFlood"): SVGFEFloodElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncA"): SVGFEFuncAElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncB"): SVGFEFuncBElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncG"): SVGFEFuncGElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncR"): SVGFEFuncRElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feGaussianBlur"): SVGFEGaussianBlurElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feImage"): SVGFEImageElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feMerge"): SVGFEMergeElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feMergeNode"): SVGFEMergeNodeElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feMorphology"): SVGFEMorphologyElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feOffset"): SVGFEOffsetElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "fePointLight"): SVGFEPointLightElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feSpecularLighting"): SVGFESpecularLightingElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feSpotLight"): SVGFESpotLightElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feTile"): SVGFETileElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feTurbulence"): SVGFETurbulenceElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "filter"): SVGFilterElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "foreignObject"): SVGForeignObjectElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "g"): SVGGElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "image"): SVGImageElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "gradient"): SVGGradientElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "line"): SVGLineElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "linearGradient"): SVGLinearGradientElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "marker"): SVGMarkerElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "mask"): SVGMaskElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "path"): SVGPathElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "metadata"): SVGMetadataElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "pattern"): SVGPatternElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "polygon"): SVGPolygonElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "polyline"): SVGPolylineElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "radialGradient"): SVGRadialGradientElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "rect"): SVGRectElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "svg"): SVGSVGElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "script"): SVGScriptElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "stop"): SVGStopElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "style"): SVGStyleElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "switch"): SVGSwitchElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "symbol"): SVGSymbolElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "tspan"): SVGTSpanElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "textContent"): SVGTextContentElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "text"): SVGTextElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "textPath"): SVGTextPathElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "textPositioning"): SVGTextPositioningElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "title"): SVGTitleElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "use"): SVGUseElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "view"): SVGViewElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: string): SVGElement + createElementNS(namespaceURI: string, qualifiedName: string): Element; + createExpression(expression: string, resolver: XPathNSResolver): XPathExpression; + createNSResolver(nodeResolver: Node): XPathNSResolver; + /** + * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. + * @param root The root element or node to start traversing on. + * @param whatToShow The type of nodes or elements to appear in the node list + * @param filter A custom NodeFilter function to use. For more information, see filter. Use null for no filter. + * @param entityReferenceExpansion A flag that specifies whether entity reference nodes are expanded. + */ + createNodeIterator(root: Node, whatToShow?: number, filter?: NodeFilter, entityReferenceExpansion?: boolean): NodeIterator; + createProcessingInstruction(target: string, data: string): ProcessingInstruction; + /** + * Returns an empty range object that has both of its boundary points positioned at the beginning of the document. + */ + createRange(): Range; + /** + * Creates a text string from the specified value. + * @param data String that specifies the nodeValue property of the text node. + */ + createTextNode(data: string): Text; + createTouch(view: any, target: EventTarget, identifier: number, pageX: number, pageY: number, screenX: number, screenY: number): Touch; + createTouchList(...touches: Touch[]): TouchList; + /** + * Creates a TreeWalker object that you can use to traverse filtered lists of nodes or elements in a document. + * @param root The root element or node to start traversing on. + * @param whatToShow The type of nodes or elements to appear in the node list. For more information, see whatToShow. + * @param filter A custom NodeFilter function to use. + * @param entityReferenceExpansion A flag that specifies whether entity reference nodes are expanded. + */ + createTreeWalker(root: Node, whatToShow?: number, filter?: NodeFilter, entityReferenceExpansion?: boolean): TreeWalker; + /** + * Returns the element for the specified x coordinate and the specified y coordinate. + * @param x The x-offset + * @param y The y-offset + */ + elementFromPoint(x: number, y: number): Element; + evaluate(expression: string, contextNode: Node, resolver: XPathNSResolver, type: number, result: XPathResult): XPathResult; + /** + * Executes a command on the current document, current selection, or the given range. + * @param commandId String that specifies the command to execute. This command can be any of the command identifiers that can be executed in script. + * @param showUI Display the user interface, defaults to false. + * @param value Value to assign. + */ + execCommand(commandId: string, showUI?: boolean, value?: any): boolean; + /** + * Displays help information for the given command identifier. + * @param commandId Displays help information for the given command identifier. + */ + execCommandShowHelp(commandId: string): boolean; + exitFullscreen(): void; + exitPointerLock(): void; + /** + * Causes the element to receive the focus and executes the code specified by the onfocus event. + */ + focus(): void; + /** + * Returns a reference to the first object with the specified value of the ID or NAME attribute. + * @param elementId String that specifies the ID value. Case-insensitive. + */ + getElementById(elementId: string): HTMLElement; + getElementsByClassName(classNames: string): NodeListOf; + /** + * Gets a collection of objects based on the value of the NAME or ID attribute. + * @param elementName Gets a collection of objects based on the value of the NAME or ID attribute. + */ + getElementsByName(elementName: string): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(tagname: "a"): NodeListOf; + getElementsByTagName(tagname: "abbr"): NodeListOf; + getElementsByTagName(tagname: "acronym"): NodeListOf; + getElementsByTagName(tagname: "address"): NodeListOf; + getElementsByTagName(tagname: "applet"): NodeListOf; + getElementsByTagName(tagname: "area"): NodeListOf; + getElementsByTagName(tagname: "article"): NodeListOf; + getElementsByTagName(tagname: "aside"): NodeListOf; + getElementsByTagName(tagname: "audio"): NodeListOf; + getElementsByTagName(tagname: "b"): NodeListOf; + getElementsByTagName(tagname: "base"): NodeListOf; + getElementsByTagName(tagname: "basefont"): NodeListOf; + getElementsByTagName(tagname: "bdo"): NodeListOf; + getElementsByTagName(tagname: "big"): NodeListOf; + getElementsByTagName(tagname: "blockquote"): NodeListOf; + getElementsByTagName(tagname: "body"): NodeListOf; + getElementsByTagName(tagname: "br"): NodeListOf; + getElementsByTagName(tagname: "button"): NodeListOf; + getElementsByTagName(tagname: "canvas"): NodeListOf; + getElementsByTagName(tagname: "caption"): NodeListOf; + getElementsByTagName(tagname: "center"): NodeListOf; + getElementsByTagName(tagname: "circle"): NodeListOf; + getElementsByTagName(tagname: "cite"): NodeListOf; + getElementsByTagName(tagname: "clippath"): NodeListOf; + getElementsByTagName(tagname: "code"): NodeListOf; + getElementsByTagName(tagname: "col"): NodeListOf; + getElementsByTagName(tagname: "colgroup"): NodeListOf; + getElementsByTagName(tagname: "datalist"): NodeListOf; + getElementsByTagName(tagname: "dd"): NodeListOf; + getElementsByTagName(tagname: "defs"): NodeListOf; + getElementsByTagName(tagname: "del"): NodeListOf; + getElementsByTagName(tagname: "desc"): NodeListOf; + getElementsByTagName(tagname: "dfn"): NodeListOf; + getElementsByTagName(tagname: "dir"): NodeListOf; + getElementsByTagName(tagname: "div"): NodeListOf; + getElementsByTagName(tagname: "dl"): NodeListOf; + getElementsByTagName(tagname: "dt"): NodeListOf; + getElementsByTagName(tagname: "ellipse"): NodeListOf; + getElementsByTagName(tagname: "em"): NodeListOf; + getElementsByTagName(tagname: "embed"): NodeListOf; + getElementsByTagName(tagname: "feblend"): NodeListOf; + getElementsByTagName(tagname: "fecolormatrix"): NodeListOf; + getElementsByTagName(tagname: "fecomponenttransfer"): NodeListOf; + getElementsByTagName(tagname: "fecomposite"): NodeListOf; + getElementsByTagName(tagname: "feconvolvematrix"): NodeListOf; + getElementsByTagName(tagname: "fediffuselighting"): NodeListOf; + getElementsByTagName(tagname: "fedisplacementmap"): NodeListOf; + getElementsByTagName(tagname: "fedistantlight"): NodeListOf; + getElementsByTagName(tagname: "feflood"): NodeListOf; + getElementsByTagName(tagname: "fefunca"): NodeListOf; + getElementsByTagName(tagname: "fefuncb"): NodeListOf; + getElementsByTagName(tagname: "fefuncg"): NodeListOf; + getElementsByTagName(tagname: "fefuncr"): NodeListOf; + getElementsByTagName(tagname: "fegaussianblur"): NodeListOf; + getElementsByTagName(tagname: "feimage"): NodeListOf; + getElementsByTagName(tagname: "femerge"): NodeListOf; + getElementsByTagName(tagname: "femergenode"): NodeListOf; + getElementsByTagName(tagname: "femorphology"): NodeListOf; + getElementsByTagName(tagname: "feoffset"): NodeListOf; + getElementsByTagName(tagname: "fepointlight"): NodeListOf; + getElementsByTagName(tagname: "fespecularlighting"): NodeListOf; + getElementsByTagName(tagname: "fespotlight"): NodeListOf; + getElementsByTagName(tagname: "fetile"): NodeListOf; + getElementsByTagName(tagname: "feturbulence"): NodeListOf; + getElementsByTagName(tagname: "fieldset"): NodeListOf; + getElementsByTagName(tagname: "figcaption"): NodeListOf; + getElementsByTagName(tagname: "figure"): NodeListOf; + getElementsByTagName(tagname: "filter"): NodeListOf; + getElementsByTagName(tagname: "font"): NodeListOf; + getElementsByTagName(tagname: "footer"): NodeListOf; + getElementsByTagName(tagname: "foreignobject"): NodeListOf; + getElementsByTagName(tagname: "form"): NodeListOf; + getElementsByTagName(tagname: "frame"): NodeListOf; + getElementsByTagName(tagname: "frameset"): NodeListOf; + getElementsByTagName(tagname: "g"): NodeListOf; + getElementsByTagName(tagname: "h1"): NodeListOf; + getElementsByTagName(tagname: "h2"): NodeListOf; + getElementsByTagName(tagname: "h3"): NodeListOf; + getElementsByTagName(tagname: "h4"): NodeListOf; + getElementsByTagName(tagname: "h5"): NodeListOf; + getElementsByTagName(tagname: "h6"): NodeListOf; + getElementsByTagName(tagname: "head"): NodeListOf; + getElementsByTagName(tagname: "header"): NodeListOf; + getElementsByTagName(tagname: "hgroup"): NodeListOf; + getElementsByTagName(tagname: "hr"): NodeListOf; + getElementsByTagName(tagname: "html"): NodeListOf; + getElementsByTagName(tagname: "i"): NodeListOf; + getElementsByTagName(tagname: "iframe"): NodeListOf; + getElementsByTagName(tagname: "image"): NodeListOf; + getElementsByTagName(tagname: "img"): NodeListOf; + getElementsByTagName(tagname: "input"): NodeListOf; + getElementsByTagName(tagname: "ins"): NodeListOf; + getElementsByTagName(tagname: "isindex"): NodeListOf; + getElementsByTagName(tagname: "kbd"): NodeListOf; + getElementsByTagName(tagname: "keygen"): NodeListOf; + getElementsByTagName(tagname: "label"): NodeListOf; + getElementsByTagName(tagname: "legend"): NodeListOf; + getElementsByTagName(tagname: "li"): NodeListOf; + getElementsByTagName(tagname: "line"): NodeListOf; + getElementsByTagName(tagname: "lineargradient"): NodeListOf; + getElementsByTagName(tagname: "link"): NodeListOf; + getElementsByTagName(tagname: "listing"): NodeListOf; + getElementsByTagName(tagname: "map"): NodeListOf; + getElementsByTagName(tagname: "mark"): NodeListOf; + getElementsByTagName(tagname: "marker"): NodeListOf; + getElementsByTagName(tagname: "marquee"): NodeListOf; + getElementsByTagName(tagname: "mask"): NodeListOf; + getElementsByTagName(tagname: "menu"): NodeListOf; + getElementsByTagName(tagname: "meta"): NodeListOf; + getElementsByTagName(tagname: "metadata"): NodeListOf; + getElementsByTagName(tagname: "nav"): NodeListOf; + getElementsByTagName(tagname: "nextid"): NodeListOf; + getElementsByTagName(tagname: "nobr"): NodeListOf; + getElementsByTagName(tagname: "noframes"): NodeListOf; + getElementsByTagName(tagname: "noscript"): NodeListOf; + getElementsByTagName(tagname: "object"): NodeListOf; + getElementsByTagName(tagname: "ol"): NodeListOf; + getElementsByTagName(tagname: "optgroup"): NodeListOf; + getElementsByTagName(tagname: "option"): NodeListOf; + getElementsByTagName(tagname: "p"): NodeListOf; + getElementsByTagName(tagname: "param"): NodeListOf; + getElementsByTagName(tagname: "path"): NodeListOf; + getElementsByTagName(tagname: "pattern"): NodeListOf; + getElementsByTagName(tagname: "plaintext"): NodeListOf; + getElementsByTagName(tagname: "polygon"): NodeListOf; + getElementsByTagName(tagname: "polyline"): NodeListOf; + getElementsByTagName(tagname: "pre"): NodeListOf; + getElementsByTagName(tagname: "progress"): NodeListOf; + getElementsByTagName(tagname: "q"): NodeListOf; + getElementsByTagName(tagname: "radialgradient"): NodeListOf; + getElementsByTagName(tagname: "rect"): NodeListOf; + getElementsByTagName(tagname: "rt"): NodeListOf; + getElementsByTagName(tagname: "ruby"): NodeListOf; + getElementsByTagName(tagname: "s"): NodeListOf; + getElementsByTagName(tagname: "samp"): NodeListOf; + getElementsByTagName(tagname: "script"): NodeListOf; + getElementsByTagName(tagname: "section"): NodeListOf; + getElementsByTagName(tagname: "select"): NodeListOf; + getElementsByTagName(tagname: "small"): NodeListOf; + getElementsByTagName(tagname: "source"): NodeListOf; + getElementsByTagName(tagname: "span"): NodeListOf; + getElementsByTagName(tagname: "stop"): NodeListOf; + getElementsByTagName(tagname: "strike"): NodeListOf; + getElementsByTagName(tagname: "strong"): NodeListOf; + getElementsByTagName(tagname: "style"): NodeListOf; + getElementsByTagName(tagname: "sub"): NodeListOf; + getElementsByTagName(tagname: "sup"): NodeListOf; + getElementsByTagName(tagname: "svg"): NodeListOf; + getElementsByTagName(tagname: "switch"): NodeListOf; + getElementsByTagName(tagname: "symbol"): NodeListOf; + getElementsByTagName(tagname: "table"): NodeListOf; + getElementsByTagName(tagname: "tbody"): NodeListOf; + getElementsByTagName(tagname: "td"): NodeListOf; + getElementsByTagName(tagname: "text"): NodeListOf; + getElementsByTagName(tagname: "textpath"): NodeListOf; + getElementsByTagName(tagname: "textarea"): NodeListOf; + getElementsByTagName(tagname: "tfoot"): NodeListOf; + getElementsByTagName(tagname: "th"): NodeListOf; + getElementsByTagName(tagname: "thead"): NodeListOf; + getElementsByTagName(tagname: "title"): NodeListOf; + getElementsByTagName(tagname: "tr"): NodeListOf; + getElementsByTagName(tagname: "track"): NodeListOf; + getElementsByTagName(tagname: "tspan"): NodeListOf; + getElementsByTagName(tagname: "tt"): NodeListOf; + getElementsByTagName(tagname: "u"): NodeListOf; + getElementsByTagName(tagname: "ul"): NodeListOf; + getElementsByTagName(tagname: "use"): NodeListOf; + getElementsByTagName(tagname: "var"): NodeListOf; + getElementsByTagName(tagname: "video"): NodeListOf; + getElementsByTagName(tagname: "view"): NodeListOf; + getElementsByTagName(tagname: "wbr"): NodeListOf; + getElementsByTagName(tagname: "x-ms-webview"): NodeListOf; + getElementsByTagName(tagname: "xmp"): NodeListOf; + getElementsByTagName(tagname: string): NodeListOf; + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf; + /** + * Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. + */ + getSelection(): Selection; + /** + * Gets a value indicating whether the object currently has focus. + */ + hasFocus(): boolean; + importNode(importedNode: Node, deep: boolean): Node; + msElementsFromPoint(x: number, y: number): NodeList; + msElementsFromRect(left: number, top: number, width: number, height: number): NodeList; + /** + * Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. + * @param url Specifies a MIME type for the document. + * @param name Specifies the name of the window. This name is used as the value for the TARGET attribute on a form or an anchor element. + * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. + * @param replace Specifies whether the existing entry for the document is replaced in the history list. + */ + open(url?: string, name?: string, features?: string, replace?: boolean): Document; + /** + * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. + * @param commandId Specifies a command identifier. + */ + queryCommandEnabled(commandId: string): boolean; + /** + * Returns a Boolean value that indicates whether the specified command is in the indeterminate state. + * @param commandId String that specifies a command identifier. + */ + queryCommandIndeterm(commandId: string): boolean; + /** + * Returns a Boolean value that indicates the current state of the command. + * @param commandId String that specifies a command identifier. + */ + queryCommandState(commandId: string): boolean; + /** + * Returns a Boolean value that indicates whether the current command is supported on the current range. + * @param commandId Specifies a command identifier. + */ + queryCommandSupported(commandId: string): boolean; + /** + * Retrieves the string associated with a command. + * @param commandId String that contains the identifier of a command. This can be any command identifier given in the list of Command Identifiers. + */ + queryCommandText(commandId: string): string; + /** + * Returns the current value of the document, range, or current selection for the given command. + * @param commandId String that specifies a command identifier. + */ + queryCommandValue(commandId: string): string; + releaseEvents(): void; + /** + * Allows updating the print settings for the page. + */ + updateSettings(): void; + webkitCancelFullScreen(): void; + webkitExitFullscreen(): void; + /** + * Writes one or more HTML expressions to a document in the specified window. + * @param content Specifies the text and HTML tags to write. + */ + write(...content: string[]): void; + /** + * Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window. + * @param content The text and HTML tags to write. + */ + writeln(...content: string[]): void; + createElement(tagName: "picture"): HTMLPictureElement; + getElementsByTagName(tagname: "picture"): NodeListOf; + addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "fullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "fullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mssitemodejumplistitemremoved", listener: (ev: MSSiteModeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "msthumbnailclick", listener: (ev: MSSiteModeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerlockchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointerlockerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stop", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Document: { + prototype: Document; + new(): Document; +} + +interface DocumentFragment extends Node, NodeSelector { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var DocumentFragment: { + prototype: DocumentFragment; + new(): DocumentFragment; +} + +interface DocumentType extends Node, ChildNode { + entities: NamedNodeMap; + internalSubset: string; + name: string; + notations: NamedNodeMap; + publicId: string; + systemId: string; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var DocumentType: { + prototype: DocumentType; + new(): DocumentType; +} + +interface DragEvent extends MouseEvent { + dataTransfer: DataTransfer; + initDragEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, dataTransferArg: DataTransfer): void; + msConvertURL(file: File, targetType: string, targetURL?: string): void; +} + +declare var DragEvent: { + prototype: DragEvent; + new(): DragEvent; +} + +interface DynamicsCompressorNode extends AudioNode { + attack: AudioParam; + knee: AudioParam; + ratio: AudioParam; + reduction: AudioParam; + release: AudioParam; + threshold: AudioParam; +} + +declare var DynamicsCompressorNode: { + prototype: DynamicsCompressorNode; + new(): DynamicsCompressorNode; +} + +interface EXT_texture_filter_anisotropic { + MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; + TEXTURE_MAX_ANISOTROPY_EXT: number; +} + +declare var EXT_texture_filter_anisotropic: { + prototype: EXT_texture_filter_anisotropic; + new(): EXT_texture_filter_anisotropic; + MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; + TEXTURE_MAX_ANISOTROPY_EXT: number; +} + +interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode { + classList: DOMTokenList; + clientHeight: number; + clientLeft: number; + clientTop: number; + clientWidth: number; + msContentZoomFactor: number; + msRegionOverflow: string; + onariarequest: (ev: AriaRequestEvent) => any; + oncommand: (ev: CommandEvent) => any; + ongotpointercapture: (ev: PointerEvent) => any; + onlostpointercapture: (ev: PointerEvent) => any; + onmsgesturechange: (ev: MSGestureEvent) => any; + onmsgesturedoubletap: (ev: MSGestureEvent) => any; + onmsgestureend: (ev: MSGestureEvent) => any; + onmsgesturehold: (ev: MSGestureEvent) => any; + onmsgesturestart: (ev: MSGestureEvent) => any; + onmsgesturetap: (ev: MSGestureEvent) => any; + onmsgotpointercapture: (ev: MSPointerEvent) => any; + onmsinertiastart: (ev: MSGestureEvent) => any; + onmslostpointercapture: (ev: MSPointerEvent) => any; + onmspointercancel: (ev: MSPointerEvent) => any; + onmspointerdown: (ev: MSPointerEvent) => any; + onmspointerenter: (ev: MSPointerEvent) => any; + onmspointerleave: (ev: MSPointerEvent) => any; + onmspointermove: (ev: MSPointerEvent) => any; + onmspointerout: (ev: MSPointerEvent) => any; + onmspointerover: (ev: MSPointerEvent) => any; + onmspointerup: (ev: MSPointerEvent) => any; + ontouchcancel: (ev: TouchEvent) => any; + ontouchend: (ev: TouchEvent) => any; + ontouchmove: (ev: TouchEvent) => any; + ontouchstart: (ev: TouchEvent) => any; + onwebkitfullscreenchange: (ev: Event) => any; + onwebkitfullscreenerror: (ev: Event) => any; + scrollHeight: number; + scrollLeft: number; + scrollTop: number; + scrollWidth: number; + tagName: string; + id: string; + className: string; + innerHTML: string; + getAttribute(name?: string): string; + getAttributeNS(namespaceURI: string, localName: string): string; + getAttributeNode(name: string): Attr; + getAttributeNodeNS(namespaceURI: string, localName: string): Attr; + getBoundingClientRect(): ClientRect; + getClientRects(): ClientRectList; + getElementsByTagName(name: "a"): NodeListOf; + getElementsByTagName(name: "abbr"): NodeListOf; + getElementsByTagName(name: "acronym"): NodeListOf; + getElementsByTagName(name: "address"): NodeListOf; + getElementsByTagName(name: "applet"): NodeListOf; + getElementsByTagName(name: "area"): NodeListOf; + getElementsByTagName(name: "article"): NodeListOf; + getElementsByTagName(name: "aside"): NodeListOf; + getElementsByTagName(name: "audio"): NodeListOf; + getElementsByTagName(name: "b"): NodeListOf; + getElementsByTagName(name: "base"): NodeListOf; + getElementsByTagName(name: "basefont"): NodeListOf; + getElementsByTagName(name: "bdo"): NodeListOf; + getElementsByTagName(name: "big"): NodeListOf; + getElementsByTagName(name: "blockquote"): NodeListOf; + getElementsByTagName(name: "body"): NodeListOf; + getElementsByTagName(name: "br"): NodeListOf; + getElementsByTagName(name: "button"): NodeListOf; + getElementsByTagName(name: "canvas"): NodeListOf; + getElementsByTagName(name: "caption"): NodeListOf; + getElementsByTagName(name: "center"): NodeListOf; + getElementsByTagName(name: "circle"): NodeListOf; + getElementsByTagName(name: "cite"): NodeListOf; + getElementsByTagName(name: "clippath"): NodeListOf; + getElementsByTagName(name: "code"): NodeListOf; + getElementsByTagName(name: "col"): NodeListOf; + getElementsByTagName(name: "colgroup"): NodeListOf; + getElementsByTagName(name: "datalist"): NodeListOf; + getElementsByTagName(name: "dd"): NodeListOf; + getElementsByTagName(name: "defs"): NodeListOf; + getElementsByTagName(name: "del"): NodeListOf; + getElementsByTagName(name: "desc"): NodeListOf; + getElementsByTagName(name: "dfn"): NodeListOf; + getElementsByTagName(name: "dir"): NodeListOf; + getElementsByTagName(name: "div"): NodeListOf; + getElementsByTagName(name: "dl"): NodeListOf; + getElementsByTagName(name: "dt"): NodeListOf; + getElementsByTagName(name: "ellipse"): NodeListOf; + getElementsByTagName(name: "em"): NodeListOf; + getElementsByTagName(name: "embed"): NodeListOf; + getElementsByTagName(name: "feblend"): NodeListOf; + getElementsByTagName(name: "fecolormatrix"): NodeListOf; + getElementsByTagName(name: "fecomponenttransfer"): NodeListOf; + getElementsByTagName(name: "fecomposite"): NodeListOf; + getElementsByTagName(name: "feconvolvematrix"): NodeListOf; + getElementsByTagName(name: "fediffuselighting"): NodeListOf; + getElementsByTagName(name: "fedisplacementmap"): NodeListOf; + getElementsByTagName(name: "fedistantlight"): NodeListOf; + getElementsByTagName(name: "feflood"): NodeListOf; + getElementsByTagName(name: "fefunca"): NodeListOf; + getElementsByTagName(name: "fefuncb"): NodeListOf; + getElementsByTagName(name: "fefuncg"): NodeListOf; + getElementsByTagName(name: "fefuncr"): NodeListOf; + getElementsByTagName(name: "fegaussianblur"): NodeListOf; + getElementsByTagName(name: "feimage"): NodeListOf; + getElementsByTagName(name: "femerge"): NodeListOf; + getElementsByTagName(name: "femergenode"): NodeListOf; + getElementsByTagName(name: "femorphology"): NodeListOf; + getElementsByTagName(name: "feoffset"): NodeListOf; + getElementsByTagName(name: "fepointlight"): NodeListOf; + getElementsByTagName(name: "fespecularlighting"): NodeListOf; + getElementsByTagName(name: "fespotlight"): NodeListOf; + getElementsByTagName(name: "fetile"): NodeListOf; + getElementsByTagName(name: "feturbulence"): NodeListOf; + getElementsByTagName(name: "fieldset"): NodeListOf; + getElementsByTagName(name: "figcaption"): NodeListOf; + getElementsByTagName(name: "figure"): NodeListOf; + getElementsByTagName(name: "filter"): NodeListOf; + getElementsByTagName(name: "font"): NodeListOf; + getElementsByTagName(name: "footer"): NodeListOf; + getElementsByTagName(name: "foreignobject"): NodeListOf; + getElementsByTagName(name: "form"): NodeListOf; + getElementsByTagName(name: "frame"): NodeListOf; + getElementsByTagName(name: "frameset"): NodeListOf; + getElementsByTagName(name: "g"): NodeListOf; + getElementsByTagName(name: "h1"): NodeListOf; + getElementsByTagName(name: "h2"): NodeListOf; + getElementsByTagName(name: "h3"): NodeListOf; + getElementsByTagName(name: "h4"): NodeListOf; + getElementsByTagName(name: "h5"): NodeListOf; + getElementsByTagName(name: "h6"): NodeListOf; + getElementsByTagName(name: "head"): NodeListOf; + getElementsByTagName(name: "header"): NodeListOf; + getElementsByTagName(name: "hgroup"): NodeListOf; + getElementsByTagName(name: "hr"): NodeListOf; + getElementsByTagName(name: "html"): NodeListOf; + getElementsByTagName(name: "i"): NodeListOf; + getElementsByTagName(name: "iframe"): NodeListOf; + getElementsByTagName(name: "image"): NodeListOf; + getElementsByTagName(name: "img"): NodeListOf; + getElementsByTagName(name: "input"): NodeListOf; + getElementsByTagName(name: "ins"): NodeListOf; + getElementsByTagName(name: "isindex"): NodeListOf; + getElementsByTagName(name: "kbd"): NodeListOf; + getElementsByTagName(name: "keygen"): NodeListOf; + getElementsByTagName(name: "label"): NodeListOf; + getElementsByTagName(name: "legend"): NodeListOf; + getElementsByTagName(name: "li"): NodeListOf; + getElementsByTagName(name: "line"): NodeListOf; + getElementsByTagName(name: "lineargradient"): NodeListOf; + getElementsByTagName(name: "link"): NodeListOf; + getElementsByTagName(name: "listing"): NodeListOf; + getElementsByTagName(name: "map"): NodeListOf; + getElementsByTagName(name: "mark"): NodeListOf; + getElementsByTagName(name: "marker"): NodeListOf; + getElementsByTagName(name: "marquee"): NodeListOf; + getElementsByTagName(name: "mask"): NodeListOf; + getElementsByTagName(name: "menu"): NodeListOf; + getElementsByTagName(name: "meta"): NodeListOf; + getElementsByTagName(name: "metadata"): NodeListOf; + getElementsByTagName(name: "nav"): NodeListOf; + getElementsByTagName(name: "nextid"): NodeListOf; + getElementsByTagName(name: "nobr"): NodeListOf; + getElementsByTagName(name: "noframes"): NodeListOf; + getElementsByTagName(name: "noscript"): NodeListOf; + getElementsByTagName(name: "object"): NodeListOf; + getElementsByTagName(name: "ol"): NodeListOf; + getElementsByTagName(name: "optgroup"): NodeListOf; + getElementsByTagName(name: "option"): NodeListOf; + getElementsByTagName(name: "p"): NodeListOf; + getElementsByTagName(name: "param"): NodeListOf; + getElementsByTagName(name: "path"): NodeListOf; + getElementsByTagName(name: "pattern"): NodeListOf; + getElementsByTagName(name: "plaintext"): NodeListOf; + getElementsByTagName(name: "polygon"): NodeListOf; + getElementsByTagName(name: "polyline"): NodeListOf; + getElementsByTagName(name: "pre"): NodeListOf; + getElementsByTagName(name: "progress"): NodeListOf; + getElementsByTagName(name: "q"): NodeListOf; + getElementsByTagName(name: "radialgradient"): NodeListOf; + getElementsByTagName(name: "rect"): NodeListOf; + getElementsByTagName(name: "rt"): NodeListOf; + getElementsByTagName(name: "ruby"): NodeListOf; + getElementsByTagName(name: "s"): NodeListOf; + getElementsByTagName(name: "samp"): NodeListOf; + getElementsByTagName(name: "script"): NodeListOf; + getElementsByTagName(name: "section"): NodeListOf; + getElementsByTagName(name: "select"): NodeListOf; + getElementsByTagName(name: "small"): NodeListOf; + getElementsByTagName(name: "source"): NodeListOf; + getElementsByTagName(name: "span"): NodeListOf; + getElementsByTagName(name: "stop"): NodeListOf; + getElementsByTagName(name: "strike"): NodeListOf; + getElementsByTagName(name: "strong"): NodeListOf; + getElementsByTagName(name: "style"): NodeListOf; + getElementsByTagName(name: "sub"): NodeListOf; + getElementsByTagName(name: "sup"): NodeListOf; + getElementsByTagName(name: "svg"): NodeListOf; + getElementsByTagName(name: "switch"): NodeListOf; + getElementsByTagName(name: "symbol"): NodeListOf; + getElementsByTagName(name: "table"): NodeListOf; + getElementsByTagName(name: "tbody"): NodeListOf; + getElementsByTagName(name: "td"): NodeListOf; + getElementsByTagName(name: "text"): NodeListOf; + getElementsByTagName(name: "textpath"): NodeListOf; + getElementsByTagName(name: "textarea"): NodeListOf; + getElementsByTagName(name: "tfoot"): NodeListOf; + getElementsByTagName(name: "th"): NodeListOf; + getElementsByTagName(name: "thead"): NodeListOf; + getElementsByTagName(name: "title"): NodeListOf; + getElementsByTagName(name: "tr"): NodeListOf; + getElementsByTagName(name: "track"): NodeListOf; + getElementsByTagName(name: "tspan"): NodeListOf; + getElementsByTagName(name: "tt"): NodeListOf; + getElementsByTagName(name: "u"): NodeListOf; + getElementsByTagName(name: "ul"): NodeListOf; + getElementsByTagName(name: "use"): NodeListOf; + getElementsByTagName(name: "var"): NodeListOf; + getElementsByTagName(name: "video"): NodeListOf; + getElementsByTagName(name: "view"): NodeListOf; + getElementsByTagName(name: "wbr"): NodeListOf; + getElementsByTagName(name: "x-ms-webview"): NodeListOf; + getElementsByTagName(name: "xmp"): NodeListOf; + getElementsByTagName(name: string): NodeListOf; + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf; + hasAttribute(name: string): boolean; + hasAttributeNS(namespaceURI: string, localName: string): boolean; + msGetRegionContent(): MSRangeCollection; + msGetUntransformedBounds(): ClientRect; + msMatchesSelector(selectors: string): boolean; + msReleasePointerCapture(pointerId: number): void; + msSetPointerCapture(pointerId: number): void; + msZoomTo(args: MsZoomToOptions): void; + releasePointerCapture(pointerId: number): void; + removeAttribute(name?: string): void; + removeAttributeNS(namespaceURI: string, localName: string): void; + removeAttributeNode(oldAttr: Attr): Attr; + requestFullscreen(): void; + requestPointerLock(): void; + setAttribute(name: string, value: string): void; + setAttributeNS(namespaceURI: string, qualifiedName: string, value: string): void; + setAttributeNode(newAttr: Attr): Attr; + setAttributeNodeNS(newAttr: Attr): Attr; + setPointerCapture(pointerId: number): void; + webkitMatchesSelector(selectors: string): boolean; + webkitRequestFullScreen(): void; + webkitRequestFullscreen(): void; + getElementsByClassName(classNames: string): NodeListOf; + matches(selector: string): boolean; + getElementsByTagName(tagname: "picture"): NodeListOf; + addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Element: { + prototype: Element; + new(): Element; +} + +interface ErrorEvent extends Event { + colno: number; + error: any; + filename: string; + lineno: number; + message: string; + initErrorEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, messageArg: string, filenameArg: string, linenoArg: number): void; +} + +declare var ErrorEvent: { + prototype: ErrorEvent; + new(): ErrorEvent; +} + +interface Event { + bubbles: boolean; + cancelBubble: boolean; + cancelable: boolean; + currentTarget: EventTarget; + defaultPrevented: boolean; + eventPhase: number; + isTrusted: boolean; + returnValue: boolean; + srcElement: Element; + target: EventTarget; + timeStamp: number; + type: string; + initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; + preventDefault(): void; + stopImmediatePropagation(): void; + stopPropagation(): void; + AT_TARGET: number; + BUBBLING_PHASE: number; + CAPTURING_PHASE: number; +} + +declare var Event: { + prototype: Event; + new(type: string, eventInitDict?: EventInit): Event; + AT_TARGET: number; + BUBBLING_PHASE: number; + CAPTURING_PHASE: number; +} + +interface EventTarget { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + dispatchEvent(evt: Event): boolean; + removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var EventTarget: { + prototype: EventTarget; + new(): EventTarget; +} + +interface External { +} + +declare var External: { + prototype: External; + new(): External; +} + +interface File extends Blob { + lastModifiedDate: any; + name: string; +} + +declare var File: { + prototype: File; + new (parts: (ArrayBuffer | ArrayBufferView | Blob | string)[], filename: string, properties?: FilePropertyBag): File; +} + +interface FileList { + length: number; + item(index: number): File; + [index: number]: File; +} + +declare var FileList: { + prototype: FileList; + new(): FileList; +} + +interface FileReader extends EventTarget, MSBaseReader { + error: DOMError; + readAsArrayBuffer(blob: Blob): void; + readAsBinaryString(blob: Blob): void; + readAsDataURL(blob: Blob): void; + readAsText(blob: Blob, encoding?: string): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var FileReader: { + prototype: FileReader; + new(): FileReader; +} + +interface FocusEvent extends UIEvent { + relatedTarget: EventTarget; + initFocusEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, relatedTargetArg: EventTarget): void; +} + +declare var FocusEvent: { + prototype: FocusEvent; + new(typeArg: string, eventInitDict?: FocusEventInit): FocusEvent; +} + +interface FormData { + append(name: any, value: any, blobName?: string): void; +} + +declare var FormData: { + prototype: FormData; + new (form?: HTMLFormElement): FormData; +} + +interface GainNode extends AudioNode { + gain: AudioParam; +} + +declare var GainNode: { + prototype: GainNode; + new(): GainNode; +} + +interface Gamepad { + axes: number[]; + buttons: GamepadButton[]; + connected: boolean; + id: string; + index: number; + mapping: string; + timestamp: number; +} + +declare var Gamepad: { + prototype: Gamepad; + new(): Gamepad; +} + +interface GamepadButton { + pressed: boolean; + value: number; +} + +declare var GamepadButton: { + prototype: GamepadButton; + new(): GamepadButton; +} + +interface GamepadEvent extends Event { + gamepad: Gamepad; +} + +declare var GamepadEvent: { + prototype: GamepadEvent; + new(): GamepadEvent; +} + +interface Geolocation { + clearWatch(watchId: number): void; + getCurrentPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): void; + watchPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): number; +} + +declare var Geolocation: { + prototype: Geolocation; + new(): Geolocation; +} + +interface HTMLAllCollection extends HTMLCollection { + namedItem(name: string): Element; +} + +declare var HTMLAllCollection: { + prototype: HTMLAllCollection; + new(): HTMLAllCollection; +} + +interface HTMLAnchorElement extends HTMLElement { + Methods: string; + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; + /** + * Sets or retrieves the coordinates of the object. + */ + coords: string; + /** + * Contains the anchor portion of the URL including the hash sign (#). + */ + hash: string; + /** + * Contains the hostname and port values of the URL. + */ + host: string; + /** + * Contains the hostname of a URL. + */ + hostname: string; + /** + * Sets or retrieves a destination URL or an anchor point. + */ + href: string; + /** + * Sets or retrieves the language code of the object. + */ + hreflang: string; + mimeType: string; + /** + * Sets or retrieves the shape of the object. + */ + name: string; + nameProp: string; + /** + * Contains the pathname of the URL. + */ + pathname: string; + /** + * Sets or retrieves the port number associated with a URL. + */ + port: string; + /** + * Contains the protocol of the URL. + */ + protocol: string; + protocolLong: string; + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rel: string; + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rev: string; + /** + * Sets or retrieves the substring of the href property that follows the question mark. + */ + search: string; + /** + * Sets or retrieves the shape of the object. + */ + shape: string; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; + type: string; + urn: string; + /** + * Returns a string representation of an object. + */ + toString(): string; +} + +declare var HTMLAnchorElement: { + prototype: HTMLAnchorElement; + new(): HTMLAnchorElement; +} + +interface HTMLAppletElement extends HTMLElement { + /** + * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. + */ + BaseHref: string; + align: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Gets or sets the optional alternative HTML script to execute if the object fails to load. + */ + altHtml: string; + /** + * Sets or retrieves a character string that can be used to implement your own archive functionality for the object. + */ + archive: string; + border: string; + code: string; + /** + * Sets or retrieves the URL of the component. + */ + codeBase: string; + /** + * Sets or retrieves the Internet media type for the code associated with the object. + */ + codeType: string; + /** + * Address of a pointer to the document this page or frame contains. If there is no document, then null will be returned. + */ + contentDocument: Document; + /** + * Sets or retrieves the URL that references the data of the object. + */ + data: string; + /** + * Sets or retrieves a character string that can be used to implement your own declare functionality for the object. + */ + declare: boolean; + form: HTMLFormElement; + /** + * Sets or retrieves the height of the object. + */ + height: string; + hspace: number; + /** + * Sets or retrieves the shape of the object. + */ + name: string; + object: string; + /** + * Sets or retrieves a message to be displayed while an object is loading. + */ + standby: string; + /** + * Returns the content type of the object. + */ + type: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + vspace: number; + width: number; +} + +declare var HTMLAppletElement: { + prototype: HTMLAppletElement; + new(): HTMLAppletElement; +} + +interface HTMLAreaElement extends HTMLElement { + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves the coordinates of the object. + */ + coords: string; + /** + * Sets or retrieves the subsection of the href property that follows the number sign (#). + */ + hash: string; + /** + * Sets or retrieves the hostname and port number of the location or URL. + */ + host: string; + /** + * Sets or retrieves the host name part of the location or URL. + */ + hostname: string; + /** + * Sets or retrieves a destination URL or an anchor point. + */ + href: string; + /** + * Sets or gets whether clicks in this region cause action. + */ + noHref: boolean; + /** + * Sets or retrieves the file name or path specified by the object. + */ + pathname: string; + /** + * Sets or retrieves the port number associated with a URL. + */ + port: string; + /** + * Sets or retrieves the protocol portion of a URL. + */ + protocol: string; + rel: string; + /** + * Sets or retrieves the substring of the href property that follows the question mark. + */ + search: string; + /** + * Sets or retrieves the shape of the object. + */ + shape: string; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Returns a string representation of an object. + */ + toString(): string; +} + +declare var HTMLAreaElement: { + prototype: HTMLAreaElement; + new(): HTMLAreaElement; +} + +interface HTMLAreasCollection extends HTMLCollection { + /** + * Adds an element to the areas, controlRange, or options collection. + */ + add(element: HTMLElement, before?: HTMLElement | number): void; + /** + * Removes an element from the collection. + */ + remove(index?: number): void; +} + +declare var HTMLAreasCollection: { + prototype: HTMLAreasCollection; + new(): HTMLAreasCollection; +} + +interface HTMLAudioElement extends HTMLMediaElement { +} + +declare var HTMLAudioElement: { + prototype: HTMLAudioElement; + new(): HTMLAudioElement; +} + +interface HTMLBRElement extends HTMLElement { + /** + * Sets or retrieves the side on which floating objects are not to be positioned when any IHTMLBlockElement is inserted into the document. + */ + clear: string; +} + +declare var HTMLBRElement: { + prototype: HTMLBRElement; + new(): HTMLBRElement; +} + +interface HTMLBaseElement extends HTMLElement { + /** + * Gets or sets the baseline URL on which relative links are based. + */ + href: string; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; +} + +declare var HTMLBaseElement: { + prototype: HTMLBaseElement; + new(): HTMLBaseElement; +} + +interface HTMLBaseFontElement extends HTMLElement, DOML2DeprecatedColorProperty { + /** + * Sets or retrieves the current typeface family. + */ + face: string; + /** + * Sets or retrieves the font size of the object. + */ + size: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLBaseFontElement: { + prototype: HTMLBaseFontElement; + new(): HTMLBaseFontElement; +} + +interface HTMLBlockElement extends HTMLElement { + /** + * Sets or retrieves reference information about the object. + */ + cite: string; + clear: string; + /** + * Sets or retrieves the width of the object. + */ + width: number; +} + +declare var HTMLBlockElement: { + prototype: HTMLBlockElement; + new(): HTMLBlockElement; +} + +interface HTMLBodyElement extends HTMLElement { + aLink: any; + background: string; + bgColor: any; + bgProperties: string; + link: any; + noWrap: boolean; + onafterprint: (ev: Event) => any; + onbeforeprint: (ev: Event) => any; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + onblur: (ev: FocusEvent) => any; + onerror: (ev: Event) => any; + onfocus: (ev: FocusEvent) => any; + onhashchange: (ev: HashChangeEvent) => any; + onload: (ev: Event) => any; + onmessage: (ev: MessageEvent) => any; + onoffline: (ev: Event) => any; + ononline: (ev: Event) => any; + onorientationchange: (ev: Event) => any; + onpagehide: (ev: PageTransitionEvent) => any; + onpageshow: (ev: PageTransitionEvent) => any; + onpopstate: (ev: PopStateEvent) => any; + onresize: (ev: UIEvent) => any; + onstorage: (ev: StorageEvent) => any; + onunload: (ev: Event) => any; + text: any; + vLink: any; + createTextRange(): TextRange; + addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "hashchange", listener: (ev: HashChangeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "orientationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLBodyElement: { + prototype: HTMLBodyElement; + new(): HTMLBodyElement; +} + +interface HTMLButtonElement extends HTMLElement { + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + disabled: boolean; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Overrides the action attribute (where the data on a form is sent) on the parent form element. + */ + formAction: string; + /** + * Used to override the encoding (formEnctype attribute) specified on the form element. + */ + formEnctype: string; + /** + * Overrides the submit method attribute previously specified on a form element. + */ + formMethod: string; + /** + * Overrides any validation or required attributes on a form or form elements to allow it to be submitted without validation. This can be used to create a "save draft"-type submit option. + */ + formNoValidate: string; + /** + * Overrides the target attribute on a form element. + */ + formTarget: string; + /** + * Sets or retrieves the name of the object. + */ + name: string; + status: any; + /** + * Gets the classification and default behavior of the button. + */ + type: string; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Sets or retrieves the default or selected value of the control. + */ + value: string; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Creates a TextRange object for the element. + */ + createTextRange(): TextRange; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} + +declare var HTMLButtonElement: { + prototype: HTMLButtonElement; + new(): HTMLButtonElement; +} + +interface HTMLCanvasElement extends HTMLElement { + /** + * Gets or sets the height of a canvas element on a document. + */ + height: number; + /** + * Gets or sets the width of a canvas element on a document. + */ + width: number; + /** + * Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas. + * @param contextId The identifier (ID) of the type of canvas to create. Internet Explorer 9 and Internet Explorer 10 support only a 2-D context using canvas.getContext("2d"); IE11 Preview also supports 3-D or WebGL context using canvas.getContext("experimental-webgl"); + */ + getContext(contextId: "2d"): CanvasRenderingContext2D; + getContext(contextId: "experimental-webgl"): WebGLRenderingContext; + getContext(contextId: string, ...args: any[]): CanvasRenderingContext2D | WebGLRenderingContext; + /** + * Returns a blob object encoded as a Portable Network Graphics (PNG) format from a canvas image or drawing. + */ + msToBlob(): Blob; + /** + * Returns the content of the current canvas as an image that you can use as a source for another canvas or an HTML element. + * @param type The standard MIME type for the image format to return. If you do not specify this parameter, the default value is a PNG format image. + */ + toDataURL(type?: string, ...args: any[]): string; + toBlob(): Blob; +} + +declare var HTMLCanvasElement: { + prototype: HTMLCanvasElement; + new(): HTMLCanvasElement; +} + +interface HTMLCollection { + /** + * Sets or retrieves the number of objects in a collection. + */ + length: number; + /** + * Retrieves an object from various collections. + */ + item(nameOrIndex?: any, optionalIndex?: any): Element; + /** + * Retrieves a select object or an object from an options collection. + */ + namedItem(name: string): Element; + [index: number]: Element; +} + +declare var HTMLCollection: { + prototype: HTMLCollection; + new(): HTMLCollection; +} + +interface HTMLDDElement extends HTMLElement { + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; +} + +declare var HTMLDDElement: { + prototype: HTMLDDElement; + new(): HTMLDDElement; +} + +interface HTMLDListElement extends HTMLElement { + compact: boolean; +} + +declare var HTMLDListElement: { + prototype: HTMLDListElement; + new(): HTMLDListElement; +} + +interface HTMLDTElement extends HTMLElement { + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; +} + +declare var HTMLDTElement: { + prototype: HTMLDTElement; + new(): HTMLDTElement; +} + +interface HTMLDataListElement extends HTMLElement { + options: HTMLCollection; +} + +declare var HTMLDataListElement: { + prototype: HTMLDataListElement; + new(): HTMLDataListElement; +} + +interface HTMLDirectoryElement extends HTMLElement { + compact: boolean; +} + +declare var HTMLDirectoryElement: { + prototype: HTMLDirectoryElement; + new(): HTMLDirectoryElement; +} + +interface HTMLDivElement extends HTMLElement { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; +} + +declare var HTMLDivElement: { + prototype: HTMLDivElement; + new(): HTMLDivElement; +} + +interface HTMLDocument extends Document { +} + +declare var HTMLDocument: { + prototype: HTMLDocument; + new(): HTMLDocument; +} + +interface HTMLElement extends Element { + accessKey: string; + children: HTMLCollection; + contentEditable: string; + dataset: DOMStringMap; + dir: string; + draggable: boolean; + hidden: boolean; + hideFocus: boolean; + innerHTML: string; + innerText: string; + isContentEditable: boolean; + lang: string; + offsetHeight: number; + offsetLeft: number; + offsetParent: Element; + offsetTop: number; + offsetWidth: number; + onabort: (ev: Event) => any; + onactivate: (ev: UIEvent) => any; + onbeforeactivate: (ev: UIEvent) => any; + onbeforecopy: (ev: DragEvent) => any; + onbeforecut: (ev: DragEvent) => any; + onbeforedeactivate: (ev: UIEvent) => any; + onbeforepaste: (ev: DragEvent) => any; + onblur: (ev: FocusEvent) => any; + oncanplay: (ev: Event) => any; + oncanplaythrough: (ev: Event) => any; + onchange: (ev: Event) => any; + onclick: (ev: MouseEvent) => any; + oncontextmenu: (ev: PointerEvent) => any; + oncopy: (ev: DragEvent) => any; + oncuechange: (ev: Event) => any; + oncut: (ev: DragEvent) => any; + ondblclick: (ev: MouseEvent) => any; + ondeactivate: (ev: UIEvent) => any; + ondrag: (ev: DragEvent) => any; + ondragend: (ev: DragEvent) => any; + ondragenter: (ev: DragEvent) => any; + ondragleave: (ev: DragEvent) => any; + ondragover: (ev: DragEvent) => any; + ondragstart: (ev: DragEvent) => any; + ondrop: (ev: DragEvent) => any; + ondurationchange: (ev: Event) => any; + onemptied: (ev: Event) => any; + onended: (ev: Event) => any; + onerror: (ev: Event) => any; + onfocus: (ev: FocusEvent) => any; + oninput: (ev: Event) => any; + onkeydown: (ev: KeyboardEvent) => any; + onkeypress: (ev: KeyboardEvent) => any; + onkeyup: (ev: KeyboardEvent) => any; + onload: (ev: Event) => any; + onloadeddata: (ev: Event) => any; + onloadedmetadata: (ev: Event) => any; + onloadstart: (ev: Event) => any; + onmousedown: (ev: MouseEvent) => any; + onmouseenter: (ev: MouseEvent) => any; + onmouseleave: (ev: MouseEvent) => any; + onmousemove: (ev: MouseEvent) => any; + onmouseout: (ev: MouseEvent) => any; + onmouseover: (ev: MouseEvent) => any; + onmouseup: (ev: MouseEvent) => any; + onmousewheel: (ev: MouseWheelEvent) => any; + onmscontentzoom: (ev: UIEvent) => any; + onmsmanipulationstatechanged: (ev: MSManipulationEvent) => any; + onpaste: (ev: DragEvent) => any; + onpause: (ev: Event) => any; + onplay: (ev: Event) => any; + onplaying: (ev: Event) => any; + onprogress: (ev: ProgressEvent) => any; + onratechange: (ev: Event) => any; + onreset: (ev: Event) => any; + onscroll: (ev: UIEvent) => any; + onseeked: (ev: Event) => any; + onseeking: (ev: Event) => any; + onselect: (ev: UIEvent) => any; + onselectstart: (ev: Event) => any; + onstalled: (ev: Event) => any; + onsubmit: (ev: Event) => any; + onsuspend: (ev: Event) => any; + ontimeupdate: (ev: Event) => any; + onvolumechange: (ev: Event) => any; + onwaiting: (ev: Event) => any; + outerHTML: string; + outerText: string; + spellcheck: boolean; + style: CSSStyleDeclaration; + tabIndex: number; + title: string; + blur(): void; + click(): void; + dragDrop(): boolean; + focus(): void; + insertAdjacentElement(position: string, insertedElement: Element): Element; + insertAdjacentHTML(where: string, html: string): void; + insertAdjacentText(where: string, text: string): void; + msGetInputContext(): MSInputMethodContext; + scrollIntoView(top?: boolean): void; + setActive(): void; + addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLElement: { + prototype: HTMLElement; + new(): HTMLElement; +} + +interface HTMLEmbedElement extends HTMLElement, GetSVGDocument { + /** + * Sets or retrieves the height of the object. + */ + height: string; + hidden: any; + /** + * Gets or sets whether the DLNA PlayTo device is available. + */ + msPlayToDisabled: boolean; + /** + * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. + */ + msPlayToPreferredSourceUri: string; + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + /** + * Gets the source associated with the media element for use by the PlayToManager. + */ + msPlayToSource: any; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Retrieves the palette used for the embedded document. + */ + palette: string; + /** + * Retrieves the URL of the plug-in used to view an embedded document. + */ + pluginspage: string; + readyState: string; + /** + * Sets or retrieves a URL to be loaded by the object. + */ + src: string; + /** + * Sets or retrieves the height and width units of the embed object. + */ + units: string; + /** + * Sets or retrieves the width of the object. + */ + width: string; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLEmbedElement: { + prototype: HTMLEmbedElement; + new(): HTMLEmbedElement; +} + +interface HTMLFieldSetElement extends HTMLElement { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + disabled: boolean; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} + +declare var HTMLFieldSetElement: { + prototype: HTMLFieldSetElement; + new(): HTMLFieldSetElement; +} + +interface HTMLFontElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { + /** + * Sets or retrieves the current typeface family. + */ + face: string; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLFontElement: { + prototype: HTMLFontElement; + new(): HTMLFontElement; +} + +interface HTMLFormElement extends HTMLElement { + /** + * Sets or retrieves a list of character encodings for input data that must be accepted by the server processing the form. + */ + acceptCharset: string; + /** + * Sets or retrieves the URL to which the form content is sent for processing. + */ + action: string; + /** + * Specifies whether autocomplete is applied to an editable text field. + */ + autocomplete: string; + /** + * Retrieves a collection, in source order, of all controls in a given form. + */ + elements: HTMLCollection; + /** + * Sets or retrieves the MIME encoding for the form. + */ + encoding: string; + /** + * Sets or retrieves the encoding type for the form. + */ + enctype: string; + /** + * Sets or retrieves the number of objects in a collection. + */ + length: number; + /** + * Sets or retrieves how to send the form data to the server. + */ + method: string; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Designates a form that is not validated when submitted. + */ + noValidate: boolean; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Retrieves a form object or an object from an elements collection. + * @param name Variant of type Number or String that specifies the object or collection to retrieve. If this parameter is a Number, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made. + * @param index Variant of type Number that specifies the zero-based index of the object to retrieve when a collection is returned. + */ + item(name?: any, index?: any): any; + /** + * Retrieves a form object or an object from an elements collection. + */ + namedItem(name: string): any; + /** + * Fires when the user resets a form. + */ + reset(): void; + /** + * Fires when a FORM is about to be submitted. + */ + submit(): void; + [name: string]: any; +} + +declare var HTMLFormElement: { + prototype: HTMLFormElement; + new(): HTMLFormElement; +} + +interface HTMLFrameElement extends HTMLElement, GetSVGDocument { + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Retrieves the document object of the page or frame. + */ + contentDocument: Document; + /** + * Retrieves the object of the specified. + */ + contentWindow: Window; + /** + * Sets or retrieves whether to display a border for the frame. + */ + frameBorder: string; + /** + * Sets or retrieves the amount of additional space between the frames. + */ + frameSpacing: any; + /** + * Sets or retrieves the height of the object. + */ + height: string | number; + /** + * Sets or retrieves a URI to a long description of the object. + */ + longDesc: string; + /** + * Sets or retrieves the top and bottom margin heights before displaying the text in a frame. + */ + marginHeight: string; + /** + * Sets or retrieves the left and right margin widths before displaying the text in a frame. + */ + marginWidth: string; + /** + * Sets or retrieves the frame name. + */ + name: string; + /** + * Sets or retrieves whether the user can resize the frame. + */ + noResize: boolean; + /** + * Raised when the object has been completely received from the server. + */ + onload: (ev: Event) => any; + /** + * Sets or retrieves whether the frame can be scrolled. + */ + scrolling: string; + /** + * Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied. + */ + security: any; + /** + * Sets or retrieves a URL to be loaded by the object. + */ + src: string; + /** + * Sets or retrieves the width of the object. + */ + width: string | number; + addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLFrameElement: { + prototype: HTMLFrameElement; + new(): HTMLFrameElement; +} + +interface HTMLFrameSetElement extends HTMLElement { + border: string; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves the frame widths of the object. + */ + cols: string; + /** + * Sets or retrieves whether to display a border for the frame. + */ + frameBorder: string; + /** + * Sets or retrieves the amount of additional space between the frames. + */ + frameSpacing: any; + name: string; + onafterprint: (ev: Event) => any; + onbeforeprint: (ev: Event) => any; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + /** + * Fires when the object loses the input focus. + */ + onblur: (ev: FocusEvent) => any; + onerror: (ev: Event) => any; + /** + * Fires when the object receives focus. + */ + onfocus: (ev: FocusEvent) => any; + onhashchange: (ev: HashChangeEvent) => any; + onload: (ev: Event) => any; + onmessage: (ev: MessageEvent) => any; + onoffline: (ev: Event) => any; + ononline: (ev: Event) => any; + onorientationchange: (ev: Event) => any; + onpagehide: (ev: PageTransitionEvent) => any; + onpageshow: (ev: PageTransitionEvent) => any; + onresize: (ev: UIEvent) => any; + onstorage: (ev: StorageEvent) => any; + onunload: (ev: Event) => any; + /** + * Sets or retrieves the frame heights of the object. + */ + rows: string; + addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "hashchange", listener: (ev: HashChangeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "orientationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLFrameSetElement: { + prototype: HTMLFrameSetElement; + new(): HTMLFrameSetElement; +} + +interface HTMLHRElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves whether the horizontal rule is drawn with 3-D shading. + */ + noShade: boolean; + /** + * Sets or retrieves the width of the object. + */ + width: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLHRElement: { + prototype: HTMLHRElement; + new(): HTMLHRElement; +} + +interface HTMLHeadElement extends HTMLElement { + profile: string; +} + +declare var HTMLHeadElement: { + prototype: HTMLHeadElement; + new(): HTMLHeadElement; +} + +interface HTMLHeadingElement extends HTMLElement { + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; + clear: string; +} + +declare var HTMLHeadingElement: { + prototype: HTMLHeadingElement; + new(): HTMLHeadingElement; +} + +interface HTMLHtmlElement extends HTMLElement { + /** + * Sets or retrieves the DTD version that governs the current document. + */ + version: string; +} + +declare var HTMLHtmlElement: { + prototype: HTMLHtmlElement; + new(): HTMLHtmlElement; +} + +interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + allowFullscreen: boolean; + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Retrieves the document object of the page or frame. + */ + contentDocument: Document; + /** + * Retrieves the object of the specified. + */ + contentWindow: Window; + /** + * Sets or retrieves whether to display a border for the frame. + */ + frameBorder: string; + /** + * Sets or retrieves the amount of additional space between the frames. + */ + frameSpacing: any; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Sets or retrieves the horizontal margin for the object. + */ + hspace: number; + /** + * Sets or retrieves a URI to a long description of the object. + */ + longDesc: string; + /** + * Sets or retrieves the top and bottom margin heights before displaying the text in a frame. + */ + marginHeight: string; + /** + * Sets or retrieves the left and right margin widths before displaying the text in a frame. + */ + marginWidth: string; + /** + * Sets or retrieves the frame name. + */ + name: string; + /** + * Sets or retrieves whether the user can resize the frame. + */ + noResize: boolean; + /** + * Raised when the object has been completely received from the server. + */ + onload: (ev: Event) => any; + sandbox: DOMSettableTokenList; + /** + * Sets or retrieves whether the frame can be scrolled. + */ + scrolling: string; + /** + * Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied. + */ + security: any; + /** + * Sets or retrieves a URL to be loaded by the object. + */ + src: string; + /** + * Sets or retrieves the vertical margin for the object. + */ + vspace: number; + /** + * Sets or retrieves the width of the object. + */ + width: string; + addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLIFrameElement: { + prototype: HTMLIFrameElement; + new(): HTMLIFrameElement; +} + +interface HTMLImageElement extends HTMLElement { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Retrieves whether the object is fully loaded. + */ + complete: boolean; + crossOrigin: string; + currentSrc: string; + /** + * Sets or retrieves the height of the object. + */ + height: number; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + hspace: number; + /** + * Sets or retrieves whether the image is a server-side image map. + */ + isMap: boolean; + /** + * Sets or retrieves a Uniform Resource Identifier (URI) to a long description of the object. + */ + longDesc: string; + /** + * Gets or sets whether the DLNA PlayTo device is available. + */ + msPlayToDisabled: boolean; + msPlayToPreferredSourceUri: string; + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + /** + * Gets the source associated with the media element for use by the PlayToManager. + */ + msPlayToSource: any; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * The original height of the image resource before sizing. + */ + naturalHeight: number; + /** + * The original width of the image resource before sizing. + */ + naturalWidth: number; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + srcset: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + /** + * Sets or retrieves the vertical margin for the object. + */ + vspace: number; + /** + * Sets or retrieves the width of the object. + */ + width: number; + x: number; + y: number; + msGetAsCastingSource(): any; +} + +declare var HTMLImageElement: { + prototype: HTMLImageElement; + new(): HTMLImageElement; + create(): HTMLImageElement; +} + +interface HTMLInputElement extends HTMLElement { + /** + * Sets or retrieves a comma-separated list of content types. + */ + accept: string; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Specifies whether autocomplete is applied to an editable text field. + */ + autocomplete: string; + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + border: string; + /** + * Sets or retrieves the state of the check box or radio button. + */ + checked: boolean; + /** + * Retrieves whether the object is fully loaded. + */ + complete: boolean; + /** + * Sets or retrieves the state of the check box or radio button. + */ + defaultChecked: boolean; + /** + * Sets or retrieves the initial contents of the object. + */ + defaultValue: string; + disabled: boolean; + /** + * Returns a FileList object on a file type input object. + */ + files: FileList; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Overrides the action attribute (where the data on a form is sent) on the parent form element. + */ + formAction: string; + /** + * Used to override the encoding (formEnctype attribute) specified on the form element. + */ + formEnctype: string; + /** + * Overrides the submit method attribute previously specified on a form element. + */ + formMethod: string; + /** + * Overrides any validation or required attributes on a form or form elements to allow it to be submitted without validation. This can be used to create a "save draft"-type submit option. + */ + formNoValidate: string; + /** + * Overrides the target attribute on a form element. + */ + formTarget: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + hspace: number; + indeterminate: boolean; + /** + * Specifies the ID of a pre-defined datalist of options for an input element. + */ + list: HTMLElement; + /** + * Defines the maximum acceptable value for an input element with type="number".When used with the min and step attributes, lets you control the range and increment (such as only even numbers) that the user can enter into an input field. + */ + max: string; + /** + * Sets or retrieves the maximum number of characters that the user can enter in a text control. + */ + maxLength: number; + /** + * Defines the minimum acceptable value for an input element with type="number". When used with the max and step attributes, lets you control the range and increment (such as even numbers only) that the user can enter into an input field. + */ + min: string; + /** + * Sets or retrieves the Boolean value indicating whether multiple items can be selected from a list. + */ + multiple: boolean; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Gets or sets a string containing a regular expression that the user's input must match. + */ + pattern: string; + /** + * Gets or sets a text string that is displayed in an input field as a hint or prompt to users as the format or type of information they need to enter.The text appears in an input field until the user puts focus on the field. + */ + placeholder: string; + readOnly: boolean; + /** + * When present, marks an element that can't be submitted without a value. + */ + required: boolean; + /** + * Gets or sets the end position or offset of a text selection. + */ + selectionEnd: number; + /** + * Gets or sets the starting position or offset of a text selection. + */ + selectionStart: number; + size: number; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + status: boolean; + /** + * Defines an increment or jump between values that you want to allow the user to enter. When used with the max and min attributes, lets you control the range and increment (for example, allow only even numbers) that the user can enter into an input field. + */ + step: string; + /** + * Returns the content type of the object. + */ + type: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Returns the value of the data at the cursor's current position. + */ + value: string; + valueAsDate: Date; + /** + * Returns the input field value as a number. + */ + valueAsNumber: number; + /** + * Sets or retrieves the vertical margin for the object. + */ + vspace: number; + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Creates a TextRange object for the element. + */ + createTextRange(): TextRange; + /** + * Makes the selection equal to the current object. + */ + select(): void; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; + /** + * Sets the start and end positions of a selection in a text field. + * @param start The offset into the text field for the start of the selection. + * @param end The offset into the text field for the end of the selection. + */ + setSelectionRange(start: number, end: number): void; + /** + * Decrements a range input control's value by the value given by the Step attribute. If the optional parameter is used, it will decrement the input control's step value multiplied by the parameter's value. + * @param n Value to decrement the value by. + */ + stepDown(n?: number): void; + /** + * Increments a range input control's value by the value given by the Step attribute. If the optional parameter is used, will increment the input control's value by that value. + * @param n Value to increment the value by. + */ + stepUp(n?: number): void; +} + +declare var HTMLInputElement: { + prototype: HTMLInputElement; + new(): HTMLInputElement; +} + +interface HTMLIsIndexElement extends HTMLElement { + /** + * Sets or retrieves the URL to which the form content is sent for processing. + */ + action: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + prompt: string; +} + +declare var HTMLIsIndexElement: { + prototype: HTMLIsIndexElement; + new(): HTMLIsIndexElement; +} + +interface HTMLLIElement extends HTMLElement { + type: string; + /** + * Sets or retrieves the value of a list item. + */ + value: number; +} + +declare var HTMLLIElement: { + prototype: HTMLLIElement; + new(): HTMLLIElement; +} + +interface HTMLLabelElement extends HTMLElement { + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the object to which the given label object is assigned. + */ + htmlFor: string; +} + +declare var HTMLLabelElement: { + prototype: HTMLLabelElement; + new(): HTMLLabelElement; +} + +interface HTMLLegendElement extends HTMLElement { + /** + * Retrieves a reference to the form that the object is embedded in. + */ + align: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; +} + +declare var HTMLLegendElement: { + prototype: HTMLLegendElement; + new(): HTMLLegendElement; +} + +interface HTMLLinkElement extends HTMLElement, LinkStyle { + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; + disabled: boolean; + /** + * Sets or retrieves a destination URL or an anchor point. + */ + href: string; + /** + * Sets or retrieves the language code of the object. + */ + hreflang: string; + /** + * Sets or retrieves the media type. + */ + media: string; + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rel: string; + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rev: string; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Sets or retrieves the MIME type of the object. + */ + type: string; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLLinkElement: { + prototype: HTMLLinkElement; + new(): HTMLLinkElement; +} + +interface HTMLMapElement extends HTMLElement { + /** + * Retrieves a collection of the area objects defined for the given map object. + */ + areas: HTMLAreasCollection; + /** + * Sets or retrieves the name of the object. + */ + name: string; +} + +declare var HTMLMapElement: { + prototype: HTMLMapElement; + new(): HTMLMapElement; +} + +interface HTMLMarqueeElement extends HTMLElement { + behavior: string; + bgColor: any; + direction: string; + height: string; + hspace: number; + loop: number; + onbounce: (ev: Event) => any; + onfinish: (ev: Event) => any; + onstart: (ev: Event) => any; + scrollAmount: number; + scrollDelay: number; + trueSpeed: boolean; + vspace: number; + width: string; + start(): void; + stop(): void; + addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "bounce", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "finish", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "start", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLMarqueeElement: { + prototype: HTMLMarqueeElement; + new(): HTMLMarqueeElement; +} + +interface HTMLMediaElement extends HTMLElement { + /** + * Returns an AudioTrackList object with the audio tracks for a given video element. + */ + audioTracks: AudioTrackList; + /** + * Gets or sets a value that indicates whether to start playing the media automatically. + */ + autoplay: boolean; + /** + * Gets a collection of buffered time ranges. + */ + buffered: TimeRanges; + /** + * Gets or sets a flag that indicates whether the client provides a set of controls for the media (in case the developer does not include controls for the player). + */ + controls: boolean; + /** + * Gets the address or URL of the current media resource that is selected by IHTMLMediaElement. + */ + currentSrc: string; + /** + * Gets or sets the current playback position, in seconds. + */ + currentTime: number; + defaultMuted: boolean; + /** + * Gets or sets the default playback rate when the user is not using fast forward or reverse for a video or audio resource. + */ + defaultPlaybackRate: number; + /** + * Returns the duration in seconds of the current media resource. A NaN value is returned if duration is not available, or Infinity if the media resource is streaming. + */ + duration: number; + /** + * Gets information about whether the playback has ended or not. + */ + ended: boolean; + /** + * Returns an object representing the current error state of the audio or video element. + */ + error: MediaError; + /** + * Gets or sets a flag to specify whether playback should restart after it completes. + */ + loop: boolean; + /** + * Specifies the purpose of the audio or video media, such as background audio or alerts. + */ + msAudioCategory: string; + /** + * Specifies the output device id that the audio will be sent to. + */ + msAudioDeviceType: string; + msGraphicsTrustStatus: MSGraphicsTrust; + /** + * Gets the MSMediaKeys object, which is used for decrypting media data, that is associated with this media element. + */ + msKeys: MSMediaKeys; + /** + * Gets or sets whether the DLNA PlayTo device is available. + */ + msPlayToDisabled: boolean; + /** + * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. + */ + msPlayToPreferredSourceUri: string; + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + /** + * Gets the source associated with the media element for use by the PlayToManager. + */ + msPlayToSource: any; + /** + * Specifies whether or not to enable low-latency playback on the media element. + */ + msRealTime: boolean; + /** + * Gets or sets a flag that indicates whether the audio (either audio or the audio track on video media) is muted. + */ + muted: boolean; + /** + * Gets the current network activity for the element. + */ + networkState: number; + onmsneedkey: (ev: MSMediaKeyNeededEvent) => any; + /** + * Gets a flag that specifies whether playback is paused. + */ + paused: boolean; + /** + * Gets or sets the current rate of speed for the media resource to play. This speed is expressed as a multiple of the normal speed of the media resource. + */ + playbackRate: number; + /** + * Gets TimeRanges for the current media resource that has been played. + */ + played: TimeRanges; + /** + * Gets or sets the current playback position, in seconds. + */ + preload: string; + readyState: number; + /** + * Returns a TimeRanges object that represents the ranges of the current media resource that can be seeked. + */ + seekable: TimeRanges; + /** + * Gets a flag that indicates whether the the client is currently moving to a new playback position in the media resource. + */ + seeking: boolean; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + textTracks: TextTrackList; + videoTracks: VideoTrackList; + /** + * Gets or sets the volume level for audio portions of the media element. + */ + volume: number; + addTextTrack(kind: string, label?: string, language?: string): TextTrack; + /** + * Returns a string that specifies whether the client can play a given media resource type. + */ + canPlayType(type: string): string; + /** + * Fires immediately after the client loads the object. + */ + load(): void; + /** + * Clears all effects from the media pipeline. + */ + msClearEffects(): void; + msGetAsCastingSource(): any; + /** + * Inserts the specified audio effect into media pipeline. + */ + msInsertAudioEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; + msSetMediaKeys(mediaKeys: MSMediaKeys): void; + /** + * Specifies the media protection manager for a given media pipeline. + */ + msSetMediaProtectionManager(mediaProtectionManager?: any): void; + /** + * Pauses the current playback and sets paused to TRUE. This can be used to test whether the media is playing or paused. You can also use the pause or play events to tell whether the media is playing or not. + */ + pause(): void; + /** + * Loads and starts playback of a media resource. + */ + play(): void; + HAVE_CURRENT_DATA: number; + HAVE_ENOUGH_DATA: number; + HAVE_FUTURE_DATA: number; + HAVE_METADATA: number; + HAVE_NOTHING: number; + NETWORK_EMPTY: number; + NETWORK_IDLE: number; + NETWORK_LOADING: number; + NETWORK_NO_SOURCE: number; + addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "msneedkey", listener: (ev: MSMediaKeyNeededEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLMediaElement: { + prototype: HTMLMediaElement; + new(): HTMLMediaElement; + HAVE_CURRENT_DATA: number; + HAVE_ENOUGH_DATA: number; + HAVE_FUTURE_DATA: number; + HAVE_METADATA: number; + HAVE_NOTHING: number; + NETWORK_EMPTY: number; + NETWORK_IDLE: number; + NETWORK_LOADING: number; + NETWORK_NO_SOURCE: number; +} + +interface HTMLMenuElement extends HTMLElement { + compact: boolean; + type: string; +} + +declare var HTMLMenuElement: { + prototype: HTMLMenuElement; + new(): HTMLMenuElement; +} + +interface HTMLMetaElement extends HTMLElement { + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; + /** + * Gets or sets meta-information to associate with httpEquiv or name. + */ + content: string; + /** + * Gets or sets information used to bind the value of a content attribute of a meta element to an HTTP response header. + */ + httpEquiv: string; + /** + * Sets or retrieves the value specified in the content attribute of the meta object. + */ + name: string; + /** + * Sets or retrieves a scheme to be used in interpreting the value of a property specified for the object. + */ + scheme: string; + /** + * Sets or retrieves the URL property that will be loaded after the specified time has elapsed. + */ + url: string; +} + +declare var HTMLMetaElement: { + prototype: HTMLMetaElement; + new(): HTMLMetaElement; +} + +interface HTMLModElement extends HTMLElement { + /** + * Sets or retrieves reference information about the object. + */ + cite: string; + /** + * Sets or retrieves the date and time of a modification to the object. + */ + dateTime: string; +} + +declare var HTMLModElement: { + prototype: HTMLModElement; + new(): HTMLModElement; +} + +interface HTMLNextIdElement extends HTMLElement { + n: string; +} + +declare var HTMLNextIdElement: { + prototype: HTMLNextIdElement; + new(): HTMLNextIdElement; +} + +interface HTMLOListElement extends HTMLElement { + compact: boolean; + /** + * The starting number. + */ + start: number; + type: string; +} + +declare var HTMLOListElement: { + prototype: HTMLOListElement; + new(): HTMLOListElement; +} + +interface HTMLObjectElement extends HTMLElement, GetSVGDocument { + /** + * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. + */ + BaseHref: string; + align: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Gets or sets the optional alternative HTML script to execute if the object fails to load. + */ + altHtml: string; + /** + * Sets or retrieves a character string that can be used to implement your own archive functionality for the object. + */ + archive: string; + border: string; + /** + * Sets or retrieves the URL of the file containing the compiled Java class. + */ + code: string; + /** + * Sets or retrieves the URL of the component. + */ + codeBase: string; + /** + * Sets or retrieves the Internet media type for the code associated with the object. + */ + codeType: string; + /** + * Retrieves the document object of the page or frame. + */ + contentDocument: Document; + /** + * Sets or retrieves the URL that references the data of the object. + */ + data: string; + declare: boolean; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the height of the object. + */ + height: string; + hspace: number; + /** + * Gets or sets whether the DLNA PlayTo device is available. + */ + msPlayToDisabled: boolean; + /** + * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. + */ + msPlayToPreferredSourceUri: string; + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + /** + * Gets the source associated with the media element for use by the PlayToManager. + */ + msPlayToSource: any; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Retrieves the contained object. + */ + object: any; + readyState: number; + /** + * Sets or retrieves a message to be displayed while an object is loading. + */ + standby: string; + /** + * Sets or retrieves the MIME type of the object. + */ + type: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + vspace: number; + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLObjectElement: { + prototype: HTMLObjectElement; + new(): HTMLObjectElement; +} + +interface HTMLOptGroupElement extends HTMLElement { + /** + * Sets or retrieves the status of an option. + */ + defaultSelected: boolean; + disabled: boolean; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the ordinal position of an option in a list box. + */ + index: number; + /** + * Sets or retrieves a value that you can use to implement your own label functionality for the object. + */ + label: string; + /** + * Sets or retrieves whether the option in the list box is the default item. + */ + selected: boolean; + /** + * Sets or retrieves the text string specified by the option tag. + */ + text: string; + /** + * Sets or retrieves the value which is returned to the server when the form control is submitted. + */ + value: string; +} + +declare var HTMLOptGroupElement: { + prototype: HTMLOptGroupElement; + new(): HTMLOptGroupElement; +} + +interface HTMLOptionElement extends HTMLElement { + /** + * Sets or retrieves the status of an option. + */ + defaultSelected: boolean; + disabled: boolean; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the ordinal position of an option in a list box. + */ + index: number; + /** + * Sets or retrieves a value that you can use to implement your own label functionality for the object. + */ + label: string; + /** + * Sets or retrieves whether the option in the list box is the default item. + */ + selected: boolean; + /** + * Sets or retrieves the text string specified by the option tag. + */ + text: string; + /** + * Sets or retrieves the value which is returned to the server when the form control is submitted. + */ + value: string; +} + +declare var HTMLOptionElement: { + prototype: HTMLOptionElement; + new(): HTMLOptionElement; + create(): HTMLOptionElement; +} + +interface HTMLParagraphElement extends HTMLElement { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + clear: string; +} + +declare var HTMLParagraphElement: { + prototype: HTMLParagraphElement; + new(): HTMLParagraphElement; +} + +interface HTMLParamElement extends HTMLElement { + /** + * Sets or retrieves the name of an input parameter for an element. + */ + name: string; + /** + * Sets or retrieves the content type of the resource designated by the value attribute. + */ + type: string; + /** + * Sets or retrieves the value of an input parameter for an element. + */ + value: string; + /** + * Sets or retrieves the data type of the value attribute. + */ + valueType: string; +} + +declare var HTMLParamElement: { + prototype: HTMLParamElement; + new(): HTMLParamElement; +} + +interface HTMLPhraseElement extends HTMLElement { + /** + * Sets or retrieves reference information about the object. + */ + cite: string; + /** + * Sets or retrieves the date and time of a modification to the object. + */ + dateTime: string; +} + +declare var HTMLPhraseElement: { + prototype: HTMLPhraseElement; + new(): HTMLPhraseElement; +} + +interface HTMLPreElement extends HTMLElement { + /** + * Indicates a citation by rendering text in italic type. + */ + cite: string; + clear: string; + /** + * Sets or gets a value that you can use to implement your own width functionality for the object. + */ + width: number; +} + +declare var HTMLPreElement: { + prototype: HTMLPreElement; + new(): HTMLPreElement; +} + +interface HTMLProgressElement extends HTMLElement { + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Defines the maximum, or "done" value for a progress element. + */ + max: number; + /** + * Returns the quotient of value/max when the value attribute is set (determinate progress bar), or -1 when the value attribute is missing (indeterminate progress bar). + */ + position: number; + /** + * Sets or gets the current value of a progress element. The value must be a non-negative number between 0 and the max value. + */ + value: number; +} + +declare var HTMLProgressElement: { + prototype: HTMLProgressElement; + new(): HTMLProgressElement; +} + +interface HTMLQuoteElement extends HTMLElement { + /** + * Sets or retrieves reference information about the object. + */ + cite: string; + /** + * Sets or retrieves the date and time of a modification to the object. + */ + dateTime: string; +} + +declare var HTMLQuoteElement: { + prototype: HTMLQuoteElement; + new(): HTMLQuoteElement; +} + +interface HTMLScriptElement extends HTMLElement { + async: boolean; + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; + /** + * Sets or retrieves the status of the script. + */ + defer: boolean; + /** + * Sets or retrieves the event for which the script is written. + */ + event: string; + /** + * Sets or retrieves the object that is bound to the event script. + */ + htmlFor: string; + /** + * Retrieves the URL to an external file that contains the source code or data. + */ + src: string; + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; + /** + * Sets or retrieves the MIME type for the associated scripting engine. + */ + type: string; +} + +declare var HTMLScriptElement: { + prototype: HTMLScriptElement; + new(): HTMLScriptElement; +} + +interface HTMLSelectElement extends HTMLElement { + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + disabled: boolean; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the number of objects in a collection. + */ + length: number; + /** + * Sets or retrieves the Boolean value indicating whether multiple items can be selected from a list. + */ + multiple: boolean; + /** + * Sets or retrieves the name of the object. + */ + name: string; + options: HTMLCollection; + /** + * When present, marks an element that can't be submitted without a value. + */ + required: boolean; + /** + * Sets or retrieves the index of the selected option in a select object. + */ + selectedIndex: number; + /** + * Sets or retrieves the number of rows in the list box. + */ + size: number; + /** + * Retrieves the type of select control based on the value of the MULTIPLE attribute. + */ + type: string; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Sets or retrieves the value which is returned to the server when the form control is submitted. + */ + value: string; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + selectedOptions: HTMLCollection; + /** + * Adds an element to the areas, controlRange, or options collection. + * @param element Variant of type Number that specifies the index position in the collection where the element is placed. If no value is given, the method places the element at the end of the collection. + * @param before Variant of type Object that specifies an element to insert before, or null to append the object to the collection. + */ + add(element: HTMLElement, before?: HTMLElement | number): void; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Retrieves a select object or an object from an options collection. + * @param name Variant of type Number or String that specifies the object or collection to retrieve. If this parameter is an integer, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made. + * @param index Variant of type Number that specifies the zero-based index of the object to retrieve when a collection is returned. + */ + item(name?: any, index?: any): any; + /** + * Retrieves a select object or an object from an options collection. + * @param namedItem A String that specifies the name or id property of the object to retrieve. A collection is returned if more than one match is made. + */ + namedItem(name: string): any; + /** + * Removes an element from the collection. + * @param index Number that specifies the zero-based index of the element to remove from the collection. + */ + remove(index?: number): void; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; + [name: string]: any; +} + +declare var HTMLSelectElement: { + prototype: HTMLSelectElement; + new(): HTMLSelectElement; +} + +interface HTMLSourceElement extends HTMLElement { + /** + * Gets or sets the intended media type of the media source. + */ + media: string; + msKeySystem: string; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + /** + * Gets or sets the MIME type of a media resource. + */ + type: string; +} + +declare var HTMLSourceElement: { + prototype: HTMLSourceElement; + new(): HTMLSourceElement; +} + +interface HTMLSpanElement extends HTMLElement { +} + +declare var HTMLSpanElement: { + prototype: HTMLSpanElement; + new(): HTMLSpanElement; +} + +interface HTMLStyleElement extends HTMLElement, LinkStyle { + /** + * Sets or retrieves the media type. + */ + media: string; + /** + * Retrieves the CSS language in which the style sheet is written. + */ + type: string; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLStyleElement: { + prototype: HTMLStyleElement; + new(): HTMLStyleElement; +} + +interface HTMLTableCaptionElement extends HTMLElement { + /** + * Sets or retrieves the alignment of the caption or legend. + */ + align: string; + /** + * Sets or retrieves whether the caption appears at the top or bottom of the table. + */ + vAlign: string; +} + +declare var HTMLTableCaptionElement: { + prototype: HTMLTableCaptionElement; + new(): HTMLTableCaptionElement; +} + +interface HTMLTableCellElement extends HTMLElement, HTMLTableAlignment { + /** + * Sets or retrieves abbreviated text for the object. + */ + abbr: string; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves a comma-delimited list of conceptual categories associated with the object. + */ + axis: string; + bgColor: any; + /** + * Retrieves the position of the object in the cells collection of a row. + */ + cellIndex: number; + /** + * Sets or retrieves the number columns in the table that the object should span. + */ + colSpan: number; + /** + * Sets or retrieves a list of header cells that provide information for the object. + */ + headers: string; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; + /** + * Sets or retrieves how many rows in a table the cell should span. + */ + rowSpan: number; + /** + * Sets or retrieves the group of cells in a table to which the object's information applies. + */ + scope: string; + /** + * Sets or retrieves the width of the object. + */ + width: string; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTableCellElement: { + prototype: HTMLTableCellElement; + new(): HTMLTableCellElement; +} + +interface HTMLTableColElement extends HTMLElement, HTMLTableAlignment { + /** + * Sets or retrieves the alignment of the object relative to the display or table. + */ + align: string; + /** + * Sets or retrieves the number of columns in the group. + */ + span: number; + /** + * Sets or retrieves the width of the object. + */ + width: any; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTableColElement: { + prototype: HTMLTableColElement; + new(): HTMLTableColElement; +} + +interface HTMLTableDataCellElement extends HTMLTableCellElement { +} + +declare var HTMLTableDataCellElement: { + prototype: HTMLTableDataCellElement; + new(): HTMLTableDataCellElement; +} + +interface HTMLTableElement extends HTMLElement { + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; + bgColor: any; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + border: string; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Retrieves the caption object of a table. + */ + caption: HTMLTableCaptionElement; + /** + * Sets or retrieves the amount of space between the border of the cell and the content of the cell. + */ + cellPadding: string; + /** + * Sets or retrieves the amount of space between cells in a table. + */ + cellSpacing: string; + /** + * Sets or retrieves the number of columns in the table. + */ + cols: number; + /** + * Sets or retrieves the way the border frame around the table is displayed. + */ + frame: string; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Sets or retrieves the number of horizontal rows contained in the object. + */ + rows: HTMLCollection; + /** + * Sets or retrieves which dividing lines (inner borders) are displayed. + */ + rules: string; + /** + * Sets or retrieves a description and/or structure of the object. + */ + summary: string; + /** + * Retrieves a collection of all tBody objects in the table. Objects in this collection are in source order. + */ + tBodies: HTMLCollection; + /** + * Retrieves the tFoot object of the table. + */ + tFoot: HTMLTableSectionElement; + /** + * Retrieves the tHead object of the table. + */ + tHead: HTMLTableSectionElement; + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Creates an empty caption element in the table. + */ + createCaption(): HTMLTableCaptionElement; + /** + * Creates an empty tBody element in the table. + */ + createTBody(): HTMLTableSectionElement; + /** + * Creates an empty tFoot element in the table. + */ + createTFoot(): HTMLTableSectionElement; + /** + * Returns the tHead element object if successful, or null otherwise. + */ + createTHead(): HTMLTableSectionElement; + /** + * Deletes the caption element and its contents from the table. + */ + deleteCaption(): void; + /** + * Removes the specified row (tr) from the element and from the rows collection. + * @param index Number that specifies the zero-based position in the rows collection of the row to remove. + */ + deleteRow(index?: number): void; + /** + * Deletes the tFoot element and its contents from the table. + */ + deleteTFoot(): void; + /** + * Deletes the tHead element and its contents from the table. + */ + deleteTHead(): void; + /** + * Creates a new row (tr) in the table, and adds the row to the rows collection. + * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. + */ + insertRow(index?: number): HTMLTableRowElement; +} + +declare var HTMLTableElement: { + prototype: HTMLTableElement; + new(): HTMLTableElement; +} + +interface HTMLTableHeaderCellElement extends HTMLTableCellElement { + /** + * Sets or retrieves the group of cells in a table to which the object's information applies. + */ + scope: string; +} + +declare var HTMLTableHeaderCellElement: { + prototype: HTMLTableHeaderCellElement; + new(): HTMLTableHeaderCellElement; +} + +interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + bgColor: any; + /** + * Retrieves a collection of all cells in the table row. + */ + cells: HTMLCollection; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Retrieves the position of the object in the rows collection for the table. + */ + rowIndex: number; + /** + * Retrieves the position of the object in the collection. + */ + sectionRowIndex: number; + /** + * Removes the specified cell from the table row, as well as from the cells collection. + * @param index Number that specifies the zero-based position of the cell to remove from the table row. If no value is provided, the last cell in the cells collection is deleted. + */ + deleteCell(index?: number): void; + /** + * Creates a new cell in the table row, and adds the cell to the cells collection. + * @param index Number that specifies where to insert the cell in the tr. The default value is -1, which appends the new cell to the end of the cells collection. + */ + insertCell(index?: number): HTMLTableCellElement; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTableRowElement: { + prototype: HTMLTableRowElement; + new(): HTMLTableRowElement; +} + +interface HTMLTableSectionElement extends HTMLElement, HTMLTableAlignment { + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; + /** + * Sets or retrieves the number of horizontal rows contained in the object. + */ + rows: HTMLCollection; + /** + * Removes the specified row (tr) from the element and from the rows collection. + * @param index Number that specifies the zero-based position in the rows collection of the row to remove. + */ + deleteRow(index?: number): void; + /** + * Creates a new row (tr) in the table, and adds the row to the rows collection. + * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. + */ + insertRow(index?: number): HTMLTableRowElement; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTableSectionElement: { + prototype: HTMLTableSectionElement; + new(): HTMLTableSectionElement; +} + +interface HTMLTextAreaElement extends HTMLElement { + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + /** + * Sets or retrieves the width of the object. + */ + cols: number; + /** + * Sets or retrieves the initial contents of the object. + */ + defaultValue: string; + disabled: boolean; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the maximum number of characters that the user can enter in a text control. + */ + maxLength: number; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Gets or sets a text string that is displayed in an input field as a hint or prompt to users as the format or type of information they need to enter.The text appears in an input field until the user puts focus on the field. + */ + placeholder: string; + /** + * Sets or retrieves the value indicated whether the content of the object is read-only. + */ + readOnly: boolean; + /** + * When present, marks an element that can't be submitted without a value. + */ + required: boolean; + /** + * Sets or retrieves the number of horizontal rows contained in the object. + */ + rows: number; + /** + * Gets or sets the end position or offset of a text selection. + */ + selectionEnd: number; + /** + * Gets or sets the starting position or offset of a text selection. + */ + selectionStart: number; + /** + * Sets or retrieves the value indicating whether the control is selected. + */ + status: any; + /** + * Retrieves the type of control. + */ + type: string; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Retrieves or sets the text in the entry field of the textArea element. + */ + value: string; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Sets or retrieves how to handle wordwrapping in the object. + */ + wrap: string; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Creates a TextRange object for the element. + */ + createTextRange(): TextRange; + /** + * Highlights the input area of a form element. + */ + select(): void; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; + /** + * Sets the start and end positions of a selection in a text field. + * @param start The offset into the text field for the start of the selection. + * @param end The offset into the text field for the end of the selection. + */ + setSelectionRange(start: number, end: number): void; +} + +declare var HTMLTextAreaElement: { + prototype: HTMLTextAreaElement; + new(): HTMLTextAreaElement; +} + +interface HTMLTitleElement extends HTMLElement { + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; +} + +declare var HTMLTitleElement: { + prototype: HTMLTitleElement; + new(): HTMLTitleElement; +} + +interface HTMLTrackElement extends HTMLElement { + default: boolean; + kind: string; + label: string; + readyState: number; + src: string; + srclang: string; + track: TextTrack; + ERROR: number; + LOADED: number; + LOADING: number; + NONE: number; +} + +declare var HTMLTrackElement: { + prototype: HTMLTrackElement; + new(): HTMLTrackElement; + ERROR: number; + LOADED: number; + LOADING: number; + NONE: number; +} + +interface HTMLUListElement extends HTMLElement { + compact: boolean; + type: string; +} + +declare var HTMLUListElement: { + prototype: HTMLUListElement; + new(): HTMLUListElement; +} + +interface HTMLUnknownElement extends HTMLElement { +} + +declare var HTMLUnknownElement: { + prototype: HTMLUnknownElement; + new(): HTMLUnknownElement; +} + +interface HTMLVideoElement extends HTMLMediaElement { + /** + * Gets or sets the height of the video element. + */ + height: number; + msHorizontalMirror: boolean; + msIsLayoutOptimalForPlayback: boolean; + msIsStereo3D: boolean; + msStereo3DPackingMode: string; + msStereo3DRenderMode: string; + msZoom: boolean; + onMSVideoFormatChanged: (ev: Event) => any; + onMSVideoFrameStepCompleted: (ev: Event) => any; + onMSVideoOptimalLayoutChanged: (ev: Event) => any; + /** + * Gets or sets a URL of an image to display, for example, like a movie poster. This can be a still frame from the video, or another image if no video data is available. + */ + poster: string; + /** + * Gets the intrinsic height of a video in CSS pixels, or zero if the dimensions are not known. + */ + videoHeight: number; + /** + * Gets the intrinsic width of a video in CSS pixels, or zero if the dimensions are not known. + */ + videoWidth: number; + webkitDisplayingFullscreen: boolean; + webkitSupportsFullscreen: boolean; + /** + * Gets or sets the width of the video element. + */ + width: number; + getVideoPlaybackQuality(): VideoPlaybackQuality; + msFrameStep(forward: boolean): void; + msInsertVideoEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; + msSetVideoRectangle(left: number, top: number, right: number, bottom: number): void; + webkitEnterFullScreen(): void; + webkitEnterFullscreen(): void; + webkitExitFullScreen(): void; + webkitExitFullscreen(): void; + addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSVideoFormatChanged", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "MSVideoFrameStepCompleted", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "MSVideoOptimalLayoutChanged", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "msneedkey", listener: (ev: MSMediaKeyNeededEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLVideoElement: { + prototype: HTMLVideoElement; + new(): HTMLVideoElement; +} + +interface HashChangeEvent extends Event { + newURL: string; + oldURL: string; +} + +declare var HashChangeEvent: { + prototype: HashChangeEvent; + new(type: string, eventInitDict?: HashChangeEventInit): HashChangeEvent; +} + +interface History { + length: number; + state: any; + back(distance?: any): void; + forward(distance?: any): void; + go(delta?: any): void; + pushState(statedata: any, title?: string, url?: string): void; + replaceState(statedata: any, title?: string, url?: string): void; +} + +declare var History: { + prototype: History; + new(): History; +} + +interface IDBCursor { + direction: string; + key: any; + primaryKey: any; + source: IDBObjectStore | IDBIndex; + advance(count: number): void; + continue(key?: any): void; + delete(): IDBRequest; + update(value: any): IDBRequest; + NEXT: string; + NEXT_NO_DUPLICATE: string; + PREV: string; + PREV_NO_DUPLICATE: string; +} + +declare var IDBCursor: { + prototype: IDBCursor; + new(): IDBCursor; + NEXT: string; + NEXT_NO_DUPLICATE: string; + PREV: string; + PREV_NO_DUPLICATE: string; +} + +interface IDBCursorWithValue extends IDBCursor { + value: any; +} + +declare var IDBCursorWithValue: { + prototype: IDBCursorWithValue; + new(): IDBCursorWithValue; +} + +interface IDBDatabase extends EventTarget { + name: string; + objectStoreNames: DOMStringList; + onabort: (ev: Event) => any; + onerror: (ev: Event) => any; + version: number; + close(): void; + createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore; + deleteObjectStore(name: string): void; + transaction(storeNames: string | string[], mode?: string): IDBTransaction; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var IDBDatabase: { + prototype: IDBDatabase; + new(): IDBDatabase; +} + +interface IDBFactory { + cmp(first: any, second: any): number; + deleteDatabase(name: string): IDBOpenDBRequest; + open(name: string, version?: number): IDBOpenDBRequest; +} + +declare var IDBFactory: { + prototype: IDBFactory; + new(): IDBFactory; +} + +interface IDBIndex { + keyPath: string | string[]; + name: string; + objectStore: IDBObjectStore; + unique: boolean; + multiEntry: boolean; + count(key?: any): IDBRequest; + get(key: any): IDBRequest; + getKey(key: any): IDBRequest; + openCursor(range?: IDBKeyRange, direction?: string): IDBRequest; + openKeyCursor(range?: IDBKeyRange, direction?: string): IDBRequest; +} + +declare var IDBIndex: { + prototype: IDBIndex; + new(): IDBIndex; +} + +interface IDBKeyRange { + lower: any; + lowerOpen: boolean; + upper: any; + upperOpen: boolean; +} + +declare var IDBKeyRange: { + prototype: IDBKeyRange; + new(): IDBKeyRange; + bound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange; + lowerBound(bound: any, open?: boolean): IDBKeyRange; + only(value: any): IDBKeyRange; + upperBound(bound: any, open?: boolean): IDBKeyRange; +} + +interface IDBObjectStore { + indexNames: DOMStringList; + keyPath: string | string[]; + name: string; + transaction: IDBTransaction; + autoIncrement: boolean; + add(value: any, key?: any): IDBRequest; + clear(): IDBRequest; + count(key?: any): IDBRequest; + createIndex(name: string, keyPath: string | string[], optionalParameters?: IDBIndexParameters): IDBIndex; + delete(key: any): IDBRequest; + deleteIndex(indexName: string): void; + get(key: any): IDBRequest; + index(name: string): IDBIndex; + openCursor(range?: any, direction?: string): IDBRequest; + put(value: any, key?: any): IDBRequest; +} + +declare var IDBObjectStore: { + prototype: IDBObjectStore; + new(): IDBObjectStore; +} + +interface IDBOpenDBRequest extends IDBRequest { + onblocked: (ev: Event) => any; + onupgradeneeded: (ev: IDBVersionChangeEvent) => any; + addEventListener(type: "blocked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "upgradeneeded", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var IDBOpenDBRequest: { + prototype: IDBOpenDBRequest; + new(): IDBOpenDBRequest; +} + +interface IDBRequest extends EventTarget { + error: DOMError; + onerror: (ev: Event) => any; + onsuccess: (ev: Event) => any; + readyState: string; + result: any; + source: IDBObjectStore | IDBIndex | IDBCursor; + transaction: IDBTransaction; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var IDBRequest: { + prototype: IDBRequest; + new(): IDBRequest; +} + +interface IDBTransaction extends EventTarget { + db: IDBDatabase; + error: DOMError; + mode: string; + onabort: (ev: Event) => any; + oncomplete: (ev: Event) => any; + onerror: (ev: Event) => any; + abort(): void; + objectStore(name: string): IDBObjectStore; + READ_ONLY: string; + READ_WRITE: string; + VERSION_CHANGE: string; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var IDBTransaction: { + prototype: IDBTransaction; + new(): IDBTransaction; + READ_ONLY: string; + READ_WRITE: string; + VERSION_CHANGE: string; +} + +interface IDBVersionChangeEvent extends Event { + newVersion: number; + oldVersion: number; +} + +declare var IDBVersionChangeEvent: { + prototype: IDBVersionChangeEvent; + new(): IDBVersionChangeEvent; +} + +interface ImageData { + data: Uint8ClampedArray; + height: number; + width: number; +} + +declare var ImageData: { + prototype: ImageData; + new(width: number, height: number): ImageData; + new(array: Uint8ClampedArray, width: number, height: number): ImageData; +} + +interface KeyboardEvent extends UIEvent { + altKey: boolean; + char: string; + charCode: number; + ctrlKey: boolean; + key: string; + keyCode: number; + locale: string; + location: number; + metaKey: boolean; + repeat: boolean; + shiftKey: boolean; + which: number; + getModifierState(keyArg: string): boolean; + initKeyboardEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, keyArg: string, locationArg: number, modifiersListArg: string, repeat: boolean, locale: string): void; + DOM_KEY_LOCATION_JOYSTICK: number; + DOM_KEY_LOCATION_LEFT: number; + DOM_KEY_LOCATION_MOBILE: number; + DOM_KEY_LOCATION_NUMPAD: number; + DOM_KEY_LOCATION_RIGHT: number; + DOM_KEY_LOCATION_STANDARD: number; +} + +declare var KeyboardEvent: { + prototype: KeyboardEvent; + new(typeArg: string, eventInitDict?: KeyboardEventInit): KeyboardEvent; + DOM_KEY_LOCATION_JOYSTICK: number; + DOM_KEY_LOCATION_LEFT: number; + DOM_KEY_LOCATION_MOBILE: number; + DOM_KEY_LOCATION_NUMPAD: number; + DOM_KEY_LOCATION_RIGHT: number; + DOM_KEY_LOCATION_STANDARD: number; +} + +interface Location { + hash: string; + host: string; + hostname: string; + href: string; + origin: string; + pathname: string; + port: string; + protocol: string; + search: string; + assign(url: string): void; + reload(forcedReload?: boolean): void; + replace(url: string): void; + toString(): string; +} + +declare var Location: { + prototype: Location; + new(): Location; +} + +interface LongRunningScriptDetectedEvent extends Event { + executionTime: number; + stopPageScriptExecution: boolean; +} + +declare var LongRunningScriptDetectedEvent: { + prototype: LongRunningScriptDetectedEvent; + new(): LongRunningScriptDetectedEvent; +} + +interface MSApp { + clearTemporaryWebDataAsync(): MSAppAsyncOperation; + createBlobFromRandomAccessStream(type: string, seeker: any): Blob; + createDataPackage(object: any): any; + createDataPackageFromSelection(): any; + createFileFromStorageFile(storageFile: any): File; + createStreamFromInputStream(type: string, inputStream: any): MSStream; + execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; + execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; + getCurrentPriority(): string; + getHtmlPrintDocumentSourceAsync(htmlDoc: any): any; + getViewId(view: any): any; + isTaskScheduledAtPriorityOrHigher(priority: string): boolean; + pageHandlesAllApplicationActivations(enabled: boolean): void; + suppressSubdownloadCredentialPrompts(suppress: boolean): void; + terminateApp(exceptionObject: any): void; + CURRENT: string; + HIGH: string; + IDLE: string; + NORMAL: string; +} +declare var MSApp: MSApp; + +interface MSAppAsyncOperation extends EventTarget { + error: DOMError; + oncomplete: (ev: Event) => any; + onerror: (ev: Event) => any; + readyState: number; + result: any; + start(): void; + COMPLETED: number; + ERROR: number; + STARTED: number; + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSAppAsyncOperation: { + prototype: MSAppAsyncOperation; + new(): MSAppAsyncOperation; + COMPLETED: number; + ERROR: number; + STARTED: number; +} + +interface MSBlobBuilder { + append(data: any, endings?: string): void; + getBlob(contentType?: string): Blob; +} + +declare var MSBlobBuilder: { + prototype: MSBlobBuilder; + new(): MSBlobBuilder; +} + +interface MSCSSMatrix { + a: number; + b: number; + c: number; + d: number; + e: number; + f: number; + m11: number; + m12: number; + m13: number; + m14: number; + m21: number; + m22: number; + m23: number; + m24: number; + m31: number; + m32: number; + m33: number; + m34: number; + m41: number; + m42: number; + m43: number; + m44: number; + inverse(): MSCSSMatrix; + multiply(secondMatrix: MSCSSMatrix): MSCSSMatrix; + rotate(angleX: number, angleY?: number, angleZ?: number): MSCSSMatrix; + rotateAxisAngle(x: number, y: number, z: number, angle: number): MSCSSMatrix; + scale(scaleX: number, scaleY?: number, scaleZ?: number): MSCSSMatrix; + setMatrixValue(value: string): void; + skewX(angle: number): MSCSSMatrix; + skewY(angle: number): MSCSSMatrix; + toString(): string; + translate(x: number, y: number, z?: number): MSCSSMatrix; +} + +declare var MSCSSMatrix: { + prototype: MSCSSMatrix; + new(text?: string): MSCSSMatrix; +} + +interface MSGesture { + target: Element; + addPointer(pointerId: number): void; + stop(): void; +} + +declare var MSGesture: { + prototype: MSGesture; + new(): MSGesture; +} + +interface MSGestureEvent extends UIEvent { + clientX: number; + clientY: number; + expansion: number; + gestureObject: any; + hwTimestamp: number; + offsetX: number; + offsetY: number; + rotation: number; + scale: number; + screenX: number; + screenY: number; + translationX: number; + translationY: number; + velocityAngular: number; + velocityExpansion: number; + velocityX: number; + velocityY: number; + initGestureEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, offsetXArg: number, offsetYArg: number, translationXArg: number, translationYArg: number, scaleArg: number, expansionArg: number, rotationArg: number, velocityXArg: number, velocityYArg: number, velocityExpansionArg: number, velocityAngularArg: number, hwTimestampArg: number): void; + MSGESTURE_FLAG_BEGIN: number; + MSGESTURE_FLAG_CANCEL: number; + MSGESTURE_FLAG_END: number; + MSGESTURE_FLAG_INERTIA: number; + MSGESTURE_FLAG_NONE: number; +} + +declare var MSGestureEvent: { + prototype: MSGestureEvent; + new(): MSGestureEvent; + MSGESTURE_FLAG_BEGIN: number; + MSGESTURE_FLAG_CANCEL: number; + MSGESTURE_FLAG_END: number; + MSGESTURE_FLAG_INERTIA: number; + MSGESTURE_FLAG_NONE: number; +} + +interface MSGraphicsTrust { + constrictionActive: boolean; + status: string; +} + +declare var MSGraphicsTrust: { + prototype: MSGraphicsTrust; + new(): MSGraphicsTrust; +} + +interface MSHTMLWebViewElement extends HTMLElement { + canGoBack: boolean; + canGoForward: boolean; + containsFullScreenElement: boolean; + documentTitle: string; + height: number; + settings: MSWebViewSettings; + src: string; + width: number; + addWebAllowedObject(name: string, applicationObject: any): void; + buildLocalStreamUri(contentIdentifier: string, relativePath: string): string; + capturePreviewToBlobAsync(): MSWebViewAsyncOperation; + captureSelectedContentToDataPackageAsync(): MSWebViewAsyncOperation; + getDeferredPermissionRequestById(id: number): DeferredPermissionRequest; + getDeferredPermissionRequests(): DeferredPermissionRequest[]; + goBack(): void; + goForward(): void; + invokeScriptAsync(scriptName: string, ...args: any[]): MSWebViewAsyncOperation; + navigate(uri: string): void; + navigateToLocalStreamUri(source: string, streamResolver: any): void; + navigateToString(contents: string): void; + navigateWithHttpRequestMessage(requestMessage: any): void; + refresh(): void; + stop(): void; +} + +declare var MSHTMLWebViewElement: { + prototype: MSHTMLWebViewElement; + new(): MSHTMLWebViewElement; +} + +interface MSInputMethodContext extends EventTarget { + compositionEndOffset: number; + compositionStartOffset: number; + oncandidatewindowhide: (ev: Event) => any; + oncandidatewindowshow: (ev: Event) => any; + oncandidatewindowupdate: (ev: Event) => any; + target: HTMLElement; + getCandidateWindowClientRect(): ClientRect; + getCompositionAlternatives(): string[]; + hasComposition(): boolean; + isCandidateWindowVisible(): boolean; + addEventListener(type: "MSCandidateWindowHide", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "MSCandidateWindowShow", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "MSCandidateWindowUpdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSInputMethodContext: { + prototype: MSInputMethodContext; + new(): MSInputMethodContext; +} + +interface MSManipulationEvent extends UIEvent { + currentState: number; + inertiaDestinationX: number; + inertiaDestinationY: number; + lastState: number; + initMSManipulationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, lastState: number, currentState: number): void; + MS_MANIPULATION_STATE_ACTIVE: number; + MS_MANIPULATION_STATE_CANCELLED: number; + MS_MANIPULATION_STATE_COMMITTED: number; + MS_MANIPULATION_STATE_DRAGGING: number; + MS_MANIPULATION_STATE_INERTIA: number; + MS_MANIPULATION_STATE_PRESELECT: number; + MS_MANIPULATION_STATE_SELECTING: number; + MS_MANIPULATION_STATE_STOPPED: number; +} + +declare var MSManipulationEvent: { + prototype: MSManipulationEvent; + new(): MSManipulationEvent; + MS_MANIPULATION_STATE_ACTIVE: number; + MS_MANIPULATION_STATE_CANCELLED: number; + MS_MANIPULATION_STATE_COMMITTED: number; + MS_MANIPULATION_STATE_DRAGGING: number; + MS_MANIPULATION_STATE_INERTIA: number; + MS_MANIPULATION_STATE_PRESELECT: number; + MS_MANIPULATION_STATE_SELECTING: number; + MS_MANIPULATION_STATE_STOPPED: number; +} + +interface MSMediaKeyError { + code: number; + systemCode: number; + MS_MEDIA_KEYERR_CLIENT: number; + MS_MEDIA_KEYERR_DOMAIN: number; + MS_MEDIA_KEYERR_HARDWARECHANGE: number; + MS_MEDIA_KEYERR_OUTPUT: number; + MS_MEDIA_KEYERR_SERVICE: number; + MS_MEDIA_KEYERR_UNKNOWN: number; +} + +declare var MSMediaKeyError: { + prototype: MSMediaKeyError; + new(): MSMediaKeyError; + MS_MEDIA_KEYERR_CLIENT: number; + MS_MEDIA_KEYERR_DOMAIN: number; + MS_MEDIA_KEYERR_HARDWARECHANGE: number; + MS_MEDIA_KEYERR_OUTPUT: number; + MS_MEDIA_KEYERR_SERVICE: number; + MS_MEDIA_KEYERR_UNKNOWN: number; +} + +interface MSMediaKeyMessageEvent extends Event { + destinationURL: string; + message: Uint8Array; +} + +declare var MSMediaKeyMessageEvent: { + prototype: MSMediaKeyMessageEvent; + new(): MSMediaKeyMessageEvent; +} + +interface MSMediaKeyNeededEvent extends Event { + initData: Uint8Array; +} + +declare var MSMediaKeyNeededEvent: { + prototype: MSMediaKeyNeededEvent; + new(): MSMediaKeyNeededEvent; +} + +interface MSMediaKeySession extends EventTarget { + error: MSMediaKeyError; + keySystem: string; + sessionId: string; + close(): void; + update(key: Uint8Array): void; +} + +declare var MSMediaKeySession: { + prototype: MSMediaKeySession; + new(): MSMediaKeySession; +} + +interface MSMediaKeys { + keySystem: string; + createSession(type: string, initData: Uint8Array, cdmData?: Uint8Array): MSMediaKeySession; +} + +declare var MSMediaKeys: { + prototype: MSMediaKeys; + new(keySystem: string): MSMediaKeys; + isTypeSupported(keySystem: string, type?: string): boolean; +} + +interface MSMimeTypesCollection { + length: number; +} + +declare var MSMimeTypesCollection: { + prototype: MSMimeTypesCollection; + new(): MSMimeTypesCollection; +} + +interface MSPluginsCollection { + length: number; + refresh(reload?: boolean): void; +} + +declare var MSPluginsCollection: { + prototype: MSPluginsCollection; + new(): MSPluginsCollection; +} + +interface MSPointerEvent extends MouseEvent { + currentPoint: any; + height: number; + hwTimestamp: number; + intermediatePoints: any; + isPrimary: boolean; + pointerId: number; + pointerType: any; + pressure: number; + rotation: number; + tiltX: number; + tiltY: number; + width: number; + getCurrentPoint(element: Element): void; + getIntermediatePoints(element: Element): void; + initPointerEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, offsetXArg: number, offsetYArg: number, widthArg: number, heightArg: number, pressure: number, rotation: number, tiltX: number, tiltY: number, pointerIdArg: number, pointerType: any, hwTimestampArg: number, isPrimary: boolean): void; +} + +declare var MSPointerEvent: { + prototype: MSPointerEvent; + new(typeArg: string, eventInitDict?: PointerEventInit): MSPointerEvent; +} + +interface MSRangeCollection { + length: number; + item(index: number): Range; + [index: number]: Range; +} + +declare var MSRangeCollection: { + prototype: MSRangeCollection; + new(): MSRangeCollection; +} + +interface MSSiteModeEvent extends Event { + actionURL: string; + buttonID: number; +} + +declare var MSSiteModeEvent: { + prototype: MSSiteModeEvent; + new(): MSSiteModeEvent; +} + +interface MSStream { + type: string; + msClose(): void; + msDetachStream(): any; +} + +declare var MSStream: { + prototype: MSStream; + new(): MSStream; +} + +interface MSStreamReader extends EventTarget, MSBaseReader { + error: DOMError; + readAsArrayBuffer(stream: MSStream, size?: number): void; + readAsBinaryString(stream: MSStream, size?: number): void; + readAsBlob(stream: MSStream, size?: number): void; + readAsDataURL(stream: MSStream, size?: number): void; + readAsText(stream: MSStream, encoding?: string, size?: number): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSStreamReader: { + prototype: MSStreamReader; + new(): MSStreamReader; +} + +interface MSWebViewAsyncOperation extends EventTarget { + error: DOMError; + oncomplete: (ev: Event) => any; + onerror: (ev: Event) => any; + readyState: number; + result: any; + target: MSHTMLWebViewElement; + type: number; + start(): void; + COMPLETED: number; + ERROR: number; + STARTED: number; + TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + TYPE_INVOKE_SCRIPT: number; + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSWebViewAsyncOperation: { + prototype: MSWebViewAsyncOperation; + new(): MSWebViewAsyncOperation; + COMPLETED: number; + ERROR: number; + STARTED: number; + TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + TYPE_INVOKE_SCRIPT: number; +} + +interface MSWebViewSettings { + isIndexedDBEnabled: boolean; + isJavaScriptEnabled: boolean; +} + +declare var MSWebViewSettings: { + prototype: MSWebViewSettings; + new(): MSWebViewSettings; +} + +interface MediaElementAudioSourceNode extends AudioNode { +} + +declare var MediaElementAudioSourceNode: { + prototype: MediaElementAudioSourceNode; + new(): MediaElementAudioSourceNode; +} + +interface MediaError { + code: number; + msExtendedCode: number; + MEDIA_ERR_ABORTED: number; + MEDIA_ERR_DECODE: number; + MEDIA_ERR_NETWORK: number; + MEDIA_ERR_SRC_NOT_SUPPORTED: number; + MS_MEDIA_ERR_ENCRYPTED: number; +} + +declare var MediaError: { + prototype: MediaError; + new(): MediaError; + MEDIA_ERR_ABORTED: number; + MEDIA_ERR_DECODE: number; + MEDIA_ERR_NETWORK: number; + MEDIA_ERR_SRC_NOT_SUPPORTED: number; + MS_MEDIA_ERR_ENCRYPTED: number; +} + +interface MediaList { + length: number; + mediaText: string; + appendMedium(newMedium: string): void; + deleteMedium(oldMedium: string): void; + item(index: number): string; + toString(): string; + [index: number]: string; +} + +declare var MediaList: { + prototype: MediaList; + new(): MediaList; +} + +interface MediaQueryList { + matches: boolean; + media: string; + addListener(listener: MediaQueryListListener): void; + removeListener(listener: MediaQueryListListener): void; +} + +declare var MediaQueryList: { + prototype: MediaQueryList; + new(): MediaQueryList; +} + +interface MediaSource extends EventTarget { + activeSourceBuffers: SourceBufferList; + duration: number; + readyState: string; + sourceBuffers: SourceBufferList; + addSourceBuffer(type: string): SourceBuffer; + endOfStream(error?: number): void; + removeSourceBuffer(sourceBuffer: SourceBuffer): void; +} + +declare var MediaSource: { + prototype: MediaSource; + new(): MediaSource; + isTypeSupported(type: string): boolean; +} + +interface MessageChannel { + port1: MessagePort; + port2: MessagePort; +} + +declare var MessageChannel: { + prototype: MessageChannel; + new(): MessageChannel; +} + +interface MessageEvent extends Event { + data: any; + origin: string; + ports: any; + source: Window; + initMessageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, dataArg: any, originArg: string, lastEventIdArg: string, sourceArg: Window): void; +} + +declare var MessageEvent: { + prototype: MessageEvent; + new(type: string, eventInitDict?: MessageEventInit): MessageEvent; +} + +interface MessagePort extends EventTarget { + onmessage: (ev: MessageEvent) => any; + close(): void; + postMessage(message?: any, ports?: any): void; + start(): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MessagePort: { + prototype: MessagePort; + new(): MessagePort; +} + +interface MimeType { + description: string; + enabledPlugin: Plugin; + suffixes: string; + type: string; +} + +declare var MimeType: { + prototype: MimeType; + new(): MimeType; +} + +interface MimeTypeArray { + length: number; + item(index: number): Plugin; + namedItem(type: string): Plugin; + [index: number]: Plugin; +} + +declare var MimeTypeArray: { + prototype: MimeTypeArray; + new(): MimeTypeArray; +} + +interface MouseEvent extends UIEvent { + altKey: boolean; + button: number; + buttons: number; + clientX: number; + clientY: number; + ctrlKey: boolean; + fromElement: Element; + layerX: number; + layerY: number; + metaKey: boolean; + movementX: number; + movementY: number; + offsetX: number; + offsetY: number; + pageX: number; + pageY: number; + relatedTarget: EventTarget; + screenX: number; + screenY: number; + shiftKey: boolean; + toElement: Element; + which: number; + x: number; + y: number; + getModifierState(keyArg: string): boolean; + initMouseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget): void; +} + +declare var MouseEvent: { + prototype: MouseEvent; + new(typeArg: string, eventInitDict?: MouseEventInit): MouseEvent; +} + +interface MouseWheelEvent extends MouseEvent { + wheelDelta: number; + wheelDeltaX: number; + wheelDeltaY: number; + initMouseWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, wheelDeltaArg: number): void; +} + +declare var MouseWheelEvent: { + prototype: MouseWheelEvent; + new(): MouseWheelEvent; +} + +interface MutationEvent extends Event { + attrChange: number; + attrName: string; + newValue: string; + prevValue: string; + relatedNode: Node; + initMutationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, relatedNodeArg: Node, prevValueArg: string, newValueArg: string, attrNameArg: string, attrChangeArg: number): void; + ADDITION: number; + MODIFICATION: number; + REMOVAL: number; +} + +declare var MutationEvent: { + prototype: MutationEvent; + new(): MutationEvent; + ADDITION: number; + MODIFICATION: number; + REMOVAL: number; +} + +interface MutationObserver { + disconnect(): void; + observe(target: Node, options: MutationObserverInit): void; + takeRecords(): MutationRecord[]; +} + +declare var MutationObserver: { + prototype: MutationObserver; + new(callback: MutationCallback): MutationObserver; +} + +interface MutationRecord { + addedNodes: NodeList; + attributeName: string; + attributeNamespace: string; + nextSibling: Node; + oldValue: string; + previousSibling: Node; + removedNodes: NodeList; + target: Node; + type: string; +} + +declare var MutationRecord: { + prototype: MutationRecord; + new(): MutationRecord; +} + +interface NamedNodeMap { + length: number; + getNamedItem(name: string): Attr; + getNamedItemNS(namespaceURI: string, localName: string): Attr; + item(index: number): Attr; + removeNamedItem(name: string): Attr; + removeNamedItemNS(namespaceURI: string, localName: string): Attr; + setNamedItem(arg: Attr): Attr; + setNamedItemNS(arg: Attr): Attr; + [index: number]: Attr; +} + +declare var NamedNodeMap: { + prototype: NamedNodeMap; + new(): NamedNodeMap; +} + +interface NavigationCompletedEvent extends NavigationEvent { + isSuccess: boolean; + webErrorStatus: number; +} + +declare var NavigationCompletedEvent: { + prototype: NavigationCompletedEvent; + new(): NavigationCompletedEvent; +} + +interface NavigationEvent extends Event { + uri: string; +} + +declare var NavigationEvent: { + prototype: NavigationEvent; + new(): NavigationEvent; +} + +interface NavigationEventWithReferrer extends NavigationEvent { + referer: string; +} + +declare var NavigationEventWithReferrer: { + prototype: NavigationEventWithReferrer; + new(): NavigationEventWithReferrer; +} + +interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver { + appCodeName: string; + appMinorVersion: string; + browserLanguage: string; + connectionSpeed: number; + cookieEnabled: boolean; + cpuClass: string; + language: string; + maxTouchPoints: number; + mimeTypes: MSMimeTypesCollection; + msManipulationViewsEnabled: boolean; + msMaxTouchPoints: number; + msPointerEnabled: boolean; + plugins: MSPluginsCollection; + pointerEnabled: boolean; + systemLanguage: string; + userLanguage: string; + webdriver: boolean; + getGamepads(): Gamepad[]; + javaEnabled(): boolean; + msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; + vibrate(pattern: number | number[]): boolean; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Navigator: { + prototype: Navigator; + new(): Navigator; +} + +interface Node extends EventTarget { + attributes: NamedNodeMap; + baseURI: string; + childNodes: NodeList; + firstChild: Node; + lastChild: Node; + localName: string; + namespaceURI: string; + nextSibling: Node; + nodeName: string; + nodeType: number; + nodeValue: string; + ownerDocument: Document; + parentElement: HTMLElement; + parentNode: Node; + prefix: string; + previousSibling: Node; + textContent: string; + appendChild(newChild: Node): Node; + cloneNode(deep?: boolean): Node; + compareDocumentPosition(other: Node): number; + hasAttributes(): boolean; + hasChildNodes(): boolean; + insertBefore(newChild: Node, refChild?: Node): Node; + isDefaultNamespace(namespaceURI: string): boolean; + isEqualNode(arg: Node): boolean; + isSameNode(other: Node): boolean; + lookupNamespaceURI(prefix: string): string; + lookupPrefix(namespaceURI: string): string; + normalize(): void; + removeChild(oldChild: Node): Node; + replaceChild(newChild: Node, oldChild: Node): Node; + contains(node: Node): boolean; + ATTRIBUTE_NODE: number; + CDATA_SECTION_NODE: number; + COMMENT_NODE: number; + DOCUMENT_FRAGMENT_NODE: number; + DOCUMENT_NODE: number; + DOCUMENT_POSITION_CONTAINED_BY: number; + DOCUMENT_POSITION_CONTAINS: number; + DOCUMENT_POSITION_DISCONNECTED: number; + DOCUMENT_POSITION_FOLLOWING: number; + DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + DOCUMENT_POSITION_PRECEDING: number; + DOCUMENT_TYPE_NODE: number; + ELEMENT_NODE: number; + ENTITY_NODE: number; + ENTITY_REFERENCE_NODE: number; + NOTATION_NODE: number; + PROCESSING_INSTRUCTION_NODE: number; + TEXT_NODE: number; +} + +declare var Node: { + prototype: Node; + new(): Node; + ATTRIBUTE_NODE: number; + CDATA_SECTION_NODE: number; + COMMENT_NODE: number; + DOCUMENT_FRAGMENT_NODE: number; + DOCUMENT_NODE: number; + DOCUMENT_POSITION_CONTAINED_BY: number; + DOCUMENT_POSITION_CONTAINS: number; + DOCUMENT_POSITION_DISCONNECTED: number; + DOCUMENT_POSITION_FOLLOWING: number; + DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + DOCUMENT_POSITION_PRECEDING: number; + DOCUMENT_TYPE_NODE: number; + ELEMENT_NODE: number; + ENTITY_NODE: number; + ENTITY_REFERENCE_NODE: number; + NOTATION_NODE: number; + PROCESSING_INSTRUCTION_NODE: number; + TEXT_NODE: number; +} + +interface NodeFilter { + acceptNode(n: Node): number; +} + +declare var NodeFilter: { + FILTER_ACCEPT: number; + FILTER_REJECT: number; + FILTER_SKIP: number; + SHOW_ALL: number; + SHOW_ATTRIBUTE: number; + SHOW_CDATA_SECTION: number; + SHOW_COMMENT: number; + SHOW_DOCUMENT: number; + SHOW_DOCUMENT_FRAGMENT: number; + SHOW_DOCUMENT_TYPE: number; + SHOW_ELEMENT: number; + SHOW_ENTITY: number; + SHOW_ENTITY_REFERENCE: number; + SHOW_NOTATION: number; + SHOW_PROCESSING_INSTRUCTION: number; + SHOW_TEXT: number; +} + +interface NodeIterator { + expandEntityReferences: boolean; + filter: NodeFilter; + root: Node; + whatToShow: number; + detach(): void; + nextNode(): Node; + previousNode(): Node; +} + +declare var NodeIterator: { + prototype: NodeIterator; + new(): NodeIterator; +} + +interface NodeList { + length: number; + item(index: number): Node; + [index: number]: Node; +} + +declare var NodeList: { + prototype: NodeList; + new(): NodeList; +} + +interface OES_element_index_uint { +} + +declare var OES_element_index_uint: { + prototype: OES_element_index_uint; + new(): OES_element_index_uint; +} + +interface OES_standard_derivatives { + FRAGMENT_SHADER_DERIVATIVE_HINT_OES: number; +} + +declare var OES_standard_derivatives: { + prototype: OES_standard_derivatives; + new(): OES_standard_derivatives; + FRAGMENT_SHADER_DERIVATIVE_HINT_OES: number; +} + +interface OES_texture_float { +} + +declare var OES_texture_float: { + prototype: OES_texture_float; + new(): OES_texture_float; +} + +interface OES_texture_float_linear { +} + +declare var OES_texture_float_linear: { + prototype: OES_texture_float_linear; + new(): OES_texture_float_linear; +} + +interface OfflineAudioCompletionEvent extends Event { + renderedBuffer: AudioBuffer; +} + +declare var OfflineAudioCompletionEvent: { + prototype: OfflineAudioCompletionEvent; + new(): OfflineAudioCompletionEvent; +} + +interface OfflineAudioContext extends AudioContext { + oncomplete: (ev: Event) => any; + startRendering(): void; + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var OfflineAudioContext: { + prototype: OfflineAudioContext; + new(numberOfChannels: number, length: number, sampleRate: number): OfflineAudioContext; +} + +interface OscillatorNode extends AudioNode { + detune: AudioParam; + frequency: AudioParam; + onended: (ev: Event) => any; + type: string; + setPeriodicWave(periodicWave: PeriodicWave): void; + start(when?: number): void; + stop(when?: number): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var OscillatorNode: { + prototype: OscillatorNode; + new(): OscillatorNode; +} + +interface PageTransitionEvent extends Event { + persisted: boolean; +} + +declare var PageTransitionEvent: { + prototype: PageTransitionEvent; + new(): PageTransitionEvent; +} + +interface PannerNode extends AudioNode { + coneInnerAngle: number; + coneOuterAngle: number; + coneOuterGain: number; + distanceModel: string; + maxDistance: number; + panningModel: string; + refDistance: number; + rolloffFactor: number; + setOrientation(x: number, y: number, z: number): void; + setPosition(x: number, y: number, z: number): void; + setVelocity(x: number, y: number, z: number): void; +} + +declare var PannerNode: { + prototype: PannerNode; + new(): PannerNode; +} + +interface PerfWidgetExternal { + activeNetworkRequestCount: number; + averageFrameTime: number; + averagePaintTime: number; + extraInformationEnabled: boolean; + independentRenderingEnabled: boolean; + irDisablingContentString: string; + irStatusAvailable: boolean; + maxCpuSpeed: number; + paintRequestsPerSecond: number; + performanceCounter: number; + performanceCounterFrequency: number; + addEventListener(eventType: string, callback: Function): void; + getMemoryUsage(): number; + getProcessCpuUsage(): number; + getRecentCpuUsage(last: number): any; + getRecentFrames(last: number): any; + getRecentMemoryUsage(last: number): any; + getRecentPaintRequests(last: number): any; + removeEventListener(eventType: string, callback: Function): void; + repositionWindow(x: number, y: number): void; + resizeWindow(width: number, height: number): void; +} + +declare var PerfWidgetExternal: { + prototype: PerfWidgetExternal; + new(): PerfWidgetExternal; +} + +interface Performance { + navigation: PerformanceNavigation; + timing: PerformanceTiming; + clearMarks(markName?: string): void; + clearMeasures(measureName?: string): void; + clearResourceTimings(): void; + getEntries(): any; + getEntriesByName(name: string, entryType?: string): any; + getEntriesByType(entryType: string): any; + getMarks(markName?: string): any; + getMeasures(measureName?: string): any; + mark(markName: string): void; + measure(measureName: string, startMarkName?: string, endMarkName?: string): void; + now(): number; + setResourceTimingBufferSize(maxSize: number): void; + toJSON(): any; +} + +declare var Performance: { + prototype: Performance; + new(): Performance; +} + +interface PerformanceEntry { + duration: number; + entryType: string; + name: string; + startTime: number; +} + +declare var PerformanceEntry: { + prototype: PerformanceEntry; + new(): PerformanceEntry; +} + +interface PerformanceMark extends PerformanceEntry { +} + +declare var PerformanceMark: { + prototype: PerformanceMark; + new(): PerformanceMark; +} + +interface PerformanceMeasure extends PerformanceEntry { +} + +declare var PerformanceMeasure: { + prototype: PerformanceMeasure; + new(): PerformanceMeasure; +} + +interface PerformanceNavigation { + redirectCount: number; + type: number; + toJSON(): any; + TYPE_BACK_FORWARD: number; + TYPE_NAVIGATE: number; + TYPE_RELOAD: number; + TYPE_RESERVED: number; +} + +declare var PerformanceNavigation: { + prototype: PerformanceNavigation; + new(): PerformanceNavigation; + TYPE_BACK_FORWARD: number; + TYPE_NAVIGATE: number; + TYPE_RELOAD: number; + TYPE_RESERVED: number; +} + +interface PerformanceNavigationTiming extends PerformanceEntry { + connectEnd: number; + connectStart: number; + domComplete: number; + domContentLoadedEventEnd: number; + domContentLoadedEventStart: number; + domInteractive: number; + domLoading: number; + domainLookupEnd: number; + domainLookupStart: number; + fetchStart: number; + loadEventEnd: number; + loadEventStart: number; + navigationStart: number; + redirectCount: number; + redirectEnd: number; + redirectStart: number; + requestStart: number; + responseEnd: number; + responseStart: number; + type: string; + unloadEventEnd: number; + unloadEventStart: number; +} + +declare var PerformanceNavigationTiming: { + prototype: PerformanceNavigationTiming; + new(): PerformanceNavigationTiming; +} + +interface PerformanceResourceTiming extends PerformanceEntry { + connectEnd: number; + connectStart: number; + domainLookupEnd: number; + domainLookupStart: number; + fetchStart: number; + initiatorType: string; + redirectEnd: number; + redirectStart: number; + requestStart: number; + responseEnd: number; + responseStart: number; +} + +declare var PerformanceResourceTiming: { + prototype: PerformanceResourceTiming; + new(): PerformanceResourceTiming; +} + +interface PerformanceTiming { + connectEnd: number; + connectStart: number; + domComplete: number; + domContentLoadedEventEnd: number; + domContentLoadedEventStart: number; + domInteractive: number; + domLoading: number; + domainLookupEnd: number; + domainLookupStart: number; + fetchStart: number; + loadEventEnd: number; + loadEventStart: number; + msFirstPaint: number; + navigationStart: number; + redirectEnd: number; + redirectStart: number; + requestStart: number; + responseEnd: number; + responseStart: number; + unloadEventEnd: number; + unloadEventStart: number; + toJSON(): any; +} + +declare var PerformanceTiming: { + prototype: PerformanceTiming; + new(): PerformanceTiming; +} + +interface PeriodicWave { +} + +declare var PeriodicWave: { + prototype: PeriodicWave; + new(): PeriodicWave; +} + +interface PermissionRequest extends DeferredPermissionRequest { + state: string; + defer(): void; +} + +declare var PermissionRequest: { + prototype: PermissionRequest; + new(): PermissionRequest; +} + +interface PermissionRequestedEvent extends Event { + permissionRequest: PermissionRequest; +} + +declare var PermissionRequestedEvent: { + prototype: PermissionRequestedEvent; + new(): PermissionRequestedEvent; +} + +interface Plugin { + description: string; + filename: string; + length: number; + name: string; + version: string; + item(index: number): MimeType; + namedItem(type: string): MimeType; + [index: number]: MimeType; +} + +declare var Plugin: { + prototype: Plugin; + new(): Plugin; +} + +interface PluginArray { + length: number; + item(index: number): Plugin; + namedItem(name: string): Plugin; + refresh(reload?: boolean): void; + [index: number]: Plugin; +} + +declare var PluginArray: { + prototype: PluginArray; + new(): PluginArray; +} + +interface PointerEvent extends MouseEvent { + currentPoint: any; + height: number; + hwTimestamp: number; + intermediatePoints: any; + isPrimary: boolean; + pointerId: number; + pointerType: any; + pressure: number; + rotation: number; + tiltX: number; + tiltY: number; + width: number; + getCurrentPoint(element: Element): void; + getIntermediatePoints(element: Element): void; + initPointerEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, offsetXArg: number, offsetYArg: number, widthArg: number, heightArg: number, pressure: number, rotation: number, tiltX: number, tiltY: number, pointerIdArg: number, pointerType: any, hwTimestampArg: number, isPrimary: boolean): void; +} + +declare var PointerEvent: { + prototype: PointerEvent; + new(typeArg: string, eventInitDict?: PointerEventInit): PointerEvent; +} + +interface PopStateEvent extends Event { + state: any; + initPopStateEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, stateArg: any): void; +} + +declare var PopStateEvent: { + prototype: PopStateEvent; + new(): PopStateEvent; +} + +interface Position { + coords: Coordinates; + timestamp: number; +} + +declare var Position: { + prototype: Position; + new(): Position; +} + +interface PositionError { + code: number; + message: string; + toString(): string; + PERMISSION_DENIED: number; + POSITION_UNAVAILABLE: number; + TIMEOUT: number; +} + +declare var PositionError: { + prototype: PositionError; + new(): PositionError; + PERMISSION_DENIED: number; + POSITION_UNAVAILABLE: number; + TIMEOUT: number; +} + +interface ProcessingInstruction extends CharacterData { + target: string; +} + +declare var ProcessingInstruction: { + prototype: ProcessingInstruction; + new(): ProcessingInstruction; +} + +interface ProgressEvent extends Event { + lengthComputable: boolean; + loaded: number; + total: number; + initProgressEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, lengthComputableArg: boolean, loadedArg: number, totalArg: number): void; +} + +declare var ProgressEvent: { + prototype: ProgressEvent; + new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; +} + +interface Range { + collapsed: boolean; + commonAncestorContainer: Node; + endContainer: Node; + endOffset: number; + startContainer: Node; + startOffset: number; + cloneContents(): DocumentFragment; + cloneRange(): Range; + collapse(toStart: boolean): void; + compareBoundaryPoints(how: number, sourceRange: Range): number; + createContextualFragment(fragment: string): DocumentFragment; + deleteContents(): void; + detach(): void; + expand(Unit: string): boolean; + extractContents(): DocumentFragment; + getBoundingClientRect(): ClientRect; + getClientRects(): ClientRectList; + insertNode(newNode: Node): void; + selectNode(refNode: Node): void; + selectNodeContents(refNode: Node): void; + setEnd(refNode: Node, offset: number): void; + setEndAfter(refNode: Node): void; + setEndBefore(refNode: Node): void; + setStart(refNode: Node, offset: number): void; + setStartAfter(refNode: Node): void; + setStartBefore(refNode: Node): void; + surroundContents(newParent: Node): void; + toString(): string; + END_TO_END: number; + END_TO_START: number; + START_TO_END: number; + START_TO_START: number; +} + +declare var Range: { + prototype: Range; + new(): Range; + END_TO_END: number; + END_TO_START: number; + START_TO_END: number; + START_TO_START: number; +} + +interface SVGAElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { + target: SVGAnimatedString; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGAElement: { + prototype: SVGAElement; + new(): SVGAElement; +} + +interface SVGAngle { + unitType: number; + value: number; + valueAsString: string; + valueInSpecifiedUnits: number; + convertToSpecifiedUnits(unitType: number): void; + newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; + SVG_ANGLETYPE_DEG: number; + SVG_ANGLETYPE_GRAD: number; + SVG_ANGLETYPE_RAD: number; + SVG_ANGLETYPE_UNKNOWN: number; + SVG_ANGLETYPE_UNSPECIFIED: number; +} + +declare var SVGAngle: { + prototype: SVGAngle; + new(): SVGAngle; + SVG_ANGLETYPE_DEG: number; + SVG_ANGLETYPE_GRAD: number; + SVG_ANGLETYPE_RAD: number; + SVG_ANGLETYPE_UNKNOWN: number; + SVG_ANGLETYPE_UNSPECIFIED: number; +} + +interface SVGAnimatedAngle { + animVal: SVGAngle; + baseVal: SVGAngle; +} + +declare var SVGAnimatedAngle: { + prototype: SVGAnimatedAngle; + new(): SVGAnimatedAngle; +} + +interface SVGAnimatedBoolean { + animVal: boolean; + baseVal: boolean; +} + +declare var SVGAnimatedBoolean: { + prototype: SVGAnimatedBoolean; + new(): SVGAnimatedBoolean; +} + +interface SVGAnimatedEnumeration { + animVal: number; + baseVal: number; +} + +declare var SVGAnimatedEnumeration: { + prototype: SVGAnimatedEnumeration; + new(): SVGAnimatedEnumeration; +} + +interface SVGAnimatedInteger { + animVal: number; + baseVal: number; +} + +declare var SVGAnimatedInteger: { + prototype: SVGAnimatedInteger; + new(): SVGAnimatedInteger; +} + +interface SVGAnimatedLength { + animVal: SVGLength; + baseVal: SVGLength; +} + +declare var SVGAnimatedLength: { + prototype: SVGAnimatedLength; + new(): SVGAnimatedLength; +} + +interface SVGAnimatedLengthList { + animVal: SVGLengthList; + baseVal: SVGLengthList; +} + +declare var SVGAnimatedLengthList: { + prototype: SVGAnimatedLengthList; + new(): SVGAnimatedLengthList; +} + +interface SVGAnimatedNumber { + animVal: number; + baseVal: number; +} + +declare var SVGAnimatedNumber: { + prototype: SVGAnimatedNumber; + new(): SVGAnimatedNumber; +} + +interface SVGAnimatedNumberList { + animVal: SVGNumberList; + baseVal: SVGNumberList; +} + +declare var SVGAnimatedNumberList: { + prototype: SVGAnimatedNumberList; + new(): SVGAnimatedNumberList; +} + +interface SVGAnimatedPreserveAspectRatio { + animVal: SVGPreserveAspectRatio; + baseVal: SVGPreserveAspectRatio; +} + +declare var SVGAnimatedPreserveAspectRatio: { + prototype: SVGAnimatedPreserveAspectRatio; + new(): SVGAnimatedPreserveAspectRatio; +} + +interface SVGAnimatedRect { + animVal: SVGRect; + baseVal: SVGRect; +} + +declare var SVGAnimatedRect: { + prototype: SVGAnimatedRect; + new(): SVGAnimatedRect; +} + +interface SVGAnimatedString { + animVal: string; + baseVal: string; +} + +declare var SVGAnimatedString: { + prototype: SVGAnimatedString; + new(): SVGAnimatedString; +} + +interface SVGAnimatedTransformList { + animVal: SVGTransformList; + baseVal: SVGTransformList; +} + +declare var SVGAnimatedTransformList: { + prototype: SVGAnimatedTransformList; + new(): SVGAnimatedTransformList; +} + +interface SVGCircleElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { + cx: SVGAnimatedLength; + cy: SVGAnimatedLength; + r: SVGAnimatedLength; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGCircleElement: { + prototype: SVGCircleElement; + new(): SVGCircleElement; +} + +interface SVGClipPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGUnitTypes { + clipPathUnits: SVGAnimatedEnumeration; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGClipPathElement: { + prototype: SVGClipPathElement; + new(): SVGClipPathElement; +} + +interface SVGComponentTransferFunctionElement extends SVGElement { + amplitude: SVGAnimatedNumber; + exponent: SVGAnimatedNumber; + intercept: SVGAnimatedNumber; + offset: SVGAnimatedNumber; + slope: SVGAnimatedNumber; + tableValues: SVGAnimatedNumberList; + type: SVGAnimatedEnumeration; + SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; + SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; +} + +declare var SVGComponentTransferFunctionElement: { + prototype: SVGComponentTransferFunctionElement; + new(): SVGComponentTransferFunctionElement; + SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; + SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; +} + +interface SVGDefsElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGDefsElement: { + prototype: SVGDefsElement; + new(): SVGDefsElement; +} + +interface SVGDescElement extends SVGElement, SVGStylable, SVGLangSpace { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGDescElement: { + prototype: SVGDescElement; + new(): SVGDescElement; +} + +interface SVGElement extends Element { + id: string; + onclick: (ev: MouseEvent) => any; + ondblclick: (ev: MouseEvent) => any; + onfocusin: (ev: FocusEvent) => any; + onfocusout: (ev: FocusEvent) => any; + onload: (ev: Event) => any; + onmousedown: (ev: MouseEvent) => any; + onmousemove: (ev: MouseEvent) => any; + onmouseout: (ev: MouseEvent) => any; + onmouseover: (ev: MouseEvent) => any; + onmouseup: (ev: MouseEvent) => any; + ownerSVGElement: SVGSVGElement; + viewportElement: SVGElement; + xmlbase: string; + className: any; + addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGElement: { + prototype: SVGElement; + new(): SVGElement; +} + +interface SVGElementInstance extends EventTarget { + childNodes: SVGElementInstanceList; + correspondingElement: SVGElement; + correspondingUseElement: SVGUseElement; + firstChild: SVGElementInstance; + lastChild: SVGElementInstance; + nextSibling: SVGElementInstance; + parentNode: SVGElementInstance; + previousSibling: SVGElementInstance; +} + +declare var SVGElementInstance: { + prototype: SVGElementInstance; + new(): SVGElementInstance; +} + +interface SVGElementInstanceList { + length: number; + item(index: number): SVGElementInstance; +} + +declare var SVGElementInstanceList: { + prototype: SVGElementInstanceList; + new(): SVGElementInstanceList; +} + +interface SVGEllipseElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { + cx: SVGAnimatedLength; + cy: SVGAnimatedLength; + rx: SVGAnimatedLength; + ry: SVGAnimatedLength; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGEllipseElement: { + prototype: SVGEllipseElement; + new(): SVGEllipseElement; +} + +interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + in2: SVGAnimatedString; + mode: SVGAnimatedEnumeration; + SVG_FEBLEND_MODE_COLOR: number; + SVG_FEBLEND_MODE_COLOR_BURN: number; + SVG_FEBLEND_MODE_COLOR_DODGE: number; + SVG_FEBLEND_MODE_DARKEN: number; + SVG_FEBLEND_MODE_DIFFERENCE: number; + SVG_FEBLEND_MODE_EXCLUSION: number; + SVG_FEBLEND_MODE_HARD_LIGHT: number; + SVG_FEBLEND_MODE_HUE: number; + SVG_FEBLEND_MODE_LIGHTEN: number; + SVG_FEBLEND_MODE_LUMINOSITY: number; + SVG_FEBLEND_MODE_MULTIPLY: number; + SVG_FEBLEND_MODE_NORMAL: number; + SVG_FEBLEND_MODE_OVERLAY: number; + SVG_FEBLEND_MODE_SATURATION: number; + SVG_FEBLEND_MODE_SCREEN: number; + SVG_FEBLEND_MODE_SOFT_LIGHT: number; + SVG_FEBLEND_MODE_UNKNOWN: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEBlendElement: { + prototype: SVGFEBlendElement; + new(): SVGFEBlendElement; + SVG_FEBLEND_MODE_COLOR: number; + SVG_FEBLEND_MODE_COLOR_BURN: number; + SVG_FEBLEND_MODE_COLOR_DODGE: number; + SVG_FEBLEND_MODE_DARKEN: number; + SVG_FEBLEND_MODE_DIFFERENCE: number; + SVG_FEBLEND_MODE_EXCLUSION: number; + SVG_FEBLEND_MODE_HARD_LIGHT: number; + SVG_FEBLEND_MODE_HUE: number; + SVG_FEBLEND_MODE_LIGHTEN: number; + SVG_FEBLEND_MODE_LUMINOSITY: number; + SVG_FEBLEND_MODE_MULTIPLY: number; + SVG_FEBLEND_MODE_NORMAL: number; + SVG_FEBLEND_MODE_OVERLAY: number; + SVG_FEBLEND_MODE_SATURATION: number; + SVG_FEBLEND_MODE_SCREEN: number; + SVG_FEBLEND_MODE_SOFT_LIGHT: number; + SVG_FEBLEND_MODE_UNKNOWN: number; +} + +interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + type: SVGAnimatedEnumeration; + values: SVGAnimatedNumberList; + SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; + SVG_FECOLORMATRIX_TYPE_MATRIX: number; + SVG_FECOLORMATRIX_TYPE_SATURATE: number; + SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEColorMatrixElement: { + prototype: SVGFEColorMatrixElement; + new(): SVGFEColorMatrixElement; + SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; + SVG_FECOLORMATRIX_TYPE_MATRIX: number; + SVG_FECOLORMATRIX_TYPE_SATURATE: number; + SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; +} + +interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEComponentTransferElement: { + prototype: SVGFEComponentTransferElement; + new(): SVGFEComponentTransferElement; +} + +interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + in2: SVGAnimatedString; + k1: SVGAnimatedNumber; + k2: SVGAnimatedNumber; + k3: SVGAnimatedNumber; + k4: SVGAnimatedNumber; + operator: SVGAnimatedEnumeration; + SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + SVG_FECOMPOSITE_OPERATOR_ATOP: number; + SVG_FECOMPOSITE_OPERATOR_IN: number; + SVG_FECOMPOSITE_OPERATOR_OUT: number; + SVG_FECOMPOSITE_OPERATOR_OVER: number; + SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + SVG_FECOMPOSITE_OPERATOR_XOR: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFECompositeElement: { + prototype: SVGFECompositeElement; + new(): SVGFECompositeElement; + SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + SVG_FECOMPOSITE_OPERATOR_ATOP: number; + SVG_FECOMPOSITE_OPERATOR_IN: number; + SVG_FECOMPOSITE_OPERATOR_OUT: number; + SVG_FECOMPOSITE_OPERATOR_OVER: number; + SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + SVG_FECOMPOSITE_OPERATOR_XOR: number; +} + +interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + bias: SVGAnimatedNumber; + divisor: SVGAnimatedNumber; + edgeMode: SVGAnimatedEnumeration; + in1: SVGAnimatedString; + kernelMatrix: SVGAnimatedNumberList; + kernelUnitLengthX: SVGAnimatedNumber; + kernelUnitLengthY: SVGAnimatedNumber; + orderX: SVGAnimatedInteger; + orderY: SVGAnimatedInteger; + preserveAlpha: SVGAnimatedBoolean; + targetX: SVGAnimatedInteger; + targetY: SVGAnimatedInteger; + SVG_EDGEMODE_DUPLICATE: number; + SVG_EDGEMODE_NONE: number; + SVG_EDGEMODE_UNKNOWN: number; + SVG_EDGEMODE_WRAP: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEConvolveMatrixElement: { + prototype: SVGFEConvolveMatrixElement; + new(): SVGFEConvolveMatrixElement; + SVG_EDGEMODE_DUPLICATE: number; + SVG_EDGEMODE_NONE: number; + SVG_EDGEMODE_UNKNOWN: number; + SVG_EDGEMODE_WRAP: number; +} + +interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + diffuseConstant: SVGAnimatedNumber; + in1: SVGAnimatedString; + kernelUnitLengthX: SVGAnimatedNumber; + kernelUnitLengthY: SVGAnimatedNumber; + surfaceScale: SVGAnimatedNumber; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEDiffuseLightingElement: { + prototype: SVGFEDiffuseLightingElement; + new(): SVGFEDiffuseLightingElement; +} + +interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + in2: SVGAnimatedString; + scale: SVGAnimatedNumber; + xChannelSelector: SVGAnimatedEnumeration; + yChannelSelector: SVGAnimatedEnumeration; + SVG_CHANNEL_A: number; + SVG_CHANNEL_B: number; + SVG_CHANNEL_G: number; + SVG_CHANNEL_R: number; + SVG_CHANNEL_UNKNOWN: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEDisplacementMapElement: { + prototype: SVGFEDisplacementMapElement; + new(): SVGFEDisplacementMapElement; + SVG_CHANNEL_A: number; + SVG_CHANNEL_B: number; + SVG_CHANNEL_G: number; + SVG_CHANNEL_R: number; + SVG_CHANNEL_UNKNOWN: number; +} + +interface SVGFEDistantLightElement extends SVGElement { + azimuth: SVGAnimatedNumber; + elevation: SVGAnimatedNumber; +} + +declare var SVGFEDistantLightElement: { + prototype: SVGFEDistantLightElement; + new(): SVGFEDistantLightElement; +} + +interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEFloodElement: { + prototype: SVGFEFloodElement; + new(): SVGFEFloodElement; +} + +interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { +} + +declare var SVGFEFuncAElement: { + prototype: SVGFEFuncAElement; + new(): SVGFEFuncAElement; +} + +interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { +} + +declare var SVGFEFuncBElement: { + prototype: SVGFEFuncBElement; + new(): SVGFEFuncBElement; +} + +interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { +} + +declare var SVGFEFuncGElement: { + prototype: SVGFEFuncGElement; + new(): SVGFEFuncGElement; +} + +interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { +} + +declare var SVGFEFuncRElement: { + prototype: SVGFEFuncRElement; + new(): SVGFEFuncRElement; +} + +interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + stdDeviationX: SVGAnimatedNumber; + stdDeviationY: SVGAnimatedNumber; + setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEGaussianBlurElement: { + prototype: SVGFEGaussianBlurElement; + new(): SVGFEGaussianBlurElement; +} + +interface SVGFEImageElement extends SVGElement, SVGFilterPrimitiveStandardAttributes, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEImageElement: { + prototype: SVGFEImageElement; + new(): SVGFEImageElement; +} + +interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEMergeElement: { + prototype: SVGFEMergeElement; + new(): SVGFEMergeElement; +} + +interface SVGFEMergeNodeElement extends SVGElement { + in1: SVGAnimatedString; +} + +declare var SVGFEMergeNodeElement: { + prototype: SVGFEMergeNodeElement; + new(): SVGFEMergeNodeElement; +} + +interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + operator: SVGAnimatedEnumeration; + radiusX: SVGAnimatedNumber; + radiusY: SVGAnimatedNumber; + SVG_MORPHOLOGY_OPERATOR_DILATE: number; + SVG_MORPHOLOGY_OPERATOR_ERODE: number; + SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEMorphologyElement: { + prototype: SVGFEMorphologyElement; + new(): SVGFEMorphologyElement; + SVG_MORPHOLOGY_OPERATOR_DILATE: number; + SVG_MORPHOLOGY_OPERATOR_ERODE: number; + SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; +} + +interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + dx: SVGAnimatedNumber; + dy: SVGAnimatedNumber; + in1: SVGAnimatedString; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEOffsetElement: { + prototype: SVGFEOffsetElement; + new(): SVGFEOffsetElement; +} + +interface SVGFEPointLightElement extends SVGElement { + x: SVGAnimatedNumber; + y: SVGAnimatedNumber; + z: SVGAnimatedNumber; +} + +declare var SVGFEPointLightElement: { + prototype: SVGFEPointLightElement; + new(): SVGFEPointLightElement; +} + +interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + kernelUnitLengthX: SVGAnimatedNumber; + kernelUnitLengthY: SVGAnimatedNumber; + specularConstant: SVGAnimatedNumber; + specularExponent: SVGAnimatedNumber; + surfaceScale: SVGAnimatedNumber; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFESpecularLightingElement: { + prototype: SVGFESpecularLightingElement; + new(): SVGFESpecularLightingElement; +} + +interface SVGFESpotLightElement extends SVGElement { + limitingConeAngle: SVGAnimatedNumber; + pointsAtX: SVGAnimatedNumber; + pointsAtY: SVGAnimatedNumber; + pointsAtZ: SVGAnimatedNumber; + specularExponent: SVGAnimatedNumber; + x: SVGAnimatedNumber; + y: SVGAnimatedNumber; + z: SVGAnimatedNumber; +} + +declare var SVGFESpotLightElement: { + prototype: SVGFESpotLightElement; + new(): SVGFESpotLightElement; +} + +interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFETileElement: { + prototype: SVGFETileElement; + new(): SVGFETileElement; +} + +interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + baseFrequencyX: SVGAnimatedNumber; + baseFrequencyY: SVGAnimatedNumber; + numOctaves: SVGAnimatedInteger; + seed: SVGAnimatedNumber; + stitchTiles: SVGAnimatedEnumeration; + type: SVGAnimatedEnumeration; + SVG_STITCHTYPE_NOSTITCH: number; + SVG_STITCHTYPE_STITCH: number; + SVG_STITCHTYPE_UNKNOWN: number; + SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + SVG_TURBULENCE_TYPE_TURBULENCE: number; + SVG_TURBULENCE_TYPE_UNKNOWN: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFETurbulenceElement: { + prototype: SVGFETurbulenceElement; + new(): SVGFETurbulenceElement; + SVG_STITCHTYPE_NOSTITCH: number; + SVG_STITCHTYPE_STITCH: number; + SVG_STITCHTYPE_UNKNOWN: number; + SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + SVG_TURBULENCE_TYPE_TURBULENCE: number; + SVG_TURBULENCE_TYPE_UNKNOWN: number; +} + +interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { + filterResX: SVGAnimatedInteger; + filterResY: SVGAnimatedInteger; + filterUnits: SVGAnimatedEnumeration; + height: SVGAnimatedLength; + primitiveUnits: SVGAnimatedEnumeration; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + y: SVGAnimatedLength; + setFilterRes(filterResX: number, filterResY: number): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFilterElement: { + prototype: SVGFilterElement; + new(): SVGFilterElement; +} + +interface SVGForeignObjectElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { + height: SVGAnimatedLength; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + y: SVGAnimatedLength; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGForeignObjectElement: { + prototype: SVGForeignObjectElement; + new(): SVGForeignObjectElement; +} + +interface SVGGElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGGElement: { + prototype: SVGGElement; + new(): SVGGElement; +} + +interface SVGGradientElement extends SVGElement, SVGStylable, SVGExternalResourcesRequired, SVGURIReference, SVGUnitTypes { + gradientTransform: SVGAnimatedTransformList; + gradientUnits: SVGAnimatedEnumeration; + spreadMethod: SVGAnimatedEnumeration; + SVG_SPREADMETHOD_PAD: number; + SVG_SPREADMETHOD_REFLECT: number; + SVG_SPREADMETHOD_REPEAT: number; + SVG_SPREADMETHOD_UNKNOWN: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGGradientElement: { + prototype: SVGGradientElement; + new(): SVGGradientElement; + SVG_SPREADMETHOD_PAD: number; + SVG_SPREADMETHOD_REFLECT: number; + SVG_SPREADMETHOD_REPEAT: number; + SVG_SPREADMETHOD_UNKNOWN: number; +} + +interface SVGImageElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { + height: SVGAnimatedLength; + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + y: SVGAnimatedLength; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGImageElement: { + prototype: SVGImageElement; + new(): SVGImageElement; +} + +interface SVGLength { + unitType: number; + value: number; + valueAsString: string; + valueInSpecifiedUnits: number; + convertToSpecifiedUnits(unitType: number): void; + newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; + SVG_LENGTHTYPE_CM: number; + SVG_LENGTHTYPE_EMS: number; + SVG_LENGTHTYPE_EXS: number; + SVG_LENGTHTYPE_IN: number; + SVG_LENGTHTYPE_MM: number; + SVG_LENGTHTYPE_NUMBER: number; + SVG_LENGTHTYPE_PC: number; + SVG_LENGTHTYPE_PERCENTAGE: number; + SVG_LENGTHTYPE_PT: number; + SVG_LENGTHTYPE_PX: number; + SVG_LENGTHTYPE_UNKNOWN: number; +} + +declare var SVGLength: { + prototype: SVGLength; + new(): SVGLength; + SVG_LENGTHTYPE_CM: number; + SVG_LENGTHTYPE_EMS: number; + SVG_LENGTHTYPE_EXS: number; + SVG_LENGTHTYPE_IN: number; + SVG_LENGTHTYPE_MM: number; + SVG_LENGTHTYPE_NUMBER: number; + SVG_LENGTHTYPE_PC: number; + SVG_LENGTHTYPE_PERCENTAGE: number; + SVG_LENGTHTYPE_PT: number; + SVG_LENGTHTYPE_PX: number; + SVG_LENGTHTYPE_UNKNOWN: number; +} + +interface SVGLengthList { + numberOfItems: number; + appendItem(newItem: SVGLength): SVGLength; + clear(): void; + getItem(index: number): SVGLength; + initialize(newItem: SVGLength): SVGLength; + insertItemBefore(newItem: SVGLength, index: number): SVGLength; + removeItem(index: number): SVGLength; + replaceItem(newItem: SVGLength, index: number): SVGLength; +} + +declare var SVGLengthList: { + prototype: SVGLengthList; + new(): SVGLengthList; +} + +interface SVGLineElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { + x1: SVGAnimatedLength; + x2: SVGAnimatedLength; + y1: SVGAnimatedLength; + y2: SVGAnimatedLength; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGLineElement: { + prototype: SVGLineElement; + new(): SVGLineElement; +} + +interface SVGLinearGradientElement extends SVGGradientElement { + x1: SVGAnimatedLength; + x2: SVGAnimatedLength; + y1: SVGAnimatedLength; + y2: SVGAnimatedLength; +} + +declare var SVGLinearGradientElement: { + prototype: SVGLinearGradientElement; + new(): SVGLinearGradientElement; +} + +interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox { + markerHeight: SVGAnimatedLength; + markerUnits: SVGAnimatedEnumeration; + markerWidth: SVGAnimatedLength; + orientAngle: SVGAnimatedAngle; + orientType: SVGAnimatedEnumeration; + refX: SVGAnimatedLength; + refY: SVGAnimatedLength; + setOrientToAngle(angle: SVGAngle): void; + setOrientToAuto(): void; + SVG_MARKERUNITS_STROKEWIDTH: number; + SVG_MARKERUNITS_UNKNOWN: number; + SVG_MARKERUNITS_USERSPACEONUSE: number; + SVG_MARKER_ORIENT_ANGLE: number; + SVG_MARKER_ORIENT_AUTO: number; + SVG_MARKER_ORIENT_UNKNOWN: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGMarkerElement: { + prototype: SVGMarkerElement; + new(): SVGMarkerElement; + SVG_MARKERUNITS_STROKEWIDTH: number; + SVG_MARKERUNITS_UNKNOWN: number; + SVG_MARKERUNITS_USERSPACEONUSE: number; + SVG_MARKER_ORIENT_ANGLE: number; + SVG_MARKER_ORIENT_AUTO: number; + SVG_MARKER_ORIENT_UNKNOWN: number; +} + +interface SVGMaskElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGUnitTypes { + height: SVGAnimatedLength; + maskContentUnits: SVGAnimatedEnumeration; + maskUnits: SVGAnimatedEnumeration; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + y: SVGAnimatedLength; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGMaskElement: { + prototype: SVGMaskElement; + new(): SVGMaskElement; +} + +interface SVGMatrix { + a: number; + b: number; + c: number; + d: number; + e: number; + f: number; + flipX(): SVGMatrix; + flipY(): SVGMatrix; + inverse(): SVGMatrix; + multiply(secondMatrix: SVGMatrix): SVGMatrix; + rotate(angle: number): SVGMatrix; + rotateFromVector(x: number, y: number): SVGMatrix; + scale(scaleFactor: number): SVGMatrix; + scaleNonUniform(scaleFactorX: number, scaleFactorY: number): SVGMatrix; + skewX(angle: number): SVGMatrix; + skewY(angle: number): SVGMatrix; + translate(x: number, y: number): SVGMatrix; +} + +declare var SVGMatrix: { + prototype: SVGMatrix; + new(): SVGMatrix; +} + +interface SVGMetadataElement extends SVGElement { +} + +declare var SVGMetadataElement: { + prototype: SVGMetadataElement; + new(): SVGMetadataElement; +} + +interface SVGNumber { + value: number; +} + +declare var SVGNumber: { + prototype: SVGNumber; + new(): SVGNumber; +} + +interface SVGNumberList { + numberOfItems: number; + appendItem(newItem: SVGNumber): SVGNumber; + clear(): void; + getItem(index: number): SVGNumber; + initialize(newItem: SVGNumber): SVGNumber; + insertItemBefore(newItem: SVGNumber, index: number): SVGNumber; + removeItem(index: number): SVGNumber; + replaceItem(newItem: SVGNumber, index: number): SVGNumber; +} + +declare var SVGNumberList: { + prototype: SVGNumberList; + new(): SVGNumberList; +} + +interface SVGPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPathData { + createSVGPathSegArcAbs(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcAbs; + createSVGPathSegArcRel(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcRel; + createSVGPathSegClosePath(): SVGPathSegClosePath; + createSVGPathSegCurvetoCubicAbs(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicAbs; + createSVGPathSegCurvetoCubicRel(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicRel; + createSVGPathSegCurvetoCubicSmoothAbs(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothAbs; + createSVGPathSegCurvetoCubicSmoothRel(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothRel; + createSVGPathSegCurvetoQuadraticAbs(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticAbs; + createSVGPathSegCurvetoQuadraticRel(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticRel; + createSVGPathSegCurvetoQuadraticSmoothAbs(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothAbs; + createSVGPathSegCurvetoQuadraticSmoothRel(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothRel; + createSVGPathSegLinetoAbs(x: number, y: number): SVGPathSegLinetoAbs; + createSVGPathSegLinetoHorizontalAbs(x: number): SVGPathSegLinetoHorizontalAbs; + createSVGPathSegLinetoHorizontalRel(x: number): SVGPathSegLinetoHorizontalRel; + createSVGPathSegLinetoRel(x: number, y: number): SVGPathSegLinetoRel; + createSVGPathSegLinetoVerticalAbs(y: number): SVGPathSegLinetoVerticalAbs; + createSVGPathSegLinetoVerticalRel(y: number): SVGPathSegLinetoVerticalRel; + createSVGPathSegMovetoAbs(x: number, y: number): SVGPathSegMovetoAbs; + createSVGPathSegMovetoRel(x: number, y: number): SVGPathSegMovetoRel; + getPathSegAtLength(distance: number): number; + getPointAtLength(distance: number): SVGPoint; + getTotalLength(): number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGPathElement: { + prototype: SVGPathElement; + new(): SVGPathElement; +} + +interface SVGPathSeg { + pathSegType: number; + pathSegTypeAsLetter: string; + PATHSEG_ARC_ABS: number; + PATHSEG_ARC_REL: number; + PATHSEG_CLOSEPATH: number; + PATHSEG_CURVETO_CUBIC_ABS: number; + PATHSEG_CURVETO_CUBIC_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + PATHSEG_CURVETO_QUADRATIC_ABS: number; + PATHSEG_CURVETO_QUADRATIC_REL: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; + PATHSEG_LINETO_ABS: number; + PATHSEG_LINETO_HORIZONTAL_ABS: number; + PATHSEG_LINETO_HORIZONTAL_REL: number; + PATHSEG_LINETO_REL: number; + PATHSEG_LINETO_VERTICAL_ABS: number; + PATHSEG_LINETO_VERTICAL_REL: number; + PATHSEG_MOVETO_ABS: number; + PATHSEG_MOVETO_REL: number; + PATHSEG_UNKNOWN: number; +} + +declare var SVGPathSeg: { + prototype: SVGPathSeg; + new(): SVGPathSeg; + PATHSEG_ARC_ABS: number; + PATHSEG_ARC_REL: number; + PATHSEG_CLOSEPATH: number; + PATHSEG_CURVETO_CUBIC_ABS: number; + PATHSEG_CURVETO_CUBIC_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + PATHSEG_CURVETO_QUADRATIC_ABS: number; + PATHSEG_CURVETO_QUADRATIC_REL: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; + PATHSEG_LINETO_ABS: number; + PATHSEG_LINETO_HORIZONTAL_ABS: number; + PATHSEG_LINETO_HORIZONTAL_REL: number; + PATHSEG_LINETO_REL: number; + PATHSEG_LINETO_VERTICAL_ABS: number; + PATHSEG_LINETO_VERTICAL_REL: number; + PATHSEG_MOVETO_ABS: number; + PATHSEG_MOVETO_REL: number; + PATHSEG_UNKNOWN: number; +} + +interface SVGPathSegArcAbs extends SVGPathSeg { + angle: number; + largeArcFlag: boolean; + r1: number; + r2: number; + sweepFlag: boolean; + x: number; + y: number; +} + +declare var SVGPathSegArcAbs: { + prototype: SVGPathSegArcAbs; + new(): SVGPathSegArcAbs; +} + +interface SVGPathSegArcRel extends SVGPathSeg { + angle: number; + largeArcFlag: boolean; + r1: number; + r2: number; + sweepFlag: boolean; + x: number; + y: number; +} + +declare var SVGPathSegArcRel: { + prototype: SVGPathSegArcRel; + new(): SVGPathSegArcRel; +} + +interface SVGPathSegClosePath extends SVGPathSeg { +} + +declare var SVGPathSegClosePath: { + prototype: SVGPathSegClosePath; + new(): SVGPathSegClosePath; +} + +interface SVGPathSegCurvetoCubicAbs extends SVGPathSeg { + x: number; + x1: number; + x2: number; + y: number; + y1: number; + y2: number; +} + +declare var SVGPathSegCurvetoCubicAbs: { + prototype: SVGPathSegCurvetoCubicAbs; + new(): SVGPathSegCurvetoCubicAbs; +} + +interface SVGPathSegCurvetoCubicRel extends SVGPathSeg { + x: number; + x1: number; + x2: number; + y: number; + y1: number; + y2: number; +} + +declare var SVGPathSegCurvetoCubicRel: { + prototype: SVGPathSegCurvetoCubicRel; + new(): SVGPathSegCurvetoCubicRel; +} + +interface SVGPathSegCurvetoCubicSmoothAbs extends SVGPathSeg { + x: number; + x2: number; + y: number; + y2: number; +} + +declare var SVGPathSegCurvetoCubicSmoothAbs: { + prototype: SVGPathSegCurvetoCubicSmoothAbs; + new(): SVGPathSegCurvetoCubicSmoothAbs; +} + +interface SVGPathSegCurvetoCubicSmoothRel extends SVGPathSeg { + x: number; + x2: number; + y: number; + y2: number; +} + +declare var SVGPathSegCurvetoCubicSmoothRel: { + prototype: SVGPathSegCurvetoCubicSmoothRel; + new(): SVGPathSegCurvetoCubicSmoothRel; +} + +interface SVGPathSegCurvetoQuadraticAbs extends SVGPathSeg { + x: number; + x1: number; + y: number; + y1: number; +} + +declare var SVGPathSegCurvetoQuadraticAbs: { + prototype: SVGPathSegCurvetoQuadraticAbs; + new(): SVGPathSegCurvetoQuadraticAbs; +} + +interface SVGPathSegCurvetoQuadraticRel extends SVGPathSeg { + x: number; + x1: number; + y: number; + y1: number; +} + +declare var SVGPathSegCurvetoQuadraticRel: { + prototype: SVGPathSegCurvetoQuadraticRel; + new(): SVGPathSegCurvetoQuadraticRel; +} + +interface SVGPathSegCurvetoQuadraticSmoothAbs extends SVGPathSeg { + x: number; + y: number; +} + +declare var SVGPathSegCurvetoQuadraticSmoothAbs: { + prototype: SVGPathSegCurvetoQuadraticSmoothAbs; + new(): SVGPathSegCurvetoQuadraticSmoothAbs; +} + +interface SVGPathSegCurvetoQuadraticSmoothRel extends SVGPathSeg { + x: number; + y: number; +} + +declare var SVGPathSegCurvetoQuadraticSmoothRel: { + prototype: SVGPathSegCurvetoQuadraticSmoothRel; + new(): SVGPathSegCurvetoQuadraticSmoothRel; +} + +interface SVGPathSegLinetoAbs extends SVGPathSeg { + x: number; + y: number; +} + +declare var SVGPathSegLinetoAbs: { + prototype: SVGPathSegLinetoAbs; + new(): SVGPathSegLinetoAbs; +} + +interface SVGPathSegLinetoHorizontalAbs extends SVGPathSeg { + x: number; +} + +declare var SVGPathSegLinetoHorizontalAbs: { + prototype: SVGPathSegLinetoHorizontalAbs; + new(): SVGPathSegLinetoHorizontalAbs; +} + +interface SVGPathSegLinetoHorizontalRel extends SVGPathSeg { + x: number; +} + +declare var SVGPathSegLinetoHorizontalRel: { + prototype: SVGPathSegLinetoHorizontalRel; + new(): SVGPathSegLinetoHorizontalRel; +} + +interface SVGPathSegLinetoRel extends SVGPathSeg { + x: number; + y: number; +} + +declare var SVGPathSegLinetoRel: { + prototype: SVGPathSegLinetoRel; + new(): SVGPathSegLinetoRel; +} + +interface SVGPathSegLinetoVerticalAbs extends SVGPathSeg { + y: number; +} + +declare var SVGPathSegLinetoVerticalAbs: { + prototype: SVGPathSegLinetoVerticalAbs; + new(): SVGPathSegLinetoVerticalAbs; +} + +interface SVGPathSegLinetoVerticalRel extends SVGPathSeg { + y: number; +} + +declare var SVGPathSegLinetoVerticalRel: { + prototype: SVGPathSegLinetoVerticalRel; + new(): SVGPathSegLinetoVerticalRel; +} + +interface SVGPathSegList { + numberOfItems: number; + appendItem(newItem: SVGPathSeg): SVGPathSeg; + clear(): void; + getItem(index: number): SVGPathSeg; + initialize(newItem: SVGPathSeg): SVGPathSeg; + insertItemBefore(newItem: SVGPathSeg, index: number): SVGPathSeg; + removeItem(index: number): SVGPathSeg; + replaceItem(newItem: SVGPathSeg, index: number): SVGPathSeg; +} + +declare var SVGPathSegList: { + prototype: SVGPathSegList; + new(): SVGPathSegList; +} + +interface SVGPathSegMovetoAbs extends SVGPathSeg { + x: number; + y: number; +} + +declare var SVGPathSegMovetoAbs: { + prototype: SVGPathSegMovetoAbs; + new(): SVGPathSegMovetoAbs; +} + +interface SVGPathSegMovetoRel extends SVGPathSeg { + x: number; + y: number; +} + +declare var SVGPathSegMovetoRel: { + prototype: SVGPathSegMovetoRel; + new(): SVGPathSegMovetoRel; +} + +interface SVGPatternElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox, SVGURIReference, SVGUnitTypes { + height: SVGAnimatedLength; + patternContentUnits: SVGAnimatedEnumeration; + patternTransform: SVGAnimatedTransformList; + patternUnits: SVGAnimatedEnumeration; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + y: SVGAnimatedLength; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGPatternElement: { + prototype: SVGPatternElement; + new(): SVGPatternElement; +} + +interface SVGPoint { + x: number; + y: number; + matrixTransform(matrix: SVGMatrix): SVGPoint; +} + +declare var SVGPoint: { + prototype: SVGPoint; + new(): SVGPoint; +} + +interface SVGPointList { + numberOfItems: number; + appendItem(newItem: SVGPoint): SVGPoint; + clear(): void; + getItem(index: number): SVGPoint; + initialize(newItem: SVGPoint): SVGPoint; + insertItemBefore(newItem: SVGPoint, index: number): SVGPoint; + removeItem(index: number): SVGPoint; + replaceItem(newItem: SVGPoint, index: number): SVGPoint; +} + +declare var SVGPointList: { + prototype: SVGPointList; + new(): SVGPointList; +} + +interface SVGPolygonElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPoints { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGPolygonElement: { + prototype: SVGPolygonElement; + new(): SVGPolygonElement; +} + +interface SVGPolylineElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPoints { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGPolylineElement: { + prototype: SVGPolylineElement; + new(): SVGPolylineElement; +} + +interface SVGPreserveAspectRatio { + align: number; + meetOrSlice: number; + SVG_MEETORSLICE_MEET: number; + SVG_MEETORSLICE_SLICE: number; + SVG_MEETORSLICE_UNKNOWN: number; + SVG_PRESERVEASPECTRATIO_NONE: number; + SVG_PRESERVEASPECTRATIO_UNKNOWN: number; + SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + SVG_PRESERVEASPECTRATIO_XMINYMID: number; + SVG_PRESERVEASPECTRATIO_XMINYMIN: number; +} + +declare var SVGPreserveAspectRatio: { + prototype: SVGPreserveAspectRatio; + new(): SVGPreserveAspectRatio; + SVG_MEETORSLICE_MEET: number; + SVG_MEETORSLICE_SLICE: number; + SVG_MEETORSLICE_UNKNOWN: number; + SVG_PRESERVEASPECTRATIO_NONE: number; + SVG_PRESERVEASPECTRATIO_UNKNOWN: number; + SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + SVG_PRESERVEASPECTRATIO_XMINYMID: number; + SVG_PRESERVEASPECTRATIO_XMINYMIN: number; +} + +interface SVGRadialGradientElement extends SVGGradientElement { + cx: SVGAnimatedLength; + cy: SVGAnimatedLength; + fx: SVGAnimatedLength; + fy: SVGAnimatedLength; + r: SVGAnimatedLength; +} + +declare var SVGRadialGradientElement: { + prototype: SVGRadialGradientElement; + new(): SVGRadialGradientElement; +} + +interface SVGRect { + height: number; + width: number; + x: number; + y: number; +} + +declare var SVGRect: { + prototype: SVGRect; + new(): SVGRect; +} + +interface SVGRectElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { + height: SVGAnimatedLength; + rx: SVGAnimatedLength; + ry: SVGAnimatedLength; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + y: SVGAnimatedLength; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGRectElement: { + prototype: SVGRectElement; + new(): SVGRectElement; +} + +interface SVGSVGElement extends SVGElement, DocumentEvent, SVGLocatable, SVGTests, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox, SVGZoomAndPan { + contentScriptType: string; + contentStyleType: string; + currentScale: number; + currentTranslate: SVGPoint; + height: SVGAnimatedLength; + onabort: (ev: Event) => any; + onerror: (ev: Event) => any; + onresize: (ev: UIEvent) => any; + onscroll: (ev: UIEvent) => any; + onunload: (ev: Event) => any; + onzoom: (ev: SVGZoomEvent) => any; + pixelUnitToMillimeterX: number; + pixelUnitToMillimeterY: number; + screenPixelToMillimeterX: number; + screenPixelToMillimeterY: number; + viewport: SVGRect; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + y: SVGAnimatedLength; + checkEnclosure(element: SVGElement, rect: SVGRect): boolean; + checkIntersection(element: SVGElement, rect: SVGRect): boolean; + createSVGAngle(): SVGAngle; + createSVGLength(): SVGLength; + createSVGMatrix(): SVGMatrix; + createSVGNumber(): SVGNumber; + createSVGPoint(): SVGPoint; + createSVGRect(): SVGRect; + createSVGTransform(): SVGTransform; + createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; + deselectAll(): void; + forceRedraw(): void; + getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; + getCurrentTime(): number; + getElementById(elementId: string): Element; + getEnclosureList(rect: SVGRect, referenceElement: SVGElement): NodeList; + getIntersectionList(rect: SVGRect, referenceElement: SVGElement): NodeList; + pauseAnimations(): void; + setCurrentTime(seconds: number): void; + suspendRedraw(maxWaitMilliseconds: number): number; + unpauseAnimations(): void; + unsuspendRedraw(suspendHandleID: number): void; + unsuspendRedrawAll(): void; + addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "SVGAbort", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "SVGError", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "SVGUnload", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "SVGZoom", listener: (ev: SVGZoomEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGSVGElement: { + prototype: SVGSVGElement; + new(): SVGSVGElement; +} + +interface SVGScriptElement extends SVGElement, SVGExternalResourcesRequired, SVGURIReference { + type: string; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGScriptElement: { + prototype: SVGScriptElement; + new(): SVGScriptElement; +} + +interface SVGStopElement extends SVGElement, SVGStylable { + offset: SVGAnimatedNumber; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGStopElement: { + prototype: SVGStopElement; + new(): SVGStopElement; +} + +interface SVGStringList { + numberOfItems: number; + appendItem(newItem: string): string; + clear(): void; + getItem(index: number): string; + initialize(newItem: string): string; + insertItemBefore(newItem: string, index: number): string; + removeItem(index: number): string; + replaceItem(newItem: string, index: number): string; +} + +declare var SVGStringList: { + prototype: SVGStringList; + new(): SVGStringList; +} + +interface SVGStyleElement extends SVGElement, SVGLangSpace { + media: string; + title: string; + type: string; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGStyleElement: { + prototype: SVGStyleElement; + new(): SVGStyleElement; +} + +interface SVGSwitchElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGSwitchElement: { + prototype: SVGSwitchElement; + new(): SVGSwitchElement; +} + +interface SVGSymbolElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGSymbolElement: { + prototype: SVGSymbolElement; + new(): SVGSymbolElement; +} + +interface SVGTSpanElement extends SVGTextPositioningElement { +} + +declare var SVGTSpanElement: { + prototype: SVGTSpanElement; + new(): SVGTSpanElement; +} + +interface SVGTextContentElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { + lengthAdjust: SVGAnimatedEnumeration; + textLength: SVGAnimatedLength; + getCharNumAtPosition(point: SVGPoint): number; + getComputedTextLength(): number; + getEndPositionOfChar(charnum: number): SVGPoint; + getExtentOfChar(charnum: number): SVGRect; + getNumberOfChars(): number; + getRotationOfChar(charnum: number): number; + getStartPositionOfChar(charnum: number): SVGPoint; + getSubStringLength(charnum: number, nchars: number): number; + selectSubString(charnum: number, nchars: number): void; + LENGTHADJUST_SPACING: number; + LENGTHADJUST_SPACINGANDGLYPHS: number; + LENGTHADJUST_UNKNOWN: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTextContentElement: { + prototype: SVGTextContentElement; + new(): SVGTextContentElement; + LENGTHADJUST_SPACING: number; + LENGTHADJUST_SPACINGANDGLYPHS: number; + LENGTHADJUST_UNKNOWN: number; +} + +interface SVGTextElement extends SVGTextPositioningElement, SVGTransformable { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTextElement: { + prototype: SVGTextElement; + new(): SVGTextElement; +} + +interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { + method: SVGAnimatedEnumeration; + spacing: SVGAnimatedEnumeration; + startOffset: SVGAnimatedLength; + TEXTPATH_METHODTYPE_ALIGN: number; + TEXTPATH_METHODTYPE_STRETCH: number; + TEXTPATH_METHODTYPE_UNKNOWN: number; + TEXTPATH_SPACINGTYPE_AUTO: number; + TEXTPATH_SPACINGTYPE_EXACT: number; + TEXTPATH_SPACINGTYPE_UNKNOWN: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTextPathElement: { + prototype: SVGTextPathElement; + new(): SVGTextPathElement; + TEXTPATH_METHODTYPE_ALIGN: number; + TEXTPATH_METHODTYPE_STRETCH: number; + TEXTPATH_METHODTYPE_UNKNOWN: number; + TEXTPATH_SPACINGTYPE_AUTO: number; + TEXTPATH_SPACINGTYPE_EXACT: number; + TEXTPATH_SPACINGTYPE_UNKNOWN: number; +} + +interface SVGTextPositioningElement extends SVGTextContentElement { + dx: SVGAnimatedLengthList; + dy: SVGAnimatedLengthList; + rotate: SVGAnimatedNumberList; + x: SVGAnimatedLengthList; + y: SVGAnimatedLengthList; +} + +declare var SVGTextPositioningElement: { + prototype: SVGTextPositioningElement; + new(): SVGTextPositioningElement; +} + +interface SVGTitleElement extends SVGElement, SVGStylable, SVGLangSpace { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTitleElement: { + prototype: SVGTitleElement; + new(): SVGTitleElement; +} + +interface SVGTransform { + angle: number; + matrix: SVGMatrix; + type: number; + setMatrix(matrix: SVGMatrix): void; + setRotate(angle: number, cx: number, cy: number): void; + setScale(sx: number, sy: number): void; + setSkewX(angle: number): void; + setSkewY(angle: number): void; + setTranslate(tx: number, ty: number): void; + SVG_TRANSFORM_MATRIX: number; + SVG_TRANSFORM_ROTATE: number; + SVG_TRANSFORM_SCALE: number; + SVG_TRANSFORM_SKEWX: number; + SVG_TRANSFORM_SKEWY: number; + SVG_TRANSFORM_TRANSLATE: number; + SVG_TRANSFORM_UNKNOWN: number; +} + +declare var SVGTransform: { + prototype: SVGTransform; + new(): SVGTransform; + SVG_TRANSFORM_MATRIX: number; + SVG_TRANSFORM_ROTATE: number; + SVG_TRANSFORM_SCALE: number; + SVG_TRANSFORM_SKEWX: number; + SVG_TRANSFORM_SKEWY: number; + SVG_TRANSFORM_TRANSLATE: number; + SVG_TRANSFORM_UNKNOWN: number; +} + +interface SVGTransformList { + numberOfItems: number; + appendItem(newItem: SVGTransform): SVGTransform; + clear(): void; + consolidate(): SVGTransform; + createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; + getItem(index: number): SVGTransform; + initialize(newItem: SVGTransform): SVGTransform; + insertItemBefore(newItem: SVGTransform, index: number): SVGTransform; + removeItem(index: number): SVGTransform; + replaceItem(newItem: SVGTransform, index: number): SVGTransform; +} + +declare var SVGTransformList: { + prototype: SVGTransformList; + new(): SVGTransformList; +} + +interface SVGUnitTypes { + SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; + SVG_UNIT_TYPE_UNKNOWN: number; + SVG_UNIT_TYPE_USERSPACEONUSE: number; +} +declare var SVGUnitTypes: SVGUnitTypes; + +interface SVGUseElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { + animatedInstanceRoot: SVGElementInstance; + height: SVGAnimatedLength; + instanceRoot: SVGElementInstance; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + y: SVGAnimatedLength; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGUseElement: { + prototype: SVGUseElement; + new(): SVGUseElement; +} + +interface SVGViewElement extends SVGElement, SVGExternalResourcesRequired, SVGFitToViewBox, SVGZoomAndPan { + viewTarget: SVGStringList; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGViewElement: { + prototype: SVGViewElement; + new(): SVGViewElement; +} + +interface SVGZoomAndPan { + zoomAndPan: number; +} + +declare var SVGZoomAndPan: { + SVG_ZOOMANDPAN_DISABLE: number; + SVG_ZOOMANDPAN_MAGNIFY: number; + SVG_ZOOMANDPAN_UNKNOWN: number; +} + +interface SVGZoomEvent extends UIEvent { + newScale: number; + newTranslate: SVGPoint; + previousScale: number; + previousTranslate: SVGPoint; + zoomRectScreen: SVGRect; +} + +declare var SVGZoomEvent: { + prototype: SVGZoomEvent; + new(): SVGZoomEvent; +} + +interface Screen extends EventTarget { + availHeight: number; + availWidth: number; + bufferDepth: number; + colorDepth: number; + deviceXDPI: number; + deviceYDPI: number; + fontSmoothingEnabled: boolean; + height: number; + logicalXDPI: number; + logicalYDPI: number; + msOrientation: string; + onmsorientationchange: (ev: Event) => any; + pixelDepth: number; + systemXDPI: number; + systemYDPI: number; + width: number; + msLockOrientation(orientations: string | string[]): boolean; + msUnlockOrientation(): void; + addEventListener(type: "MSOrientationChange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Screen: { + prototype: Screen; + new(): Screen; +} + +interface ScriptNotifyEvent extends Event { + callingUri: string; + value: string; +} + +declare var ScriptNotifyEvent: { + prototype: ScriptNotifyEvent; + new(): ScriptNotifyEvent; +} + +interface ScriptProcessorNode extends AudioNode { + bufferSize: number; + onaudioprocess: (ev: AudioProcessingEvent) => any; + addEventListener(type: "audioprocess", listener: (ev: AudioProcessingEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ScriptProcessorNode: { + prototype: ScriptProcessorNode; + new(): ScriptProcessorNode; +} + +interface Selection { + anchorNode: Node; + anchorOffset: number; + focusNode: Node; + focusOffset: number; + isCollapsed: boolean; + rangeCount: number; + type: string; + addRange(range: Range): void; + collapse(parentNode: Node, offset: number): void; + collapseToEnd(): void; + collapseToStart(): void; + containsNode(node: Node, partlyContained: boolean): boolean; + deleteFromDocument(): void; + empty(): void; + extend(newNode: Node, offset: number): void; + getRangeAt(index: number): Range; + removeAllRanges(): void; + removeRange(range: Range): void; + selectAllChildren(parentNode: Node): void; + setBaseAndExtent(baseNode: Node, baseOffset: number, extentNode: Node, extentOffset: number): void; + toString(): string; +} + +declare var Selection: { + prototype: Selection; + new(): Selection; +} + +interface SourceBuffer extends EventTarget { + appendWindowEnd: number; + appendWindowStart: number; + audioTracks: AudioTrackList; + buffered: TimeRanges; + mode: string; + timestampOffset: number; + updating: boolean; + videoTracks: VideoTrackList; + abort(): void; + appendBuffer(data: ArrayBuffer | ArrayBufferView): void; + appendStream(stream: MSStream, maxSize?: number): void; + remove(start: number, end: number): void; +} + +declare var SourceBuffer: { + prototype: SourceBuffer; + new(): SourceBuffer; +} + +interface SourceBufferList extends EventTarget { + length: number; + item(index: number): SourceBuffer; + [index: number]: SourceBuffer; +} + +declare var SourceBufferList: { + prototype: SourceBufferList; + new(): SourceBufferList; +} + +interface StereoPannerNode extends AudioNode { + pan: AudioParam; +} + +declare var StereoPannerNode: { + prototype: StereoPannerNode; + new(): StereoPannerNode; +} + +interface Storage { + length: number; + clear(): void; + getItem(key: string): any; + key(index: number): string; + removeItem(key: string): void; + setItem(key: string, data: string): void; + [key: string]: any; + [index: number]: string; +} + +declare var Storage: { + prototype: Storage; + new(): Storage; +} + +interface StorageEvent extends Event { + url: string; + key?: string; + oldValue?: string; + newValue?: string; + storageArea?: Storage; +} + +declare var StorageEvent: { + prototype: StorageEvent; + new (type: string, eventInitDict?: StorageEventInit): StorageEvent; +} + +interface StyleMedia { + type: string; + matchMedium(mediaquery: string): boolean; +} + +declare var StyleMedia: { + prototype: StyleMedia; + new(): StyleMedia; +} + +interface StyleSheet { + disabled: boolean; + href: string; + media: MediaList; + ownerNode: Node; + parentStyleSheet: StyleSheet; + title: string; + type: string; +} + +declare var StyleSheet: { + prototype: StyleSheet; + new(): StyleSheet; +} + +interface StyleSheetList { + length: number; + item(index?: number): StyleSheet; + [index: number]: StyleSheet; +} + +declare var StyleSheetList: { + prototype: StyleSheetList; + new(): StyleSheetList; +} + +interface StyleSheetPageList { + length: number; + item(index: number): CSSPageRule; + [index: number]: CSSPageRule; +} + +declare var StyleSheetPageList: { + prototype: StyleSheetPageList; + new(): StyleSheetPageList; +} + +interface SubtleCrypto { + decrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; + deriveBits(algorithm: string | Algorithm, baseKey: CryptoKey, length: number): any; + deriveKey(algorithm: string | Algorithm, baseKey: CryptoKey, derivedKeyType: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + digest(algorithm: string | Algorithm, data: ArrayBufferView): any; + encrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; + exportKey(format: string, key: CryptoKey): any; + generateKey(algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + importKey(format: string, keyData: ArrayBufferView, algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + sign(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; + unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | Algorithm, unwrappedKeyAlgorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + verify(algorithm: string | Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; + wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | Algorithm): any; +} + +declare var SubtleCrypto: { + prototype: SubtleCrypto; + new(): SubtleCrypto; +} + +interface Text extends CharacterData { + wholeText: string; + replaceWholeText(content: string): Text; + splitText(offset: number): Text; +} + +declare var Text: { + prototype: Text; + new(): Text; +} + +interface TextEvent extends UIEvent { + data: string; + inputMethod: number; + locale: string; + initTextEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, inputMethod: number, locale: string): void; + DOM_INPUT_METHOD_DROP: number; + DOM_INPUT_METHOD_HANDWRITING: number; + DOM_INPUT_METHOD_IME: number; + DOM_INPUT_METHOD_KEYBOARD: number; + DOM_INPUT_METHOD_MULTIMODAL: number; + DOM_INPUT_METHOD_OPTION: number; + DOM_INPUT_METHOD_PASTE: number; + DOM_INPUT_METHOD_SCRIPT: number; + DOM_INPUT_METHOD_UNKNOWN: number; + DOM_INPUT_METHOD_VOICE: number; +} + +declare var TextEvent: { + prototype: TextEvent; + new(): TextEvent; + DOM_INPUT_METHOD_DROP: number; + DOM_INPUT_METHOD_HANDWRITING: number; + DOM_INPUT_METHOD_IME: number; + DOM_INPUT_METHOD_KEYBOARD: number; + DOM_INPUT_METHOD_MULTIMODAL: number; + DOM_INPUT_METHOD_OPTION: number; + DOM_INPUT_METHOD_PASTE: number; + DOM_INPUT_METHOD_SCRIPT: number; + DOM_INPUT_METHOD_UNKNOWN: number; + DOM_INPUT_METHOD_VOICE: number; +} + +interface TextMetrics { + width: number; +} + +declare var TextMetrics: { + prototype: TextMetrics; + new(): TextMetrics; +} + +interface TextRange { + boundingHeight: number; + boundingLeft: number; + boundingTop: number; + boundingWidth: number; + htmlText: string; + offsetLeft: number; + offsetTop: number; + text: string; + collapse(start?: boolean): void; + compareEndPoints(how: string, sourceRange: TextRange): number; + duplicate(): TextRange; + execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; + execCommandShowHelp(cmdID: string): boolean; + expand(Unit: string): boolean; + findText(string: string, count?: number, flags?: number): boolean; + getBookmark(): string; + getBoundingClientRect(): ClientRect; + getClientRects(): ClientRectList; + inRange(range: TextRange): boolean; + isEqual(range: TextRange): boolean; + move(unit: string, count?: number): number; + moveEnd(unit: string, count?: number): number; + moveStart(unit: string, count?: number): number; + moveToBookmark(bookmark: string): boolean; + moveToElementText(element: Element): void; + moveToPoint(x: number, y: number): void; + parentElement(): Element; + pasteHTML(html: string): void; + queryCommandEnabled(cmdID: string): boolean; + queryCommandIndeterm(cmdID: string): boolean; + queryCommandState(cmdID: string): boolean; + queryCommandSupported(cmdID: string): boolean; + queryCommandText(cmdID: string): string; + queryCommandValue(cmdID: string): any; + scrollIntoView(fStart?: boolean): void; + select(): void; + setEndPoint(how: string, SourceRange: TextRange): void; +} + +declare var TextRange: { + prototype: TextRange; + new(): TextRange; +} + +interface TextRangeCollection { + length: number; + item(index: number): TextRange; + [index: number]: TextRange; +} + +declare var TextRangeCollection: { + prototype: TextRangeCollection; + new(): TextRangeCollection; +} + +interface TextTrack extends EventTarget { + activeCues: TextTrackCueList; + cues: TextTrackCueList; + inBandMetadataTrackDispatchType: string; + kind: string; + label: string; + language: string; + mode: any; + oncuechange: (ev: Event) => any; + onerror: (ev: Event) => any; + onload: (ev: Event) => any; + readyState: number; + addCue(cue: TextTrackCue): void; + removeCue(cue: TextTrackCue): void; + DISABLED: number; + ERROR: number; + HIDDEN: number; + LOADED: number; + LOADING: number; + NONE: number; + SHOWING: number; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var TextTrack: { + prototype: TextTrack; + new(): TextTrack; + DISABLED: number; + ERROR: number; + HIDDEN: number; + LOADED: number; + LOADING: number; + NONE: number; + SHOWING: number; +} + +interface TextTrackCue extends EventTarget { + endTime: number; + id: string; + onenter: (ev: Event) => any; + onexit: (ev: Event) => any; + pauseOnExit: boolean; + startTime: number; + text: string; + track: TextTrack; + getCueAsHTML(): DocumentFragment; + addEventListener(type: "enter", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "exit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var TextTrackCue: { + prototype: TextTrackCue; + new(startTime: number, endTime: number, text: string): TextTrackCue; +} + +interface TextTrackCueList { + length: number; + getCueById(id: string): TextTrackCue; + item(index: number): TextTrackCue; + [index: number]: TextTrackCue; +} + +declare var TextTrackCueList: { + prototype: TextTrackCueList; + new(): TextTrackCueList; +} + +interface TextTrackList extends EventTarget { + length: number; + onaddtrack: (ev: TrackEvent) => any; + item(index: number): TextTrack; + addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + [index: number]: TextTrack; +} + +declare var TextTrackList: { + prototype: TextTrackList; + new(): TextTrackList; +} + +interface TimeRanges { + length: number; + end(index: number): number; + start(index: number): number; +} + +declare var TimeRanges: { + prototype: TimeRanges; + new(): TimeRanges; +} + +interface Touch { + clientX: number; + clientY: number; + identifier: number; + pageX: number; + pageY: number; + screenX: number; + screenY: number; + target: EventTarget; +} + +declare var Touch: { + prototype: Touch; + new(): Touch; +} + +interface TouchEvent extends UIEvent { + altKey: boolean; + changedTouches: TouchList; + ctrlKey: boolean; + metaKey: boolean; + shiftKey: boolean; + targetTouches: TouchList; + touches: TouchList; +} + +declare var TouchEvent: { + prototype: TouchEvent; + new(): TouchEvent; +} + +interface TouchList { + length: number; + item(index: number): Touch; + [index: number]: Touch; +} + +declare var TouchList: { + prototype: TouchList; + new(): TouchList; +} + +interface TrackEvent extends Event { + track: any; +} + +declare var TrackEvent: { + prototype: TrackEvent; + new(): TrackEvent; +} + +interface TransitionEvent extends Event { + elapsedTime: number; + propertyName: string; + initTransitionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, propertyNameArg: string, elapsedTimeArg: number): void; +} + +declare var TransitionEvent: { + prototype: TransitionEvent; + new(): TransitionEvent; +} + +interface TreeWalker { + currentNode: Node; + expandEntityReferences: boolean; + filter: NodeFilter; + root: Node; + whatToShow: number; + firstChild(): Node; + lastChild(): Node; + nextNode(): Node; + nextSibling(): Node; + parentNode(): Node; + previousNode(): Node; + previousSibling(): Node; +} + +declare var TreeWalker: { + prototype: TreeWalker; + new(): TreeWalker; +} + +interface UIEvent extends Event { + detail: number; + view: Window; + initUIEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number): void; +} + +declare var UIEvent: { + prototype: UIEvent; + new(type: string, eventInitDict?: UIEventInit): UIEvent; +} + +interface URL { + createObjectURL(object: any, options?: ObjectURLOptions): string; + revokeObjectURL(url: string): void; +} +declare var URL: URL; + +interface UnviewableContentIdentifiedEvent extends NavigationEventWithReferrer { + mediaType: string; +} + +declare var UnviewableContentIdentifiedEvent: { + prototype: UnviewableContentIdentifiedEvent; + new(): UnviewableContentIdentifiedEvent; +} + +interface ValidityState { + badInput: boolean; + customError: boolean; + patternMismatch: boolean; + rangeOverflow: boolean; + rangeUnderflow: boolean; + stepMismatch: boolean; + tooLong: boolean; + typeMismatch: boolean; + valid: boolean; + valueMissing: boolean; +} + +declare var ValidityState: { + prototype: ValidityState; + new(): ValidityState; +} + +interface VideoPlaybackQuality { + corruptedVideoFrames: number; + creationTime: number; + droppedVideoFrames: number; + totalFrameDelay: number; + totalVideoFrames: number; +} + +declare var VideoPlaybackQuality: { + prototype: VideoPlaybackQuality; + new(): VideoPlaybackQuality; +} + +interface VideoTrack { + id: string; + kind: string; + label: string; + language: string; + selected: boolean; + sourceBuffer: SourceBuffer; +} + +declare var VideoTrack: { + prototype: VideoTrack; + new(): VideoTrack; +} + +interface VideoTrackList extends EventTarget { + length: number; + onaddtrack: (ev: TrackEvent) => any; + onchange: (ev: Event) => any; + onremovetrack: (ev: TrackEvent) => any; + selectedIndex: number; + getTrackById(id: string): VideoTrack; + item(index: number): VideoTrack; + addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "removetrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + [index: number]: VideoTrack; +} + +declare var VideoTrackList: { + prototype: VideoTrackList; + new(): VideoTrackList; +} + +interface WEBGL_compressed_texture_s3tc { + COMPRESSED_RGBA_S3TC_DXT1_EXT: number; + COMPRESSED_RGBA_S3TC_DXT3_EXT: number; + COMPRESSED_RGBA_S3TC_DXT5_EXT: number; + COMPRESSED_RGB_S3TC_DXT1_EXT: number; +} + +declare var WEBGL_compressed_texture_s3tc: { + prototype: WEBGL_compressed_texture_s3tc; + new(): WEBGL_compressed_texture_s3tc; + COMPRESSED_RGBA_S3TC_DXT1_EXT: number; + COMPRESSED_RGBA_S3TC_DXT3_EXT: number; + COMPRESSED_RGBA_S3TC_DXT5_EXT: number; + COMPRESSED_RGB_S3TC_DXT1_EXT: number; +} + +interface WEBGL_debug_renderer_info { + UNMASKED_RENDERER_WEBGL: number; + UNMASKED_VENDOR_WEBGL: number; +} + +declare var WEBGL_debug_renderer_info: { + prototype: WEBGL_debug_renderer_info; + new(): WEBGL_debug_renderer_info; + UNMASKED_RENDERER_WEBGL: number; + UNMASKED_VENDOR_WEBGL: number; +} + +interface WEBGL_depth_texture { + UNSIGNED_INT_24_8_WEBGL: number; +} + +declare var WEBGL_depth_texture: { + prototype: WEBGL_depth_texture; + new(): WEBGL_depth_texture; + UNSIGNED_INT_24_8_WEBGL: number; +} + +interface WaveShaperNode extends AudioNode { + curve: Float32Array; + oversample: string; +} + +declare var WaveShaperNode: { + prototype: WaveShaperNode; + new(): WaveShaperNode; +} + +interface WebGLActiveInfo { + name: string; + size: number; + type: number; +} + +declare var WebGLActiveInfo: { + prototype: WebGLActiveInfo; + new(): WebGLActiveInfo; +} + +interface WebGLBuffer extends WebGLObject { +} + +declare var WebGLBuffer: { + prototype: WebGLBuffer; + new(): WebGLBuffer; +} + +interface WebGLContextEvent extends Event { + statusMessage: string; +} + +declare var WebGLContextEvent: { + prototype: WebGLContextEvent; + new(): WebGLContextEvent; +} + +interface WebGLFramebuffer extends WebGLObject { +} + +declare var WebGLFramebuffer: { + prototype: WebGLFramebuffer; + new(): WebGLFramebuffer; +} + +interface WebGLObject { +} + +declare var WebGLObject: { + prototype: WebGLObject; + new(): WebGLObject; +} + +interface WebGLProgram extends WebGLObject { +} + +declare var WebGLProgram: { + prototype: WebGLProgram; + new(): WebGLProgram; +} + +interface WebGLRenderbuffer extends WebGLObject { +} + +declare var WebGLRenderbuffer: { + prototype: WebGLRenderbuffer; + new(): WebGLRenderbuffer; +} + +interface WebGLRenderingContext { + canvas: HTMLCanvasElement; + drawingBufferHeight: number; + drawingBufferWidth: number; + activeTexture(texture: number): void; + attachShader(program: WebGLProgram, shader: WebGLShader): void; + bindAttribLocation(program: WebGLProgram, index: number, name: string): void; + bindBuffer(target: number, buffer: WebGLBuffer): void; + bindFramebuffer(target: number, framebuffer: WebGLFramebuffer): void; + bindRenderbuffer(target: number, renderbuffer: WebGLRenderbuffer): void; + bindTexture(target: number, texture: WebGLTexture): void; + blendColor(red: number, green: number, blue: number, alpha: number): void; + blendEquation(mode: number): void; + blendEquationSeparate(modeRGB: number, modeAlpha: number): void; + blendFunc(sfactor: number, dfactor: number): void; + blendFuncSeparate(srcRGB: number, dstRGB: number, srcAlpha: number, dstAlpha: number): void; + bufferData(target: number, size: number | ArrayBufferView | ArrayBuffer, usage: number): void; + bufferSubData(target: number, offset: number, data: ArrayBufferView | ArrayBuffer): void; + checkFramebufferStatus(target: number): number; + clear(mask: number): void; + clearColor(red: number, green: number, blue: number, alpha: number): void; + clearDepth(depth: number): void; + clearStencil(s: number): void; + colorMask(red: boolean, green: boolean, blue: boolean, alpha: boolean): void; + compileShader(shader: WebGLShader): void; + compressedTexImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, data: ArrayBufferView): void; + compressedTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, data: ArrayBufferView): void; + copyTexImage2D(target: number, level: number, internalformat: number, x: number, y: number, width: number, height: number, border: number): void; + copyTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, x: number, y: number, width: number, height: number): void; + createBuffer(): WebGLBuffer; + createFramebuffer(): WebGLFramebuffer; + createProgram(): WebGLProgram; + createRenderbuffer(): WebGLRenderbuffer; + createShader(type: number): WebGLShader; + createTexture(): WebGLTexture; + cullFace(mode: number): void; + deleteBuffer(buffer: WebGLBuffer): void; + deleteFramebuffer(framebuffer: WebGLFramebuffer): void; + deleteProgram(program: WebGLProgram): void; + deleteRenderbuffer(renderbuffer: WebGLRenderbuffer): void; + deleteShader(shader: WebGLShader): void; + deleteTexture(texture: WebGLTexture): void; + depthFunc(func: number): void; + depthMask(flag: boolean): void; + depthRange(zNear: number, zFar: number): void; + detachShader(program: WebGLProgram, shader: WebGLShader): void; + disable(cap: number): void; + disableVertexAttribArray(index: number): void; + drawArrays(mode: number, first: number, count: number): void; + drawElements(mode: number, count: number, type: number, offset: number): void; + enable(cap: number): void; + enableVertexAttribArray(index: number): void; + finish(): void; + flush(): void; + framebufferRenderbuffer(target: number, attachment: number, renderbuffertarget: number, renderbuffer: WebGLRenderbuffer): void; + framebufferTexture2D(target: number, attachment: number, textarget: number, texture: WebGLTexture, level: number): void; + frontFace(mode: number): void; + generateMipmap(target: number): void; + getActiveAttrib(program: WebGLProgram, index: number): WebGLActiveInfo; + getActiveUniform(program: WebGLProgram, index: number): WebGLActiveInfo; + getAttachedShaders(program: WebGLProgram): WebGLShader[]; + getAttribLocation(program: WebGLProgram, name: string): number; + getBufferParameter(target: number, pname: number): any; + getContextAttributes(): WebGLContextAttributes; + getError(): number; + getExtension(name: string): any; + getFramebufferAttachmentParameter(target: number, attachment: number, pname: number): any; + getParameter(pname: number): any; + getProgramInfoLog(program: WebGLProgram): string; + getProgramParameter(program: WebGLProgram, pname: number): any; + getRenderbufferParameter(target: number, pname: number): any; + getShaderInfoLog(shader: WebGLShader): string; + getShaderParameter(shader: WebGLShader, pname: number): any; + getShaderPrecisionFormat(shadertype: number, precisiontype: number): WebGLShaderPrecisionFormat; + getShaderSource(shader: WebGLShader): string; + getSupportedExtensions(): string[]; + getTexParameter(target: number, pname: number): any; + getUniform(program: WebGLProgram, location: WebGLUniformLocation): any; + getUniformLocation(program: WebGLProgram, name: string): WebGLUniformLocation; + getVertexAttrib(index: number, pname: number): any; + getVertexAttribOffset(index: number, pname: number): number; + hint(target: number, mode: number): void; + isBuffer(buffer: WebGLBuffer): boolean; + isContextLost(): boolean; + isEnabled(cap: number): boolean; + isFramebuffer(framebuffer: WebGLFramebuffer): boolean; + isProgram(program: WebGLProgram): boolean; + isRenderbuffer(renderbuffer: WebGLRenderbuffer): boolean; + isShader(shader: WebGLShader): boolean; + isTexture(texture: WebGLTexture): boolean; + lineWidth(width: number): void; + linkProgram(program: WebGLProgram): void; + pixelStorei(pname: number, param: number): void; + polygonOffset(factor: number, units: number): void; + readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void; + renderbufferStorage(target: number, internalformat: number, width: number, height: number): void; + sampleCoverage(value: number, invert: boolean): void; + scissor(x: number, y: number, width: number, height: number): void; + shaderSource(shader: WebGLShader, source: string): void; + stencilFunc(func: number, ref: number, mask: number): void; + stencilFuncSeparate(face: number, func: number, ref: number, mask: number): void; + stencilMask(mask: number): void; + stencilMaskSeparate(face: number, mask: number): void; + stencilOp(fail: number, zfail: number, zpass: number): void; + stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void; + texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels: ArrayBufferView): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, image: HTMLImageElement): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, canvas: HTMLCanvasElement): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, video: HTMLVideoElement): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageData): void; + texParameterf(target: number, pname: number, param: number): void; + texParameteri(target: number, pname: number, param: number): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, image: HTMLImageElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, canvas: HTMLCanvasElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void; + uniform1f(location: WebGLUniformLocation, x: number): void; + uniform1fv(location: WebGLUniformLocation, v: Float32Array): void; + uniform1i(location: WebGLUniformLocation, x: number): void; + uniform1iv(location: WebGLUniformLocation, v: Int32Array): void; + uniform2f(location: WebGLUniformLocation, x: number, y: number): void; + uniform2fv(location: WebGLUniformLocation, v: Float32Array): void; + uniform2i(location: WebGLUniformLocation, x: number, y: number): void; + uniform2iv(location: WebGLUniformLocation, v: Int32Array): void; + uniform3f(location: WebGLUniformLocation, x: number, y: number, z: number): void; + uniform3fv(location: WebGLUniformLocation, v: Float32Array): void; + uniform3i(location: WebGLUniformLocation, x: number, y: number, z: number): void; + uniform3iv(location: WebGLUniformLocation, v: Int32Array): void; + uniform4f(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; + uniform4fv(location: WebGLUniformLocation, v: Float32Array): void; + uniform4i(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; + uniform4iv(location: WebGLUniformLocation, v: Int32Array): void; + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + useProgram(program: WebGLProgram): void; + validateProgram(program: WebGLProgram): void; + vertexAttrib1f(indx: number, x: number): void; + vertexAttrib1fv(indx: number, values: Float32Array): void; + vertexAttrib2f(indx: number, x: number, y: number): void; + vertexAttrib2fv(indx: number, values: Float32Array): void; + vertexAttrib3f(indx: number, x: number, y: number, z: number): void; + vertexAttrib3fv(indx: number, values: Float32Array): void; + vertexAttrib4f(indx: number, x: number, y: number, z: number, w: number): void; + vertexAttrib4fv(indx: number, values: Float32Array): void; + vertexAttribPointer(indx: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void; + viewport(x: number, y: number, width: number, height: number): void; + ACTIVE_ATTRIBUTES: number; + ACTIVE_TEXTURE: number; + ACTIVE_UNIFORMS: number; + ALIASED_LINE_WIDTH_RANGE: number; + ALIASED_POINT_SIZE_RANGE: number; + ALPHA: number; + ALPHA_BITS: number; + ALWAYS: number; + ARRAY_BUFFER: number; + ARRAY_BUFFER_BINDING: number; + ATTACHED_SHADERS: number; + BACK: number; + BLEND: number; + BLEND_COLOR: number; + BLEND_DST_ALPHA: number; + BLEND_DST_RGB: number; + BLEND_EQUATION: number; + BLEND_EQUATION_ALPHA: number; + BLEND_EQUATION_RGB: number; + BLEND_SRC_ALPHA: number; + BLEND_SRC_RGB: number; + BLUE_BITS: number; + BOOL: number; + BOOL_VEC2: number; + BOOL_VEC3: number; + BOOL_VEC4: number; + BROWSER_DEFAULT_WEBGL: number; + BUFFER_SIZE: number; + BUFFER_USAGE: number; + BYTE: number; + CCW: number; + CLAMP_TO_EDGE: number; + COLOR_ATTACHMENT0: number; + COLOR_BUFFER_BIT: number; + COLOR_CLEAR_VALUE: number; + COLOR_WRITEMASK: number; + COMPILE_STATUS: number; + COMPRESSED_TEXTURE_FORMATS: number; + CONSTANT_ALPHA: number; + CONSTANT_COLOR: number; + CONTEXT_LOST_WEBGL: number; + CULL_FACE: number; + CULL_FACE_MODE: number; + CURRENT_PROGRAM: number; + CURRENT_VERTEX_ATTRIB: number; + CW: number; + DECR: number; + DECR_WRAP: number; + DELETE_STATUS: number; + DEPTH_ATTACHMENT: number; + DEPTH_BITS: number; + DEPTH_BUFFER_BIT: number; + DEPTH_CLEAR_VALUE: number; + DEPTH_COMPONENT: number; + DEPTH_COMPONENT16: number; + DEPTH_FUNC: number; + DEPTH_RANGE: number; + DEPTH_STENCIL: number; + DEPTH_STENCIL_ATTACHMENT: number; + DEPTH_TEST: number; + DEPTH_WRITEMASK: number; + DITHER: number; + DONT_CARE: number; + DST_ALPHA: number; + DST_COLOR: number; + DYNAMIC_DRAW: number; + ELEMENT_ARRAY_BUFFER: number; + ELEMENT_ARRAY_BUFFER_BINDING: number; + EQUAL: number; + FASTEST: number; + FLOAT: number; + FLOAT_MAT2: number; + FLOAT_MAT3: number; + FLOAT_MAT4: number; + FLOAT_VEC2: number; + FLOAT_VEC3: number; + FLOAT_VEC4: number; + FRAGMENT_SHADER: number; + FRAMEBUFFER: number; + FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: number; + FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: number; + FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: number; + FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: number; + FRAMEBUFFER_BINDING: number; + FRAMEBUFFER_COMPLETE: number; + FRAMEBUFFER_INCOMPLETE_ATTACHMENT: number; + FRAMEBUFFER_INCOMPLETE_DIMENSIONS: number; + FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: number; + FRAMEBUFFER_UNSUPPORTED: number; + FRONT: number; + FRONT_AND_BACK: number; + FRONT_FACE: number; + FUNC_ADD: number; + FUNC_REVERSE_SUBTRACT: number; + FUNC_SUBTRACT: number; + GENERATE_MIPMAP_HINT: number; + GEQUAL: number; + GREATER: number; + GREEN_BITS: number; + HIGH_FLOAT: number; + HIGH_INT: number; + IMPLEMENTATION_COLOR_READ_FORMAT: number; + IMPLEMENTATION_COLOR_READ_TYPE: number; + INCR: number; + INCR_WRAP: number; + INT: number; + INT_VEC2: number; + INT_VEC3: number; + INT_VEC4: number; + INVALID_ENUM: number; + INVALID_FRAMEBUFFER_OPERATION: number; + INVALID_OPERATION: number; + INVALID_VALUE: number; + INVERT: number; + KEEP: number; + LEQUAL: number; + LESS: number; + LINEAR: number; + LINEAR_MIPMAP_LINEAR: number; + LINEAR_MIPMAP_NEAREST: number; + LINES: number; + LINE_LOOP: number; + LINE_STRIP: number; + LINE_WIDTH: number; + LINK_STATUS: number; + LOW_FLOAT: number; + LOW_INT: number; + LUMINANCE: number; + LUMINANCE_ALPHA: number; + MAX_COMBINED_TEXTURE_IMAGE_UNITS: number; + MAX_CUBE_MAP_TEXTURE_SIZE: number; + MAX_FRAGMENT_UNIFORM_VECTORS: number; + MAX_RENDERBUFFER_SIZE: number; + MAX_TEXTURE_IMAGE_UNITS: number; + MAX_TEXTURE_SIZE: number; + MAX_VARYING_VECTORS: number; + MAX_VERTEX_ATTRIBS: number; + MAX_VERTEX_TEXTURE_IMAGE_UNITS: number; + MAX_VERTEX_UNIFORM_VECTORS: number; + MAX_VIEWPORT_DIMS: number; + MEDIUM_FLOAT: number; + MEDIUM_INT: number; + MIRRORED_REPEAT: number; + NEAREST: number; + NEAREST_MIPMAP_LINEAR: number; + NEAREST_MIPMAP_NEAREST: number; + NEVER: number; + NICEST: number; + NONE: number; + NOTEQUAL: number; + NO_ERROR: number; + ONE: number; + ONE_MINUS_CONSTANT_ALPHA: number; + ONE_MINUS_CONSTANT_COLOR: number; + ONE_MINUS_DST_ALPHA: number; + ONE_MINUS_DST_COLOR: number; + ONE_MINUS_SRC_ALPHA: number; + ONE_MINUS_SRC_COLOR: number; + OUT_OF_MEMORY: number; + PACK_ALIGNMENT: number; + POINTS: number; + POLYGON_OFFSET_FACTOR: number; + POLYGON_OFFSET_FILL: number; + POLYGON_OFFSET_UNITS: number; + RED_BITS: number; + RENDERBUFFER: number; + RENDERBUFFER_ALPHA_SIZE: number; + RENDERBUFFER_BINDING: number; + RENDERBUFFER_BLUE_SIZE: number; + RENDERBUFFER_DEPTH_SIZE: number; + RENDERBUFFER_GREEN_SIZE: number; + RENDERBUFFER_HEIGHT: number; + RENDERBUFFER_INTERNAL_FORMAT: number; + RENDERBUFFER_RED_SIZE: number; + RENDERBUFFER_STENCIL_SIZE: number; + RENDERBUFFER_WIDTH: number; + RENDERER: number; + REPEAT: number; + REPLACE: number; + RGB: number; + RGB565: number; + RGB5_A1: number; + RGBA: number; + RGBA4: number; + SAMPLER_2D: number; + SAMPLER_CUBE: number; + SAMPLES: number; + SAMPLE_ALPHA_TO_COVERAGE: number; + SAMPLE_BUFFERS: number; + SAMPLE_COVERAGE: number; + SAMPLE_COVERAGE_INVERT: number; + SAMPLE_COVERAGE_VALUE: number; + SCISSOR_BOX: number; + SCISSOR_TEST: number; + SHADER_TYPE: number; + SHADING_LANGUAGE_VERSION: number; + SHORT: number; + SRC_ALPHA: number; + SRC_ALPHA_SATURATE: number; + SRC_COLOR: number; + STATIC_DRAW: number; + STENCIL_ATTACHMENT: number; + STENCIL_BACK_FAIL: number; + STENCIL_BACK_FUNC: number; + STENCIL_BACK_PASS_DEPTH_FAIL: number; + STENCIL_BACK_PASS_DEPTH_PASS: number; + STENCIL_BACK_REF: number; + STENCIL_BACK_VALUE_MASK: number; + STENCIL_BACK_WRITEMASK: number; + STENCIL_BITS: number; + STENCIL_BUFFER_BIT: number; + STENCIL_CLEAR_VALUE: number; + STENCIL_FAIL: number; + STENCIL_FUNC: number; + STENCIL_INDEX: number; + STENCIL_INDEX8: number; + STENCIL_PASS_DEPTH_FAIL: number; + STENCIL_PASS_DEPTH_PASS: number; + STENCIL_REF: number; + STENCIL_TEST: number; + STENCIL_VALUE_MASK: number; + STENCIL_WRITEMASK: number; + STREAM_DRAW: number; + SUBPIXEL_BITS: number; + TEXTURE: number; + TEXTURE0: number; + TEXTURE1: number; + TEXTURE10: number; + TEXTURE11: number; + TEXTURE12: number; + TEXTURE13: number; + TEXTURE14: number; + TEXTURE15: number; + TEXTURE16: number; + TEXTURE17: number; + TEXTURE18: number; + TEXTURE19: number; + TEXTURE2: number; + TEXTURE20: number; + TEXTURE21: number; + TEXTURE22: number; + TEXTURE23: number; + TEXTURE24: number; + TEXTURE25: number; + TEXTURE26: number; + TEXTURE27: number; + TEXTURE28: number; + TEXTURE29: number; + TEXTURE3: number; + TEXTURE30: number; + TEXTURE31: number; + TEXTURE4: number; + TEXTURE5: number; + TEXTURE6: number; + TEXTURE7: number; + TEXTURE8: number; + TEXTURE9: number; + TEXTURE_2D: number; + TEXTURE_BINDING_2D: number; + TEXTURE_BINDING_CUBE_MAP: number; + TEXTURE_CUBE_MAP: number; + TEXTURE_CUBE_MAP_NEGATIVE_X: number; + TEXTURE_CUBE_MAP_NEGATIVE_Y: number; + TEXTURE_CUBE_MAP_NEGATIVE_Z: number; + TEXTURE_CUBE_MAP_POSITIVE_X: number; + TEXTURE_CUBE_MAP_POSITIVE_Y: number; + TEXTURE_CUBE_MAP_POSITIVE_Z: number; + TEXTURE_MAG_FILTER: number; + TEXTURE_MIN_FILTER: number; + TEXTURE_WRAP_S: number; + TEXTURE_WRAP_T: number; + TRIANGLES: number; + TRIANGLE_FAN: number; + TRIANGLE_STRIP: number; + UNPACK_ALIGNMENT: number; + UNPACK_COLORSPACE_CONVERSION_WEBGL: number; + UNPACK_FLIP_Y_WEBGL: number; + UNPACK_PREMULTIPLY_ALPHA_WEBGL: number; + UNSIGNED_BYTE: number; + UNSIGNED_INT: number; + UNSIGNED_SHORT: number; + UNSIGNED_SHORT_4_4_4_4: number; + UNSIGNED_SHORT_5_5_5_1: number; + UNSIGNED_SHORT_5_6_5: number; + VALIDATE_STATUS: number; + VENDOR: number; + VERSION: number; + VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: number; + VERTEX_ATTRIB_ARRAY_ENABLED: number; + VERTEX_ATTRIB_ARRAY_NORMALIZED: number; + VERTEX_ATTRIB_ARRAY_POINTER: number; + VERTEX_ATTRIB_ARRAY_SIZE: number; + VERTEX_ATTRIB_ARRAY_STRIDE: number; + VERTEX_ATTRIB_ARRAY_TYPE: number; + VERTEX_SHADER: number; + VIEWPORT: number; + ZERO: number; +} + +declare var WebGLRenderingContext: { + prototype: WebGLRenderingContext; + new(): WebGLRenderingContext; + ACTIVE_ATTRIBUTES: number; + ACTIVE_TEXTURE: number; + ACTIVE_UNIFORMS: number; + ALIASED_LINE_WIDTH_RANGE: number; + ALIASED_POINT_SIZE_RANGE: number; + ALPHA: number; + ALPHA_BITS: number; + ALWAYS: number; + ARRAY_BUFFER: number; + ARRAY_BUFFER_BINDING: number; + ATTACHED_SHADERS: number; + BACK: number; + BLEND: number; + BLEND_COLOR: number; + BLEND_DST_ALPHA: number; + BLEND_DST_RGB: number; + BLEND_EQUATION: number; + BLEND_EQUATION_ALPHA: number; + BLEND_EQUATION_RGB: number; + BLEND_SRC_ALPHA: number; + BLEND_SRC_RGB: number; + BLUE_BITS: number; + BOOL: number; + BOOL_VEC2: number; + BOOL_VEC3: number; + BOOL_VEC4: number; + BROWSER_DEFAULT_WEBGL: number; + BUFFER_SIZE: number; + BUFFER_USAGE: number; + BYTE: number; + CCW: number; + CLAMP_TO_EDGE: number; + COLOR_ATTACHMENT0: number; + COLOR_BUFFER_BIT: number; + COLOR_CLEAR_VALUE: number; + COLOR_WRITEMASK: number; + COMPILE_STATUS: number; + COMPRESSED_TEXTURE_FORMATS: number; + CONSTANT_ALPHA: number; + CONSTANT_COLOR: number; + CONTEXT_LOST_WEBGL: number; + CULL_FACE: number; + CULL_FACE_MODE: number; + CURRENT_PROGRAM: number; + CURRENT_VERTEX_ATTRIB: number; + CW: number; + DECR: number; + DECR_WRAP: number; + DELETE_STATUS: number; + DEPTH_ATTACHMENT: number; + DEPTH_BITS: number; + DEPTH_BUFFER_BIT: number; + DEPTH_CLEAR_VALUE: number; + DEPTH_COMPONENT: number; + DEPTH_COMPONENT16: number; + DEPTH_FUNC: number; + DEPTH_RANGE: number; + DEPTH_STENCIL: number; + DEPTH_STENCIL_ATTACHMENT: number; + DEPTH_TEST: number; + DEPTH_WRITEMASK: number; + DITHER: number; + DONT_CARE: number; + DST_ALPHA: number; + DST_COLOR: number; + DYNAMIC_DRAW: number; + ELEMENT_ARRAY_BUFFER: number; + ELEMENT_ARRAY_BUFFER_BINDING: number; + EQUAL: number; + FASTEST: number; + FLOAT: number; + FLOAT_MAT2: number; + FLOAT_MAT3: number; + FLOAT_MAT4: number; + FLOAT_VEC2: number; + FLOAT_VEC3: number; + FLOAT_VEC4: number; + FRAGMENT_SHADER: number; + FRAMEBUFFER: number; + FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: number; + FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: number; + FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: number; + FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: number; + FRAMEBUFFER_BINDING: number; + FRAMEBUFFER_COMPLETE: number; + FRAMEBUFFER_INCOMPLETE_ATTACHMENT: number; + FRAMEBUFFER_INCOMPLETE_DIMENSIONS: number; + FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: number; + FRAMEBUFFER_UNSUPPORTED: number; + FRONT: number; + FRONT_AND_BACK: number; + FRONT_FACE: number; + FUNC_ADD: number; + FUNC_REVERSE_SUBTRACT: number; + FUNC_SUBTRACT: number; + GENERATE_MIPMAP_HINT: number; + GEQUAL: number; + GREATER: number; + GREEN_BITS: number; + HIGH_FLOAT: number; + HIGH_INT: number; + IMPLEMENTATION_COLOR_READ_FORMAT: number; + IMPLEMENTATION_COLOR_READ_TYPE: number; + INCR: number; + INCR_WRAP: number; + INT: number; + INT_VEC2: number; + INT_VEC3: number; + INT_VEC4: number; + INVALID_ENUM: number; + INVALID_FRAMEBUFFER_OPERATION: number; + INVALID_OPERATION: number; + INVALID_VALUE: number; + INVERT: number; + KEEP: number; + LEQUAL: number; + LESS: number; + LINEAR: number; + LINEAR_MIPMAP_LINEAR: number; + LINEAR_MIPMAP_NEAREST: number; + LINES: number; + LINE_LOOP: number; + LINE_STRIP: number; + LINE_WIDTH: number; + LINK_STATUS: number; + LOW_FLOAT: number; + LOW_INT: number; + LUMINANCE: number; + LUMINANCE_ALPHA: number; + MAX_COMBINED_TEXTURE_IMAGE_UNITS: number; + MAX_CUBE_MAP_TEXTURE_SIZE: number; + MAX_FRAGMENT_UNIFORM_VECTORS: number; + MAX_RENDERBUFFER_SIZE: number; + MAX_TEXTURE_IMAGE_UNITS: number; + MAX_TEXTURE_SIZE: number; + MAX_VARYING_VECTORS: number; + MAX_VERTEX_ATTRIBS: number; + MAX_VERTEX_TEXTURE_IMAGE_UNITS: number; + MAX_VERTEX_UNIFORM_VECTORS: number; + MAX_VIEWPORT_DIMS: number; + MEDIUM_FLOAT: number; + MEDIUM_INT: number; + MIRRORED_REPEAT: number; + NEAREST: number; + NEAREST_MIPMAP_LINEAR: number; + NEAREST_MIPMAP_NEAREST: number; + NEVER: number; + NICEST: number; + NONE: number; + NOTEQUAL: number; + NO_ERROR: number; + ONE: number; + ONE_MINUS_CONSTANT_ALPHA: number; + ONE_MINUS_CONSTANT_COLOR: number; + ONE_MINUS_DST_ALPHA: number; + ONE_MINUS_DST_COLOR: number; + ONE_MINUS_SRC_ALPHA: number; + ONE_MINUS_SRC_COLOR: number; + OUT_OF_MEMORY: number; + PACK_ALIGNMENT: number; + POINTS: number; + POLYGON_OFFSET_FACTOR: number; + POLYGON_OFFSET_FILL: number; + POLYGON_OFFSET_UNITS: number; + RED_BITS: number; + RENDERBUFFER: number; + RENDERBUFFER_ALPHA_SIZE: number; + RENDERBUFFER_BINDING: number; + RENDERBUFFER_BLUE_SIZE: number; + RENDERBUFFER_DEPTH_SIZE: number; + RENDERBUFFER_GREEN_SIZE: number; + RENDERBUFFER_HEIGHT: number; + RENDERBUFFER_INTERNAL_FORMAT: number; + RENDERBUFFER_RED_SIZE: number; + RENDERBUFFER_STENCIL_SIZE: number; + RENDERBUFFER_WIDTH: number; + RENDERER: number; + REPEAT: number; + REPLACE: number; + RGB: number; + RGB565: number; + RGB5_A1: number; + RGBA: number; + RGBA4: number; + SAMPLER_2D: number; + SAMPLER_CUBE: number; + SAMPLES: number; + SAMPLE_ALPHA_TO_COVERAGE: number; + SAMPLE_BUFFERS: number; + SAMPLE_COVERAGE: number; + SAMPLE_COVERAGE_INVERT: number; + SAMPLE_COVERAGE_VALUE: number; + SCISSOR_BOX: number; + SCISSOR_TEST: number; + SHADER_TYPE: number; + SHADING_LANGUAGE_VERSION: number; + SHORT: number; + SRC_ALPHA: number; + SRC_ALPHA_SATURATE: number; + SRC_COLOR: number; + STATIC_DRAW: number; + STENCIL_ATTACHMENT: number; + STENCIL_BACK_FAIL: number; + STENCIL_BACK_FUNC: number; + STENCIL_BACK_PASS_DEPTH_FAIL: number; + STENCIL_BACK_PASS_DEPTH_PASS: number; + STENCIL_BACK_REF: number; + STENCIL_BACK_VALUE_MASK: number; + STENCIL_BACK_WRITEMASK: number; + STENCIL_BITS: number; + STENCIL_BUFFER_BIT: number; + STENCIL_CLEAR_VALUE: number; + STENCIL_FAIL: number; + STENCIL_FUNC: number; + STENCIL_INDEX: number; + STENCIL_INDEX8: number; + STENCIL_PASS_DEPTH_FAIL: number; + STENCIL_PASS_DEPTH_PASS: number; + STENCIL_REF: number; + STENCIL_TEST: number; + STENCIL_VALUE_MASK: number; + STENCIL_WRITEMASK: number; + STREAM_DRAW: number; + SUBPIXEL_BITS: number; + TEXTURE: number; + TEXTURE0: number; + TEXTURE1: number; + TEXTURE10: number; + TEXTURE11: number; + TEXTURE12: number; + TEXTURE13: number; + TEXTURE14: number; + TEXTURE15: number; + TEXTURE16: number; + TEXTURE17: number; + TEXTURE18: number; + TEXTURE19: number; + TEXTURE2: number; + TEXTURE20: number; + TEXTURE21: number; + TEXTURE22: number; + TEXTURE23: number; + TEXTURE24: number; + TEXTURE25: number; + TEXTURE26: number; + TEXTURE27: number; + TEXTURE28: number; + TEXTURE29: number; + TEXTURE3: number; + TEXTURE30: number; + TEXTURE31: number; + TEXTURE4: number; + TEXTURE5: number; + TEXTURE6: number; + TEXTURE7: number; + TEXTURE8: number; + TEXTURE9: number; + TEXTURE_2D: number; + TEXTURE_BINDING_2D: number; + TEXTURE_BINDING_CUBE_MAP: number; + TEXTURE_CUBE_MAP: number; + TEXTURE_CUBE_MAP_NEGATIVE_X: number; + TEXTURE_CUBE_MAP_NEGATIVE_Y: number; + TEXTURE_CUBE_MAP_NEGATIVE_Z: number; + TEXTURE_CUBE_MAP_POSITIVE_X: number; + TEXTURE_CUBE_MAP_POSITIVE_Y: number; + TEXTURE_CUBE_MAP_POSITIVE_Z: number; + TEXTURE_MAG_FILTER: number; + TEXTURE_MIN_FILTER: number; + TEXTURE_WRAP_S: number; + TEXTURE_WRAP_T: number; + TRIANGLES: number; + TRIANGLE_FAN: number; + TRIANGLE_STRIP: number; + UNPACK_ALIGNMENT: number; + UNPACK_COLORSPACE_CONVERSION_WEBGL: number; + UNPACK_FLIP_Y_WEBGL: number; + UNPACK_PREMULTIPLY_ALPHA_WEBGL: number; + UNSIGNED_BYTE: number; + UNSIGNED_INT: number; + UNSIGNED_SHORT: number; + UNSIGNED_SHORT_4_4_4_4: number; + UNSIGNED_SHORT_5_5_5_1: number; + UNSIGNED_SHORT_5_6_5: number; + VALIDATE_STATUS: number; + VENDOR: number; + VERSION: number; + VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: number; + VERTEX_ATTRIB_ARRAY_ENABLED: number; + VERTEX_ATTRIB_ARRAY_NORMALIZED: number; + VERTEX_ATTRIB_ARRAY_POINTER: number; + VERTEX_ATTRIB_ARRAY_SIZE: number; + VERTEX_ATTRIB_ARRAY_STRIDE: number; + VERTEX_ATTRIB_ARRAY_TYPE: number; + VERTEX_SHADER: number; + VIEWPORT: number; + ZERO: number; +} + +interface WebGLShader extends WebGLObject { +} + +declare var WebGLShader: { + prototype: WebGLShader; + new(): WebGLShader; +} + +interface WebGLShaderPrecisionFormat { + precision: number; + rangeMax: number; + rangeMin: number; +} + +declare var WebGLShaderPrecisionFormat: { + prototype: WebGLShaderPrecisionFormat; + new(): WebGLShaderPrecisionFormat; +} + +interface WebGLTexture extends WebGLObject { +} + +declare var WebGLTexture: { + prototype: WebGLTexture; + new(): WebGLTexture; +} + +interface WebGLUniformLocation { +} + +declare var WebGLUniformLocation: { + prototype: WebGLUniformLocation; + new(): WebGLUniformLocation; +} + +interface WebKitCSSMatrix { + a: number; + b: number; + c: number; + d: number; + e: number; + f: number; + m11: number; + m12: number; + m13: number; + m14: number; + m21: number; + m22: number; + m23: number; + m24: number; + m31: number; + m32: number; + m33: number; + m34: number; + m41: number; + m42: number; + m43: number; + m44: number; + inverse(): WebKitCSSMatrix; + multiply(secondMatrix: WebKitCSSMatrix): WebKitCSSMatrix; + rotate(angleX: number, angleY?: number, angleZ?: number): WebKitCSSMatrix; + rotateAxisAngle(x: number, y: number, z: number, angle: number): WebKitCSSMatrix; + scale(scaleX: number, scaleY?: number, scaleZ?: number): WebKitCSSMatrix; + setMatrixValue(value: string): void; + skewX(angle: number): WebKitCSSMatrix; + skewY(angle: number): WebKitCSSMatrix; + toString(): string; + translate(x: number, y: number, z?: number): WebKitCSSMatrix; +} + +declare var WebKitCSSMatrix: { + prototype: WebKitCSSMatrix; + new(text?: string): WebKitCSSMatrix; +} + +interface WebKitPoint { + x: number; + y: number; +} + +declare var WebKitPoint: { + prototype: WebKitPoint; + new(x?: number, y?: number): WebKitPoint; +} + +interface WebSocket extends EventTarget { + binaryType: string; + bufferedAmount: number; + extensions: string; + onclose: (ev: CloseEvent) => any; + onerror: (ev: Event) => any; + onmessage: (ev: MessageEvent) => any; + onopen: (ev: Event) => any; + protocol: string; + readyState: number; + url: string; + close(code?: number, reason?: string): void; + send(data: any): void; + CLOSED: number; + CLOSING: number; + CONNECTING: number; + OPEN: number; + addEventListener(type: "close", listener: (ev: CloseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "open", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var WebSocket: { + prototype: WebSocket; + new(url: string, protocols?: string | string[]): WebSocket; + CLOSED: number; + CLOSING: number; + CONNECTING: number; + OPEN: number; +} + +interface WheelEvent extends MouseEvent { + deltaMode: number; + deltaX: number; + deltaY: number; + deltaZ: number; + getCurrentPoint(element: Element): void; + initWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, deltaXArg: number, deltaYArg: number, deltaZArg: number, deltaMode: number): void; + DOM_DELTA_LINE: number; + DOM_DELTA_PAGE: number; + DOM_DELTA_PIXEL: number; +} + +declare var WheelEvent: { + prototype: WheelEvent; + new(typeArg: string, eventInitDict?: WheelEventInit): WheelEvent; + DOM_DELTA_LINE: number; + DOM_DELTA_PAGE: number; + DOM_DELTA_PIXEL: number; +} + +interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64 { + animationStartTime: number; + applicationCache: ApplicationCache; + clientInformation: Navigator; + closed: boolean; + crypto: Crypto; + defaultStatus: string; + devicePixelRatio: number; + doNotTrack: string; + document: Document; + event: Event; + external: External; + frameElement: Element; + frames: Window; + history: History; + innerHeight: number; + innerWidth: number; + length: number; + location: Location; + locationbar: BarProp; + menubar: BarProp; + msAnimationStartTime: number; + name: string; + navigator: Navigator; + offscreenBuffering: string | boolean; + onabort: (ev: Event) => any; + onafterprint: (ev: Event) => any; + onbeforeprint: (ev: Event) => any; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + onblur: (ev: FocusEvent) => any; + oncanplay: (ev: Event) => any; + oncanplaythrough: (ev: Event) => any; + onchange: (ev: Event) => any; + onclick: (ev: MouseEvent) => any; + oncompassneedscalibration: (ev: Event) => any; + oncontextmenu: (ev: PointerEvent) => any; + ondblclick: (ev: MouseEvent) => any; + ondevicemotion: (ev: DeviceMotionEvent) => any; + ondeviceorientation: (ev: DeviceOrientationEvent) => any; + ondrag: (ev: DragEvent) => any; + ondragend: (ev: DragEvent) => any; + ondragenter: (ev: DragEvent) => any; + ondragleave: (ev: DragEvent) => any; + ondragover: (ev: DragEvent) => any; + ondragstart: (ev: DragEvent) => any; + ondrop: (ev: DragEvent) => any; + ondurationchange: (ev: Event) => any; + onemptied: (ev: Event) => any; + onended: (ev: Event) => any; + onerror: ErrorEventHandler; + onfocus: (ev: FocusEvent) => any; + onhashchange: (ev: HashChangeEvent) => any; + oninput: (ev: Event) => any; + onkeydown: (ev: KeyboardEvent) => any; + onkeypress: (ev: KeyboardEvent) => any; + onkeyup: (ev: KeyboardEvent) => any; + onload: (ev: Event) => any; + onloadeddata: (ev: Event) => any; + onloadedmetadata: (ev: Event) => any; + onloadstart: (ev: Event) => any; + onmessage: (ev: MessageEvent) => any; + onmousedown: (ev: MouseEvent) => any; + onmouseenter: (ev: MouseEvent) => any; + onmouseleave: (ev: MouseEvent) => any; + onmousemove: (ev: MouseEvent) => any; + onmouseout: (ev: MouseEvent) => any; + onmouseover: (ev: MouseEvent) => any; + onmouseup: (ev: MouseEvent) => any; + onmousewheel: (ev: MouseWheelEvent) => any; + onmsgesturechange: (ev: MSGestureEvent) => any; + onmsgesturedoubletap: (ev: MSGestureEvent) => any; + onmsgestureend: (ev: MSGestureEvent) => any; + onmsgesturehold: (ev: MSGestureEvent) => any; + onmsgesturestart: (ev: MSGestureEvent) => any; + onmsgesturetap: (ev: MSGestureEvent) => any; + onmsinertiastart: (ev: MSGestureEvent) => any; + onmspointercancel: (ev: MSPointerEvent) => any; + onmspointerdown: (ev: MSPointerEvent) => any; + onmspointerenter: (ev: MSPointerEvent) => any; + onmspointerleave: (ev: MSPointerEvent) => any; + onmspointermove: (ev: MSPointerEvent) => any; + onmspointerout: (ev: MSPointerEvent) => any; + onmspointerover: (ev: MSPointerEvent) => any; + onmspointerup: (ev: MSPointerEvent) => any; + onoffline: (ev: Event) => any; + ononline: (ev: Event) => any; + onorientationchange: (ev: Event) => any; + onpagehide: (ev: PageTransitionEvent) => any; + onpageshow: (ev: PageTransitionEvent) => any; + onpause: (ev: Event) => any; + onplay: (ev: Event) => any; + onplaying: (ev: Event) => any; + onpopstate: (ev: PopStateEvent) => any; + onprogress: (ev: ProgressEvent) => any; + onratechange: (ev: Event) => any; + onreadystatechange: (ev: ProgressEvent) => any; + onreset: (ev: Event) => any; + onresize: (ev: UIEvent) => any; + onscroll: (ev: UIEvent) => any; + onseeked: (ev: Event) => any; + onseeking: (ev: Event) => any; + onselect: (ev: UIEvent) => any; + onstalled: (ev: Event) => any; + onstorage: (ev: StorageEvent) => any; + onsubmit: (ev: Event) => any; + onsuspend: (ev: Event) => any; + ontimeupdate: (ev: Event) => any; + ontouchcancel: any; + ontouchend: any; + ontouchmove: any; + ontouchstart: any; + onunload: (ev: Event) => any; + onvolumechange: (ev: Event) => any; + onwaiting: (ev: Event) => any; + opener: Window; + orientation: string | number; + outerHeight: number; + outerWidth: number; + pageXOffset: number; + pageYOffset: number; + parent: Window; + performance: Performance; + personalbar: BarProp; + screen: Screen; + screenLeft: number; + screenTop: number; + screenX: number; + screenY: number; + scrollX: number; + scrollY: number; + scrollbars: BarProp; + self: Window; + status: string; + statusbar: BarProp; + styleMedia: StyleMedia; + toolbar: BarProp; + top: Window; + window: Window; + URL: URL; + alert(message?: any): void; + blur(): void; + cancelAnimationFrame(handle: number): void; + captureEvents(): void; + close(): void; + confirm(message?: string): boolean; + focus(): void; + getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; + getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; + getSelection(): Selection; + matchMedia(mediaQuery: string): MediaQueryList; + moveBy(x?: number, y?: number): void; + moveTo(x?: number, y?: number): void; + msCancelRequestAnimationFrame(handle: number): void; + msMatchMedia(mediaQuery: string): MediaQueryList; + msRequestAnimationFrame(callback: FrameRequestCallback): number; + msWriteProfilerMark(profilerMarkName: string): void; + open(url?: string, target?: string, features?: string, replace?: boolean): Window; + postMessage(message: any, targetOrigin: string, ports?: any): void; + print(): void; + prompt(message?: string, _default?: string): string; + releaseEvents(): void; + requestAnimationFrame(callback: FrameRequestCallback): number; + resizeBy(x?: number, y?: number): void; + resizeTo(x?: number, y?: number): void; + scroll(x?: number, y?: number): void; + scrollBy(x?: number, y?: number): void; + scrollTo(x?: number, y?: number): void; + webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; + webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; + addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "compassneedscalibration", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "devicemotion", listener: (ev: DeviceMotionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deviceorientation", listener: (ev: DeviceOrientationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "hashchange", listener: (ev: HashChangeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "orientationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + [index: number]: Window; +} + +declare var Window: { + prototype: Window; + new(): Window; +} + +interface Worker extends EventTarget, AbstractWorker { + onmessage: (ev: MessageEvent) => any; + postMessage(message: any, ports?: any): void; + terminate(): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Worker: { + prototype: Worker; + new(stringUrl: string): Worker; +} + +interface XMLDocument extends Document { +} + +declare var XMLDocument: { + prototype: XMLDocument; + new(): XMLDocument; +} + +interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { + msCaching: string; + onreadystatechange: (ev: ProgressEvent) => any; + readyState: number; + response: any; + responseBody: any; + responseText: string; + responseType: string; + responseXML: any; + status: number; + statusText: string; + timeout: number; + upload: XMLHttpRequestUpload; + withCredentials: boolean; + abort(): void; + getAllResponseHeaders(): string; + getResponseHeader(header: string): string; + msCachingEnabled(): boolean; + open(method: string, url: string, async?: boolean, user?: string, password?: string): void; + overrideMimeType(mime: string): void; + send(data?: Document): void; + send(data?: string): void; + send(data?: any): void; + setRequestHeader(header: string, value: string): void; + DONE: number; + HEADERS_RECEIVED: number; + LOADING: number; + OPENED: number; + UNSENT: number; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeout", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var XMLHttpRequest: { + prototype: XMLHttpRequest; + new(): XMLHttpRequest; + DONE: number; + HEADERS_RECEIVED: number; + LOADING: number; + OPENED: number; + UNSENT: number; + create(): XMLHttpRequest; +} + +interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var XMLHttpRequestUpload: { + prototype: XMLHttpRequestUpload; + new(): XMLHttpRequestUpload; +} + +interface XMLSerializer { + serializeToString(target: Node): string; +} + +declare var XMLSerializer: { + prototype: XMLSerializer; + new(): XMLSerializer; +} + +interface XPathEvaluator { + createExpression(expression: string, resolver: XPathNSResolver): XPathExpression; + createNSResolver(nodeResolver?: Node): XPathNSResolver; + evaluate(expression: string, contextNode: Node, resolver: XPathNSResolver, type: number, result: XPathResult): XPathResult; +} + +declare var XPathEvaluator: { + prototype: XPathEvaluator; + new(): XPathEvaluator; +} + +interface XPathExpression { + evaluate(contextNode: Node, type: number, result: XPathResult): XPathExpression; +} + +declare var XPathExpression: { + prototype: XPathExpression; + new(): XPathExpression; +} + +interface XPathNSResolver { + lookupNamespaceURI(prefix: string): string; +} + +declare var XPathNSResolver: { + prototype: XPathNSResolver; + new(): XPathNSResolver; +} + +interface XPathResult { + booleanValue: boolean; + invalidIteratorState: boolean; + numberValue: number; + resultType: number; + singleNodeValue: Node; + snapshotLength: number; + stringValue: string; + iterateNext(): Node; + snapshotItem(index: number): Node; + ANY_TYPE: number; + ANY_UNORDERED_NODE_TYPE: number; + BOOLEAN_TYPE: number; + FIRST_ORDERED_NODE_TYPE: number; + NUMBER_TYPE: number; + ORDERED_NODE_ITERATOR_TYPE: number; + ORDERED_NODE_SNAPSHOT_TYPE: number; + STRING_TYPE: number; + UNORDERED_NODE_ITERATOR_TYPE: number; + UNORDERED_NODE_SNAPSHOT_TYPE: number; +} + +declare var XPathResult: { + prototype: XPathResult; + new(): XPathResult; + ANY_TYPE: number; + ANY_UNORDERED_NODE_TYPE: number; + BOOLEAN_TYPE: number; + FIRST_ORDERED_NODE_TYPE: number; + NUMBER_TYPE: number; + ORDERED_NODE_ITERATOR_TYPE: number; + ORDERED_NODE_SNAPSHOT_TYPE: number; + STRING_TYPE: number; + UNORDERED_NODE_ITERATOR_TYPE: number; + UNORDERED_NODE_SNAPSHOT_TYPE: number; +} + +interface XSLTProcessor { + clearParameters(): void; + getParameter(namespaceURI: string, localName: string): any; + importStylesheet(style: Node): void; + removeParameter(namespaceURI: string, localName: string): void; + reset(): void; + setParameter(namespaceURI: string, localName: string, value: any): void; + transformToDocument(source: Node): Document; + transformToFragment(source: Node, document: Document): DocumentFragment; +} + +declare var XSLTProcessor: { + prototype: XSLTProcessor; + new(): XSLTProcessor; +} + +interface AbstractWorker { + onerror: (ev: Event) => any; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface ChildNode { + remove(): void; +} + +interface DOML2DeprecatedColorProperty { + color: string; +} + +interface DOML2DeprecatedSizeProperty { + size: number; +} + +interface DocumentEvent { + createEvent(eventInterface:"AnimationEvent"): AnimationEvent; + createEvent(eventInterface:"AriaRequestEvent"): AriaRequestEvent; + createEvent(eventInterface:"AudioProcessingEvent"): AudioProcessingEvent; + createEvent(eventInterface:"BeforeUnloadEvent"): BeforeUnloadEvent; + createEvent(eventInterface:"ClipboardEvent"): ClipboardEvent; + createEvent(eventInterface:"CloseEvent"): CloseEvent; + createEvent(eventInterface:"CommandEvent"): CommandEvent; + createEvent(eventInterface:"CompositionEvent"): CompositionEvent; + createEvent(eventInterface:"CustomEvent"): CustomEvent; + createEvent(eventInterface:"DeviceMotionEvent"): DeviceMotionEvent; + createEvent(eventInterface:"DeviceOrientationEvent"): DeviceOrientationEvent; + createEvent(eventInterface:"DragEvent"): DragEvent; + createEvent(eventInterface:"ErrorEvent"): ErrorEvent; + createEvent(eventInterface:"Event"): Event; + createEvent(eventInterface:"Events"): Event; + createEvent(eventInterface:"FocusEvent"): FocusEvent; + createEvent(eventInterface:"GamepadEvent"): GamepadEvent; + createEvent(eventInterface:"HashChangeEvent"): HashChangeEvent; + createEvent(eventInterface:"IDBVersionChangeEvent"): IDBVersionChangeEvent; + createEvent(eventInterface:"KeyboardEvent"): KeyboardEvent; + createEvent(eventInterface:"LongRunningScriptDetectedEvent"): LongRunningScriptDetectedEvent; + createEvent(eventInterface:"MSGestureEvent"): MSGestureEvent; + createEvent(eventInterface:"MSManipulationEvent"): MSManipulationEvent; + createEvent(eventInterface:"MSMediaKeyMessageEvent"): MSMediaKeyMessageEvent; + createEvent(eventInterface:"MSMediaKeyNeededEvent"): MSMediaKeyNeededEvent; + createEvent(eventInterface:"MSPointerEvent"): MSPointerEvent; + createEvent(eventInterface:"MSSiteModeEvent"): MSSiteModeEvent; + createEvent(eventInterface:"MessageEvent"): MessageEvent; + createEvent(eventInterface:"MouseEvent"): MouseEvent; + createEvent(eventInterface:"MouseEvents"): MouseEvent; + createEvent(eventInterface:"MouseWheelEvent"): MouseWheelEvent; + createEvent(eventInterface:"MutationEvent"): MutationEvent; + createEvent(eventInterface:"MutationEvents"): MutationEvent; + createEvent(eventInterface:"NavigationCompletedEvent"): NavigationCompletedEvent; + createEvent(eventInterface:"NavigationEvent"): NavigationEvent; + createEvent(eventInterface:"NavigationEventWithReferrer"): NavigationEventWithReferrer; + createEvent(eventInterface:"OfflineAudioCompletionEvent"): OfflineAudioCompletionEvent; + createEvent(eventInterface:"PageTransitionEvent"): PageTransitionEvent; + createEvent(eventInterface:"PermissionRequestedEvent"): PermissionRequestedEvent; + createEvent(eventInterface:"PointerEvent"): PointerEvent; + createEvent(eventInterface:"PopStateEvent"): PopStateEvent; + createEvent(eventInterface:"ProgressEvent"): ProgressEvent; + createEvent(eventInterface:"SVGZoomEvent"): SVGZoomEvent; + createEvent(eventInterface:"SVGZoomEvents"): SVGZoomEvent; + createEvent(eventInterface:"ScriptNotifyEvent"): ScriptNotifyEvent; + createEvent(eventInterface:"StorageEvent"): StorageEvent; + createEvent(eventInterface:"TextEvent"): TextEvent; + createEvent(eventInterface:"TouchEvent"): TouchEvent; + createEvent(eventInterface:"TrackEvent"): TrackEvent; + createEvent(eventInterface:"TransitionEvent"): TransitionEvent; + createEvent(eventInterface:"UIEvent"): UIEvent; + createEvent(eventInterface:"UIEvents"): UIEvent; + createEvent(eventInterface:"UnviewableContentIdentifiedEvent"): UnviewableContentIdentifiedEvent; + createEvent(eventInterface:"WebGLContextEvent"): WebGLContextEvent; + createEvent(eventInterface:"WheelEvent"): WheelEvent; + createEvent(eventInterface: string): Event; +} + +interface ElementTraversal { + childElementCount: number; + firstElementChild: Element; + lastElementChild: Element; + nextElementSibling: Element; + previousElementSibling: Element; +} + +interface GetSVGDocument { + getSVGDocument(): Document; +} + +interface GlobalEventHandlers { + onpointercancel: (ev: PointerEvent) => any; + onpointerdown: (ev: PointerEvent) => any; + onpointerenter: (ev: PointerEvent) => any; + onpointerleave: (ev: PointerEvent) => any; + onpointermove: (ev: PointerEvent) => any; + onpointerout: (ev: PointerEvent) => any; + onpointerover: (ev: PointerEvent) => any; + onpointerup: (ev: PointerEvent) => any; + onwheel: (ev: WheelEvent) => any; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface HTMLTableAlignment { + /** + * Sets or retrieves a value that you can use to implement your own ch functionality for the object. + */ + ch: string; + /** + * Sets or retrieves a value that you can use to implement your own chOff functionality for the object. + */ + chOff: string; + /** + * Sets or retrieves how text and other content are vertically aligned within the object that contains them. + */ + vAlign: string; +} + +interface IDBEnvironment { + indexedDB: IDBFactory; + msIndexedDB: IDBFactory; +} + +interface LinkStyle { + sheet: StyleSheet; +} + +interface MSBaseReader { + onabort: (ev: Event) => any; + onerror: (ev: Event) => any; + onload: (ev: Event) => any; + onloadend: (ev: ProgressEvent) => any; + onloadstart: (ev: Event) => any; + onprogress: (ev: ProgressEvent) => any; + readyState: number; + result: any; + abort(): void; + DONE: number; + EMPTY: number; + LOADING: number; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface MSFileSaver { + msSaveBlob(blob: any, defaultName?: string): boolean; + msSaveOrOpenBlob(blob: any, defaultName?: string): boolean; +} + +interface MSNavigatorDoNotTrack { + confirmSiteSpecificTrackingException(args: ConfirmSiteSpecificExceptionsInformation): boolean; + confirmWebWideTrackingException(args: ExceptionInformation): boolean; + removeSiteSpecificTrackingException(args: ExceptionInformation): void; + removeWebWideTrackingException(args: ExceptionInformation): void; + storeSiteSpecificTrackingException(args: StoreSiteSpecificExceptionsInformation): void; + storeWebWideTrackingException(args: StoreExceptionsInformation): void; +} + +interface NavigatorContentUtils { +} + +interface NavigatorGeolocation { + geolocation: Geolocation; +} + +interface NavigatorID { + appName: string; + appVersion: string; + platform: string; + product: string; + productSub: string; + userAgent: string; + vendor: string; + vendorSub: string; +} + +interface NavigatorOnLine { + onLine: boolean; +} + +interface NavigatorStorageUtils { +} + +interface NodeSelector { + querySelector(selectors: string): Element; + querySelectorAll(selectors: string): NodeListOf; +} + +interface RandomSource { + getRandomValues(array: ArrayBufferView): ArrayBufferView; +} + +interface SVGAnimatedPathData { + pathSegList: SVGPathSegList; +} + +interface SVGAnimatedPoints { + animatedPoints: SVGPointList; + points: SVGPointList; +} + +interface SVGExternalResourcesRequired { + externalResourcesRequired: SVGAnimatedBoolean; +} + +interface SVGFilterPrimitiveStandardAttributes extends SVGStylable { + height: SVGAnimatedLength; + result: SVGAnimatedString; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + y: SVGAnimatedLength; +} + +interface SVGFitToViewBox { + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + viewBox: SVGAnimatedRect; +} + +interface SVGLangSpace { + xmllang: string; + xmlspace: string; +} + +interface SVGLocatable { + farthestViewportElement: SVGElement; + nearestViewportElement: SVGElement; + getBBox(): SVGRect; + getCTM(): SVGMatrix; + getScreenCTM(): SVGMatrix; + getTransformToElement(element: SVGElement): SVGMatrix; +} + +interface SVGStylable { + className: any; + style: CSSStyleDeclaration; +} + +interface SVGTests { + requiredExtensions: SVGStringList; + requiredFeatures: SVGStringList; + systemLanguage: SVGStringList; + hasExtension(extension: string): boolean; +} + +interface SVGTransformable extends SVGLocatable { + transform: SVGAnimatedTransformList; +} + +interface SVGURIReference { + href: SVGAnimatedString; +} + +interface WindowBase64 { + atob(encodedString: string): string; + btoa(rawString: string): string; +} + +interface WindowConsole { + console: Console; +} + +interface WindowLocalStorage { + localStorage: Storage; +} + +interface WindowSessionStorage { + sessionStorage: Storage; +} + +interface WindowTimers extends Object, WindowTimersExtension { + clearInterval(handle: number): void; + clearTimeout(handle: number): void; + setInterval(handler: any, timeout?: any, ...args: any[]): number; + setTimeout(handler: any, timeout?: any, ...args: any[]): number; +} + +interface WindowTimersExtension { + clearImmediate(handle: number): void; + msClearImmediate(handle: number): void; + msSetImmediate(expression: any, ...args: any[]): number; + setImmediate(expression: any, ...args: any[]): number; +} + +interface XMLHttpRequestEventTarget { + onabort: (ev: Event) => any; + onerror: (ev: Event) => any; + onload: (ev: Event) => any; + onloadend: (ev: ProgressEvent) => any; + onloadstart: (ev: Event) => any; + onprogress: (ev: ProgressEvent) => any; + ontimeout: (ev: ProgressEvent) => any; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeout", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface StorageEventInit extends EventInit { + key?: string; + oldValue?: string; + newValue?: string; + url: string; + storageArea?: Storage; +} + +interface IDBObjectStoreParameters { + keyPath?: string | string[]; + autoIncrement?: boolean; +} + +interface IDBIndexParameters { + unique?: boolean; + multiEntry?: boolean; +} + +interface NodeListOf extends NodeList { + length: number; + item(index: number): TNode; + [index: number]: TNode; +} + +interface BlobPropertyBag { + type?: string; + endings?: string; +} + +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + +interface EventListenerObject { + handleEvent(evt: Event): void; +} + +interface MessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + channel?: string; + source?: any; + ports?: MessagePort[]; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + +interface HTMLTemplateElement extends HTMLElement { + content: DocumentFragment; +} + +declare var HTMLTemplateElement: { + prototype: HTMLTemplateElement; + new(): HTMLTemplateElement; +} + +interface HTMLPictureElement extends HTMLElement { +} + +declare var HTMLPictureElement: { + prototype: HTMLPictureElement; + new(): HTMLPictureElement; +} + +declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; + +interface ErrorEventHandler { + (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; +} +interface PositionCallback { + (position: Position): void; +} +interface PositionErrorCallback { + (error: PositionError): void; +} +interface MediaQueryListListener { + (mql: MediaQueryList): void; +} +interface MSLaunchUriCallback { + (): void; +} +interface FrameRequestCallback { + (time: number): void; +} +interface MSUnsafeFunctionCallback { + (): any; +} +interface MSExecAtPriorityFunctionCallback { + (...args: any[]): any; +} +interface MutationCallback { + (mutations: MutationRecord[], observer: MutationObserver): void; +} +interface DecodeSuccessCallback { + (decodedData: AudioBuffer): void; +} +interface DecodeErrorCallback { + (error: DOMException): void; +} +interface FunctionStringCallback { + (data: string): void; +} +declare var Audio: {new(src?: string): HTMLAudioElement; }; +declare var Image: {new(width?: number, height?: number): HTMLImageElement; }; +declare var Option: {new(text?: string, value?: string, defaultSelected?: boolean, selected?: boolean): HTMLOptionElement; }; +declare var animationStartTime: number; +declare var applicationCache: ApplicationCache; +declare var clientInformation: Navigator; +declare var closed: boolean; +declare var crypto: Crypto; +declare var defaultStatus: string; +declare var devicePixelRatio: number; +declare var doNotTrack: string; +declare var document: Document; +declare var event: Event; +declare var external: External; +declare var frameElement: Element; +declare var frames: Window; +declare var history: History; +declare var innerHeight: number; +declare var innerWidth: number; +declare var length: number; +declare var location: Location; +declare var locationbar: BarProp; +declare var menubar: BarProp; +declare var msAnimationStartTime: number; +declare var name: string; +declare var navigator: Navigator; +declare var offscreenBuffering: string | boolean; +declare var onabort: (ev: Event) => any; +declare var onafterprint: (ev: Event) => any; +declare var onbeforeprint: (ev: Event) => any; +declare var onbeforeunload: (ev: BeforeUnloadEvent) => any; +declare var onblur: (ev: FocusEvent) => any; +declare var oncanplay: (ev: Event) => any; +declare var oncanplaythrough: (ev: Event) => any; +declare var onchange: (ev: Event) => any; +declare var onclick: (ev: MouseEvent) => any; +declare var oncompassneedscalibration: (ev: Event) => any; +declare var oncontextmenu: (ev: PointerEvent) => any; +declare var ondblclick: (ev: MouseEvent) => any; +declare var ondevicemotion: (ev: DeviceMotionEvent) => any; +declare var ondeviceorientation: (ev: DeviceOrientationEvent) => any; +declare var ondrag: (ev: DragEvent) => any; +declare var ondragend: (ev: DragEvent) => any; +declare var ondragenter: (ev: DragEvent) => any; +declare var ondragleave: (ev: DragEvent) => any; +declare var ondragover: (ev: DragEvent) => any; +declare var ondragstart: (ev: DragEvent) => any; +declare var ondrop: (ev: DragEvent) => any; +declare var ondurationchange: (ev: Event) => any; +declare var onemptied: (ev: Event) => any; +declare var onended: (ev: Event) => any; +declare var onerror: ErrorEventHandler; +declare var onfocus: (ev: FocusEvent) => any; +declare var onhashchange: (ev: HashChangeEvent) => any; +declare var oninput: (ev: Event) => any; +declare var onkeydown: (ev: KeyboardEvent) => any; +declare var onkeypress: (ev: KeyboardEvent) => any; +declare var onkeyup: (ev: KeyboardEvent) => any; +declare var onload: (ev: Event) => any; +declare var onloadeddata: (ev: Event) => any; +declare var onloadedmetadata: (ev: Event) => any; +declare var onloadstart: (ev: Event) => any; +declare var onmessage: (ev: MessageEvent) => any; +declare var onmousedown: (ev: MouseEvent) => any; +declare var onmouseenter: (ev: MouseEvent) => any; +declare var onmouseleave: (ev: MouseEvent) => any; +declare var onmousemove: (ev: MouseEvent) => any; +declare var onmouseout: (ev: MouseEvent) => any; +declare var onmouseover: (ev: MouseEvent) => any; +declare var onmouseup: (ev: MouseEvent) => any; +declare var onmousewheel: (ev: MouseWheelEvent) => any; +declare var onmsgesturechange: (ev: MSGestureEvent) => any; +declare var onmsgesturedoubletap: (ev: MSGestureEvent) => any; +declare var onmsgestureend: (ev: MSGestureEvent) => any; +declare var onmsgesturehold: (ev: MSGestureEvent) => any; +declare var onmsgesturestart: (ev: MSGestureEvent) => any; +declare var onmsgesturetap: (ev: MSGestureEvent) => any; +declare var onmsinertiastart: (ev: MSGestureEvent) => any; +declare var onmspointercancel: (ev: MSPointerEvent) => any; +declare var onmspointerdown: (ev: MSPointerEvent) => any; +declare var onmspointerenter: (ev: MSPointerEvent) => any; +declare var onmspointerleave: (ev: MSPointerEvent) => any; +declare var onmspointermove: (ev: MSPointerEvent) => any; +declare var onmspointerout: (ev: MSPointerEvent) => any; +declare var onmspointerover: (ev: MSPointerEvent) => any; +declare var onmspointerup: (ev: MSPointerEvent) => any; +declare var onoffline: (ev: Event) => any; +declare var ononline: (ev: Event) => any; +declare var onorientationchange: (ev: Event) => any; +declare var onpagehide: (ev: PageTransitionEvent) => any; +declare var onpageshow: (ev: PageTransitionEvent) => any; +declare var onpause: (ev: Event) => any; +declare var onplay: (ev: Event) => any; +declare var onplaying: (ev: Event) => any; +declare var onpopstate: (ev: PopStateEvent) => any; +declare var onprogress: (ev: ProgressEvent) => any; +declare var onratechange: (ev: Event) => any; +declare var onreadystatechange: (ev: ProgressEvent) => any; +declare var onreset: (ev: Event) => any; +declare var onresize: (ev: UIEvent) => any; +declare var onscroll: (ev: UIEvent) => any; +declare var onseeked: (ev: Event) => any; +declare var onseeking: (ev: Event) => any; +declare var onselect: (ev: UIEvent) => any; +declare var onstalled: (ev: Event) => any; +declare var onstorage: (ev: StorageEvent) => any; +declare var onsubmit: (ev: Event) => any; +declare var onsuspend: (ev: Event) => any; +declare var ontimeupdate: (ev: Event) => any; +declare var ontouchcancel: any; +declare var ontouchend: any; +declare var ontouchmove: any; +declare var ontouchstart: any; +declare var onunload: (ev: Event) => any; +declare var onvolumechange: (ev: Event) => any; +declare var onwaiting: (ev: Event) => any; +declare var opener: Window; +declare var orientation: string | number; +declare var outerHeight: number; +declare var outerWidth: number; +declare var pageXOffset: number; +declare var pageYOffset: number; +declare var parent: Window; +declare var performance: Performance; +declare var personalbar: BarProp; +declare var screen: Screen; +declare var screenLeft: number; +declare var screenTop: number; +declare var screenX: number; +declare var screenY: number; +declare var scrollX: number; +declare var scrollY: number; +declare var scrollbars: BarProp; +declare var self: Window; +declare var status: string; +declare var statusbar: BarProp; +declare var styleMedia: StyleMedia; +declare var toolbar: BarProp; +declare var top: Window; +declare var window: Window; +declare var URL: URL; +declare function alert(message?: any): void; +declare function blur(): void; +declare function cancelAnimationFrame(handle: number): void; +declare function captureEvents(): void; +declare function close(): void; +declare function confirm(message?: string): boolean; +declare function focus(): void; +declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; +declare function getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; +declare function getSelection(): Selection; +declare function matchMedia(mediaQuery: string): MediaQueryList; +declare function moveBy(x?: number, y?: number): void; +declare function moveTo(x?: number, y?: number): void; +declare function msCancelRequestAnimationFrame(handle: number): void; +declare function msMatchMedia(mediaQuery: string): MediaQueryList; +declare function msRequestAnimationFrame(callback: FrameRequestCallback): number; +declare function msWriteProfilerMark(profilerMarkName: string): void; +declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window; +declare function postMessage(message: any, targetOrigin: string, ports?: any): void; +declare function print(): void; +declare function prompt(message?: string, _default?: string): string; +declare function releaseEvents(): void; +declare function requestAnimationFrame(callback: FrameRequestCallback): number; +declare function resizeBy(x?: number, y?: number): void; +declare function resizeTo(x?: number, y?: number): void; +declare function scroll(x?: number, y?: number): void; +declare function scrollBy(x?: number, y?: number): void; +declare function scrollTo(x?: number, y?: number): void; +declare function webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; +declare function webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; +declare function toString(): string; +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function dispatchEvent(evt: Event): boolean; +declare function removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function clearInterval(handle: number): void; +declare function clearTimeout(handle: number): void; +declare function setInterval(handler: any, timeout?: any, ...args: any[]): number; +declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number; +declare function clearImmediate(handle: number): void; +declare function msClearImmediate(handle: number): void; +declare function msSetImmediate(expression: any, ...args: any[]): number; +declare function setImmediate(expression: any, ...args: any[]): number; +declare var sessionStorage: Storage; +declare var localStorage: Storage; +declare var console: Console; +declare var onpointercancel: (ev: PointerEvent) => any; +declare var onpointerdown: (ev: PointerEvent) => any; +declare var onpointerenter: (ev: PointerEvent) => any; +declare var onpointerleave: (ev: PointerEvent) => any; +declare var onpointermove: (ev: PointerEvent) => any; +declare var onpointerout: (ev: PointerEvent) => any; +declare var onpointerover: (ev: PointerEvent) => any; +declare var onpointerup: (ev: PointerEvent) => any; +declare var onwheel: (ev: WheelEvent) => any; +declare var indexedDB: IDBFactory; +declare var msIndexedDB: IDBFactory; +declare function atob(encodedString: string): string; +declare function btoa(rawString: string): string; +declare function addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "compassneedscalibration", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "devicemotion", listener: (ev: DeviceMotionEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "deviceorientation", listener: (ev: DeviceOrientationEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "hashchange", listener: (ev: HashChangeEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "orientationchange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "readystatechange", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; diff --git a/jsweet-core/LICENSE b/jsweet-core/LICENSE new file mode 100644 index 00000000..8f71f43f --- /dev/null +++ b/jsweet-core/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/jsweet-transpiler/.gitignore b/jsweet-transpiler/.gitignore index 7a43d2f8..ef1d2e22 100644 --- a/jsweet-transpiler/.gitignore +++ b/jsweet-transpiler/.gitignore @@ -5,3 +5,4 @@ /tempOut/ /js/ /.jsweet/ +/bin/ diff --git a/jsweet-transpiler/CONTRIBUTING.md b/jsweet-transpiler/CONTRIBUTING.md new file mode 100644 index 00000000..40beef23 --- /dev/null +++ b/jsweet-transpiler/CONTRIBUTING.md @@ -0,0 +1,26 @@ + +## What to contribute? + +Check out the issues and [wiki](https://github.com/cincheo/jsweet/wiki) for bugs, sub-projects and features where your contributions could be useful. + +## Your contributions + +Your contributions are most welcome. Bugs and features should be first reported in the Github issues space, so that we all know who is working on what, and so that we avoid duplicate efforts. + +### Bug fixes + +Bug fixes should come with the corresponding test(s) if possible. + +### Features + +Please make sure that contributed new features has been discussed thoroughly first (check out existing issues and the Wiki). It is important that they come with the appropriate test case(s) if possible. + + +## Contribution License Agreement + +By contributing through a pull request, you acknowledge that you fully own your Contribution and that you are legally entitled to make it available to the JSweet project under the terms and conditions of the Apache 2.0 license. This license implies that you grant the JSweet project, and those who receive the code directly or indirectly from the JSweet project, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license in the Contribution to reproduce, prepare derivative works of, publicly display, publicly perform, and distribute your Contribution and such derivative works, and to sublicense any or all of the foregoing rights to third parties. + +Your execution and/or acceptance of this agreement does not influence any of your right and title to use and distribute your own Contribution. + + + diff --git a/jsweet-transpiler/LICENSE b/jsweet-transpiler/LICENSE new file mode 100644 index 00000000..8f71f43f --- /dev/null +++ b/jsweet-transpiler/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/jsweet-transpiler/README.md b/jsweet-transpiler/README.md new file mode 100644 index 00000000..2015b480 --- /dev/null +++ b/jsweet-transpiler/README.md @@ -0,0 +1,183 @@ +# JSweet: a Java to JavaScript transpiler [![Build Status](https://travis-ci.org/cincheo/jsweet.svg?branch=master)](https://travis-ci.org/cincheo/jsweet) + +JSweet leverages TypeScript to write rich and responsive Web applications in Java through the use of JavaScript libraries and frameworks. With JSweet, Java programs are transpiled (source-to-source compiled) to TypeScript and JavaScript for being run in browsers, mobile Web views, or in Node.js. + +* JSweet is safe and reliable. It provides web applications with type-checking and generates fully type-checked JavaScript programs. It stands on Oracle's Java Compiler (javac) and on Microsoft's TypeScript (tsc). +* JSweet allows you to use your favorite JS library ([JSweet+Angular2](https://github.com/cincheo/jsweet-angular2-quickstart), [JSweet+threejs](https://github.com/cincheo/jsweet-examples-threejs), [IONIC/Cordova](https://github.com/lgrignon/jsweet-cordova-ionic-example), ...). +* JSweet enables code sharing between server-side Java and client-side JavaScript. JSweet provides implementations for the core Java libraries for code sharing and legacy Java migration purpose. +* JSweet is fast, lightweight and fully JavaScript-interoperable. The generated code is regular JavaScript code, which implies no overhead compared to JavaScript, and can directly interoperate with existing JavaScript programs and libraries. + +How does it work? JSweet depends on well-typed descriptions of JavaScript APIs, so-called "candies", most of them being automatically generated from TypeScript definition files. These API descriptions in Java can be seen as headers (similarly to *.h header files in C) to bridge JavaSript libraries from Java. There are several sources of candies for existing libraries and you can easily build a candy for any library out there (see [more details](http://www.jsweet.org/jsweet-candies/)). + +With JSweet, you take advantage of all the Java tooling (IDE's, Maven, ...) to program real JavaScript applications using the latest JavaScript libraries. + +## Java -> TypeScript -> JavaScript + +Here is a first taste of what you get by using JSweet. Consider this simple Java program: + +```java +package org.jsweet; + +import static jsweet.dom.Globals.*; + +/** + * This is a very simple example that just shows an alert. + */ +public class HelloWorld { + public static void main(String[] args) { + alert("Hi there!"); + } +} +``` + +Transpiling with JSweet gives the following TypeScript program: + +```TypeScript +namespace org.jsweet { + /** + * This is a very simple example that just shows an alert. + */ + export class HelloWorld { + public static main(args : string[]) { + alert("Hi there!"); + } + } +} +org.jsweet.HelloWorld.main(null); +``` + +Which in turn produces the following JavaScript output: + +```JavaScript +var org; +(function (org) { + var jsweet; + (function (jsweet) { + /** + * This is a very simple example that just shows an alert. + */ + var HelloWorld = (function () { + function HelloWorld() { + } + HelloWorld.main = function (args) { + alert("Hi there!"); + }; + return HelloWorld; + }()); + jsweet.HelloWorld = HelloWorld; + })(jsweet = org.jsweet || (org.jsweet = {})); +})(org || (org = {})); +org.jsweet.HelloWorld.main(null); +``` + +More with the [live sandbox](http://www.jsweet.org/jsweet-live-sandbox/). + +## Features + +- Full syntax mapping between Java and TypeScript, including classes, interfaces, functional types, union types, tuple types, object types, string types, and so on. +- Extensive support of Java constructs and semantics added since [version 1.1.0](https://github.com/cincheo/jsweet/releases/tag/v1.1.0) (inner classes, anonymous classes, final fields, method overloading, instanceof operator, static initializers, ...). +- *Over 1000 JavaScript libraries*, frameworks and plugins to write Web and Mobile HTML5 applications (JQuery, Underscore, Angular, Backbone, Cordova, Node.js, and much [more](http://www.jsweet.org/candies-snapshots/)). +- A [Maven repository](http://repository.jsweet.org/artifactory) containing all the available libraries in Maven artifacts (a.k.a. candies). +- Support for Java basic APIs as the [J4TS](https://github.com/cincheo/j4ts) candy (forked from the GWT's JRE emulation). +- An [Eclipse plugin](https://github.com/cincheo/jsweet-eclipse-plugin) for easy installation and use. +- A [Maven plugin](https://github.com/lgrignon/jsweet-maven-plugin) to use JSweet from any other IDE or from the command line. +- A debug mode to enable Java code debugging within your favorite browser. +- A set of nice [WEB/Mobile HTML5 examples](https://github.com/cincheo/jsweet-examples) to get started and get used to JSweet and the most common JavaScript APIs (even more examples in the Examples section). +- Support for bundles to run the generated programs in the most simple way. +- Support for JavaScript modules (commonjs, amd, umd). JSweet programs *can* run in a browser or in Node.js. +- Support for various EcmaScript target versions (ES3 to ES6). +- ... + +For more details, go to the [language specifications](https://github.com/cincheo/jsweet/blob/master/doc/jsweet-language-specifications.md) ([PDF](https://github.com/cincheo/jsweet/raw/master/doc/jsweet-language-specifications.pdf)). + +## Getting started + +- Step 1: Install (or check that you have installed) [Git](https://git-scm.com/downloads), [Node.js](https://nodejs.org) and [Maven](https://maven.apache.org/) (commands `git`, `node`, `npm` and `mvn` should be in your path). +- Step 2: Clone the [jsweet-quickstart](https://github.com/cincheo/jsweet-quickstart) project from Github: +``` +> git clone https://github.com/cincheo/jsweet-quickstart.git +``` +- Step 3: Run the transpiler to generate the JavaScript code: +``` +> cd jsweet-quickstart +> mvn generate-sources +``` +- Step 4: Check out the result in your browser: +``` +> firefox webapp/index.html +``` +- Step 5: Edit the project and start programming: + - Checkout the examples to see various use cases + - Get access to hundreds of [libs (candies)](http://www.jsweet.org/jsweet-candies/) + - Refer to the [language specifications](https://github.com/cincheo/jsweet/blob/master/doc/jsweet-language-specifications.md) to know more about programming with JSweet + - Eclipse users: install the [Eclipse plugin](http://www.jsweet.org/eclipse-plugin/) to get inline error reporting, build-on-save, and easy configuration UI + +More info at http://www.jsweet.org. + +## Examples + +- Simple examples illustrating the use of various frameworks in Java (jQuery, Underscore, Backbone, AngularJS, Knockout): https://github.com/cincheo/jsweet-examples +- Simple examples illustrating the use of the Threejs framework in Java: https://github.com/cincheo/jsweet-examples-threejs) +- Node.js + Socket.IO + AngularJS: https://github.com/lgrignon/jsweet-node-example +- Some simple examples to get started with React.js: https://github.com/cincheo/jsweet-examples-react +- JSweet JAX-RS server example (how to share a Java model between client and server): https://github.com/lgrignon/jsweet-jaxrs-server-example +- JSweet Cordova / Polymer example: https://github.com/lgrignon/jsweet-cordova-polymer-example +- JSweet Cordova / Ionic example: https://github.com/lgrignon/jsweet-cordova-ionic-example +- JSweet Angular 2 example: https://github.com/cincheo/jsweet-angular2-quickstart +- JSweet Angular 2 + PrimeNG: https://github.com/cincheo/jsweet-primeng-quickstart + +## Tooling + +- [Eclipse plugin](https://github.com/cincheo/jsweet-eclipse-plugin) +- [Maven plugin](https://github.com/lgrignon/jsweet-maven-plugin) +- [Gradle plugin](https://github.com/lgrignon/jsweet-gradle-plugin) + +## News and more information + +Most information is available on the http://www.jsweet.org. Developers, check out the [wiki](https://github.com/cincheo/jsweet/wiki). + +## How to build + +Prerequisites: `node` and `npm` executables must be in the path (https://nodejs.org). Note that there seem to be an issue with the `node` executable on some Unix-based machines, which should be fixed (see for instance: http://askubuntu.com/questions/235655/node-js-conflicts-sbin-node-vs-usr-bin-node). + +To build the `jsweet-transpiler` jars (in the project's directory): + +``` +> mvn package +``` + +To install the `jsweet-transpiler` artifact in your local Maven repository: + +``` +> mvn install +``` + +Note that current JUnit tests launch a Node.js instance for each test and will be quite slow (this will be improved). In order to easily test some changes locally without having to run all the tests, use the following command: + +``` +> mvn package -Dmaven.test.skip=true +``` + +or + +``` +> mvn install -Dmaven.test.skip=true +``` + +To generate the markdown language specifications from the Latex source file with [Pandoc](http://pandoc.org/): + +``` +> cd doc +> pandoc -r latex -w markdown_github --base-header-level=2 -s --toc --number-sections -B header.md -o jsweet-language-specifications.md jsweet-language-specifications.tex +``` + +Note that the following command will output the document in HTML: + +``` +> pandoc -r latex -w html5 --base-header-level=3 -o jsweet-language-specifications.html jsweet-language-specifications.tex +``` + +## License + +JSweet is under the Apache 2.0 Open Source license. + diff --git a/jsweet-transpiler/copyright.txt b/jsweet-transpiler/copyright.txt new file mode 100644 index 00000000..eec3cfef --- /dev/null +++ b/jsweet-transpiler/copyright.txt @@ -0,0 +1,16 @@ +/* + * JSweet - http://www.jsweet.org + * Copyright (C) 2015 CINCHEO SAS + * + * 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. + */ \ No newline at end of file