@idlizer/arktscgen 2.1.9-arktscgen-9 → 2.1.10-arktscgen-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (263) hide show
  1. package/build/libarkts-copy/generator/options.json5 +115 -3
  2. package/build/libarkts-copy/native/mingw.cross +13 -0
  3. package/build/libarkts-copy/native/src/bridges.cc +58 -227
  4. package/build/libarkts-copy/native/src/common.cc +49 -8
  5. package/build/libarkts-copy/native/src/generated/bridges.cc +1641 -44
  6. package/build/libarkts-copy/package.json +11 -14
  7. package/build/libarkts-copy/src/Es2pandaNativeModule.ts +28 -51
  8. package/build/libarkts-copy/src/arkts-api/ImportStorage.ts +1 -1
  9. package/build/libarkts-copy/src/arkts-api/class-by-peer.ts +6 -5
  10. package/build/libarkts-copy/src/arkts-api/factory/nodeFactory.ts +5 -2
  11. package/build/libarkts-copy/src/arkts-api/node-cache.ts +4 -0
  12. package/build/libarkts-copy/src/arkts-api/node-utilities/ArkTsConfig.ts +7 -6
  13. package/build/libarkts-copy/src/arkts-api/node-utilities/NumberLiteral.ts +3 -1
  14. package/build/libarkts-copy/src/arkts-api/node-utilities/ObjectExpression.ts +25 -6
  15. package/build/libarkts-copy/src/{wrapper-compat/arkts-api/peers/ImportPathManager.ts → arkts-api/node-utilities/OpaqueTypeNode.ts} +8 -17
  16. package/build/libarkts-copy/src/arkts-api/node-utilities/Program.ts +11 -10
  17. package/build/libarkts-copy/src/arkts-api/peers/AstNode.ts +8 -6
  18. package/build/libarkts-copy/src/arkts-api/peers/Config.ts +6 -0
  19. package/build/libarkts-copy/src/arkts-api/peers/Context.ts +3 -15
  20. package/build/libarkts-copy/src/arkts-api/static/global.ts +28 -1
  21. package/build/libarkts-copy/src/arkts-api/utilities/extensions.ts +46 -6
  22. package/build/libarkts-copy/src/arkts-api/utilities/private.ts +3 -3
  23. package/build/libarkts-copy/src/arkts-api/utilities/public.ts +58 -90
  24. package/build/libarkts-copy/src/arkts-api/visitor.ts +965 -365
  25. package/build/libarkts-copy/src/generated/Es2pandaEnums.ts +5 -0
  26. package/build/libarkts-copy/src/generated/Es2pandaNativeModule.ts +601 -13
  27. package/build/libarkts-copy/src/generated/index.ts +3 -2
  28. package/build/libarkts-copy/src/generated/peers/AnnotatedAstNode.ts +3 -2
  29. package/build/libarkts-copy/src/generated/peers/AnnotatedExpression.ts +3 -2
  30. package/build/libarkts-copy/src/generated/peers/AnnotatedStatement.ts +3 -2
  31. package/build/libarkts-copy/src/generated/peers/AnnotationDeclaration.ts +6 -7
  32. package/build/libarkts-copy/src/generated/peers/AnnotationUsage.ts +6 -7
  33. package/build/libarkts-copy/src/generated/peers/ArkTsConfig.ts +4 -0
  34. package/build/libarkts-copy/src/generated/peers/ArrayExpression.ts +6 -7
  35. package/build/libarkts-copy/src/generated/peers/ArrowFunctionExpression.ts +6 -7
  36. package/build/libarkts-copy/src/generated/peers/AssertStatement.ts +5 -6
  37. package/build/libarkts-copy/src/generated/peers/AssignmentExpression.ts +6 -7
  38. package/build/libarkts-copy/src/generated/peers/AstDumper.ts +3 -0
  39. package/build/libarkts-copy/src/generated/peers/AwaitExpression.ts +5 -6
  40. package/build/libarkts-copy/src/generated/peers/BigIntLiteral.ts +5 -6
  41. package/build/libarkts-copy/src/generated/peers/BinaryExpression.ts +5 -6
  42. package/build/libarkts-copy/src/generated/peers/BlockExpression.ts +5 -6
  43. package/build/libarkts-copy/src/generated/peers/BlockStatement.ts +5 -6
  44. package/build/libarkts-copy/src/generated/peers/BooleanLiteral.ts +5 -6
  45. package/build/libarkts-copy/src/generated/peers/BreakStatement.ts +6 -7
  46. package/build/libarkts-copy/src/generated/peers/CallExpression.ts +5 -6
  47. package/build/libarkts-copy/src/generated/peers/CatchClause.ts +6 -7
  48. package/build/libarkts-copy/src/generated/peers/ChainExpression.ts +5 -6
  49. package/build/libarkts-copy/src/generated/peers/CharLiteral.ts +5 -6
  50. package/build/libarkts-copy/src/generated/peers/ClassDeclaration.ts +5 -6
  51. package/build/libarkts-copy/src/generated/peers/ClassDefinition.ts +9 -8
  52. package/build/libarkts-copy/src/generated/peers/ClassElement.ts +3 -2
  53. package/build/libarkts-copy/src/generated/peers/ClassExpression.ts +5 -6
  54. package/build/libarkts-copy/src/generated/peers/ClassProperty.ts +15 -8
  55. package/build/libarkts-copy/src/generated/peers/ClassStaticBlock.ts +5 -6
  56. package/build/libarkts-copy/src/generated/peers/ConditionalExpression.ts +5 -6
  57. package/build/libarkts-copy/src/generated/peers/ContinueStatement.ts +6 -7
  58. package/build/libarkts-copy/src/generated/peers/DebuggerStatement.ts +5 -6
  59. package/build/libarkts-copy/src/generated/peers/Decorator.ts +5 -6
  60. package/build/libarkts-copy/src/generated/peers/DirectEvalExpression.ts +5 -6
  61. package/build/libarkts-copy/src/generated/peers/DoWhileStatement.ts +5 -6
  62. package/build/libarkts-copy/src/generated/peers/ETSClassLiteral.ts +5 -6
  63. package/build/libarkts-copy/src/generated/peers/ETSFunctionType.ts +5 -6
  64. package/build/libarkts-copy/src/generated/peers/ETSImportDeclaration.ts +5 -6
  65. package/build/libarkts-copy/src/generated/peers/ETSIntrinsicNode.ts +7 -8
  66. package/build/libarkts-copy/src/generated/peers/ETSKeyofType.ts +5 -6
  67. package/build/libarkts-copy/src/generated/peers/ETSModule.ts +5 -6
  68. package/build/libarkts-copy/src/generated/peers/ETSNewArrayInstanceExpression.ts +5 -6
  69. package/build/libarkts-copy/src/generated/peers/ETSNewClassInstanceExpression.ts +6 -7
  70. package/build/libarkts-copy/src/generated/peers/ETSNewMultiDimArrayInstanceExpression.ts +6 -7
  71. package/build/libarkts-copy/src/generated/peers/ETSNullType.ts +5 -6
  72. package/build/libarkts-copy/src/generated/peers/ETSPackageDeclaration.ts +5 -6
  73. package/build/libarkts-copy/src/generated/peers/ETSParameterExpression.ts +7 -8
  74. package/build/libarkts-copy/src/generated/peers/ETSPrimitiveType.ts +5 -6
  75. package/build/libarkts-copy/src/generated/peers/ETSReExportDeclaration.ts +3 -4
  76. package/build/libarkts-copy/src/generated/peers/ETSStringLiteralType.ts +5 -6
  77. package/build/libarkts-copy/src/generated/peers/ETSStructDeclaration.ts +5 -6
  78. package/build/libarkts-copy/src/generated/peers/ETSTuple.ts +9 -10
  79. package/build/libarkts-copy/src/generated/peers/ETSTypeReference.ts +5 -6
  80. package/build/libarkts-copy/src/generated/peers/ETSTypeReferencePart.ts +6 -7
  81. package/build/libarkts-copy/src/generated/peers/ETSUndefinedType.ts +5 -6
  82. package/build/libarkts-copy/src/generated/peers/ETSUnionType.ts +5 -6
  83. package/build/libarkts-copy/src/generated/peers/ETSWildcardType.ts +5 -6
  84. package/build/libarkts-copy/src/generated/peers/EmptyStatement.ts +6 -7
  85. package/build/libarkts-copy/src/generated/peers/ExportAllDeclaration.ts +5 -6
  86. package/build/libarkts-copy/src/generated/peers/ExportDefaultDeclaration.ts +5 -6
  87. package/build/libarkts-copy/src/generated/peers/ExportNamedDeclaration.ts +9 -10
  88. package/build/libarkts-copy/src/generated/peers/ExportSpecifier.ts +5 -6
  89. package/build/libarkts-copy/src/generated/peers/Expression.ts +7 -2
  90. package/build/libarkts-copy/src/generated/peers/ExpressionStatement.ts +5 -6
  91. package/build/libarkts-copy/src/generated/peers/ForInStatement.ts +5 -6
  92. package/build/libarkts-copy/src/generated/peers/ForOfStatement.ts +5 -6
  93. package/build/libarkts-copy/src/generated/peers/ForUpdateStatement.ts +4 -5
  94. package/build/libarkts-copy/src/generated/peers/FunctionDeclaration.ts +6 -7
  95. package/build/libarkts-copy/src/generated/peers/FunctionExpression.ts +6 -7
  96. package/build/libarkts-copy/src/generated/peers/FunctionSignature.ts +3 -0
  97. package/build/libarkts-copy/src/generated/peers/Identifier.ts +7 -8
  98. package/build/libarkts-copy/src/generated/peers/IfStatement.ts +5 -6
  99. package/build/libarkts-copy/src/generated/peers/ImportDeclaration.ts +5 -6
  100. package/build/libarkts-copy/src/generated/peers/ImportDefaultSpecifier.ts +5 -6
  101. package/build/libarkts-copy/src/generated/peers/ImportExpression.ts +5 -6
  102. package/build/libarkts-copy/src/generated/peers/ImportNamespaceSpecifier.ts +5 -6
  103. package/build/libarkts-copy/src/generated/peers/ImportSpecifier.ts +5 -6
  104. package/build/libarkts-copy/src/generated/peers/LabelledStatement.ts +5 -6
  105. package/build/libarkts-copy/src/generated/peers/Literal.ts +3 -2
  106. package/build/libarkts-copy/src/generated/peers/LoopStatement.ts +3 -2
  107. package/build/libarkts-copy/src/generated/peers/MaybeOptionalExpression.ts +3 -2
  108. package/build/libarkts-copy/src/generated/peers/MemberExpression.ts +5 -10
  109. package/build/libarkts-copy/src/generated/peers/MetaProperty.ts +5 -6
  110. package/build/libarkts-copy/src/generated/peers/MethodDefinition.ts +5 -6
  111. package/build/libarkts-copy/src/generated/peers/NamedType.ts +5 -6
  112. package/build/libarkts-copy/src/generated/peers/NewExpression.ts +5 -6
  113. package/build/libarkts-copy/src/generated/peers/NullLiteral.ts +5 -6
  114. package/build/libarkts-copy/src/generated/peers/NumberLiteral.ts +10 -9
  115. package/build/libarkts-copy/src/generated/peers/ObjectExpression.ts +5 -6
  116. package/build/libarkts-copy/src/generated/peers/OmittedExpression.ts +5 -6
  117. package/build/libarkts-copy/src/generated/peers/OpaqueTypeNode.ts +5 -6
  118. package/build/libarkts-copy/src/generated/peers/OverloadDeclaration.ts +5 -6
  119. package/build/libarkts-copy/src/generated/peers/PrefixAssertionExpression.ts +5 -6
  120. package/build/libarkts-copy/src/generated/peers/Property.ts +6 -7
  121. package/build/libarkts-copy/src/generated/peers/RegExpLiteral.ts +5 -6
  122. package/build/libarkts-copy/src/generated/peers/ReturnStatement.ts +6 -7
  123. package/build/libarkts-copy/src/generated/peers/ScriptFunction.ts +7 -6
  124. package/build/libarkts-copy/src/generated/peers/SequenceExpression.ts +5 -6
  125. package/build/libarkts-copy/src/generated/peers/SourcePosition.ts +6 -0
  126. package/build/libarkts-copy/src/generated/peers/SpreadElement.ts +5 -6
  127. package/build/libarkts-copy/src/generated/peers/SrcDumper.ts +3 -0
  128. package/build/libarkts-copy/src/generated/peers/Statement.ts +3 -2
  129. package/build/libarkts-copy/src/generated/peers/StringLiteral.ts +6 -7
  130. package/build/libarkts-copy/src/generated/peers/SuperExpression.ts +5 -6
  131. package/build/libarkts-copy/src/generated/peers/SwitchCaseStatement.ts +5 -6
  132. package/build/libarkts-copy/src/generated/peers/SwitchStatement.ts +5 -6
  133. package/build/libarkts-copy/src/generated/peers/TSAnyKeyword.ts +5 -6
  134. package/build/libarkts-copy/src/generated/peers/TSArrayType.ts +5 -6
  135. package/build/libarkts-copy/src/generated/peers/TSAsExpression.ts +5 -6
  136. package/build/libarkts-copy/src/generated/peers/TSBigintKeyword.ts +5 -6
  137. package/build/libarkts-copy/src/generated/peers/TSBooleanKeyword.ts +5 -6
  138. package/build/libarkts-copy/src/generated/peers/TSClassImplements.ts +6 -7
  139. package/build/libarkts-copy/src/generated/peers/TSConditionalType.ts +5 -6
  140. package/build/libarkts-copy/src/generated/peers/TSConstructorType.ts +5 -6
  141. package/build/libarkts-copy/src/generated/peers/TSEnumDeclaration.ts +6 -7
  142. package/build/libarkts-copy/src/generated/peers/TSEnumMember.ts +6 -7
  143. package/build/libarkts-copy/src/generated/peers/TSExternalModuleReference.ts +5 -6
  144. package/build/libarkts-copy/src/generated/peers/TSFunctionType.ts +5 -6
  145. package/build/libarkts-copy/src/generated/peers/TSImportEqualsDeclaration.ts +5 -6
  146. package/build/libarkts-copy/src/generated/peers/TSImportType.ts +5 -6
  147. package/build/libarkts-copy/src/generated/peers/TSIndexSignature.ts +5 -6
  148. package/build/libarkts-copy/src/generated/peers/TSIndexedAccessType.ts +5 -6
  149. package/build/libarkts-copy/src/generated/peers/TSInferType.ts +5 -6
  150. package/build/libarkts-copy/src/generated/peers/TSInterfaceBody.ts +5 -6
  151. package/build/libarkts-copy/src/generated/peers/TSInterfaceDeclaration.ts +5 -6
  152. package/build/libarkts-copy/src/generated/peers/TSInterfaceHeritage.ts +5 -6
  153. package/build/libarkts-copy/src/generated/peers/TSIntersectionType.ts +5 -6
  154. package/build/libarkts-copy/src/generated/peers/TSLiteralType.ts +5 -6
  155. package/build/libarkts-copy/src/generated/peers/TSMappedType.ts +5 -6
  156. package/build/libarkts-copy/src/generated/peers/TSMethodSignature.ts +5 -6
  157. package/build/libarkts-copy/src/generated/peers/TSModuleBlock.ts +5 -6
  158. package/build/libarkts-copy/src/generated/peers/TSModuleDeclaration.ts +5 -6
  159. package/build/libarkts-copy/src/generated/peers/TSNamedTupleMember.ts +5 -6
  160. package/build/libarkts-copy/src/generated/peers/TSNeverKeyword.ts +5 -6
  161. package/build/libarkts-copy/src/generated/peers/TSNonNullExpression.ts +5 -6
  162. package/build/libarkts-copy/src/generated/peers/TSNullKeyword.ts +5 -6
  163. package/build/libarkts-copy/src/generated/peers/TSNumberKeyword.ts +5 -6
  164. package/build/libarkts-copy/src/generated/peers/TSObjectKeyword.ts +5 -6
  165. package/build/libarkts-copy/src/generated/peers/TSParameterProperty.ts +5 -6
  166. package/build/libarkts-copy/src/generated/peers/TSParenthesizedType.ts +5 -6
  167. package/build/libarkts-copy/src/generated/peers/TSPropertySignature.ts +5 -6
  168. package/build/libarkts-copy/src/generated/peers/TSQualifiedName.ts +5 -6
  169. package/build/libarkts-copy/src/generated/peers/TSSignatureDeclaration.ts +5 -6
  170. package/build/libarkts-copy/src/generated/peers/TSStringKeyword.ts +5 -6
  171. package/build/libarkts-copy/src/generated/peers/TSThisType.ts +5 -6
  172. package/build/libarkts-copy/src/generated/peers/TSTupleType.ts +5 -6
  173. package/build/libarkts-copy/src/generated/peers/TSTypeAliasDeclaration.ts +6 -7
  174. package/build/libarkts-copy/src/generated/peers/TSTypeAssertion.ts +5 -6
  175. package/build/libarkts-copy/src/generated/peers/TSTypeLiteral.ts +5 -6
  176. package/build/libarkts-copy/src/generated/peers/TSTypeOperator.ts +5 -6
  177. package/build/libarkts-copy/src/generated/peers/TSTypeParameter.ts +6 -7
  178. package/build/libarkts-copy/src/generated/peers/TSTypeParameterDeclaration.ts +5 -6
  179. package/build/libarkts-copy/src/generated/peers/TSTypeParameterInstantiation.ts +5 -6
  180. package/build/libarkts-copy/src/generated/peers/TSTypePredicate.ts +5 -6
  181. package/build/libarkts-copy/src/generated/peers/TSTypeQuery.ts +5 -6
  182. package/build/libarkts-copy/src/generated/peers/TSTypeReference.ts +5 -6
  183. package/build/libarkts-copy/src/generated/peers/TSUndefinedKeyword.ts +5 -6
  184. package/build/libarkts-copy/src/generated/peers/TSUnionType.ts +5 -6
  185. package/build/libarkts-copy/src/generated/peers/TSUnknownKeyword.ts +5 -6
  186. package/build/libarkts-copy/src/generated/peers/TSVoidKeyword.ts +5 -6
  187. package/build/libarkts-copy/src/generated/peers/TaggedTemplateExpression.ts +5 -6
  188. package/build/libarkts-copy/src/generated/peers/TemplateElement.ts +6 -7
  189. package/build/libarkts-copy/src/generated/peers/TemplateLiteral.ts +5 -6
  190. package/build/libarkts-copy/src/generated/peers/ThisExpression.ts +5 -6
  191. package/build/libarkts-copy/src/generated/peers/ThrowStatement.ts +5 -6
  192. package/build/libarkts-copy/src/generated/peers/TryStatement.ts +6 -7
  193. package/build/libarkts-copy/src/generated/peers/TypeNode.ts +3 -2
  194. package/build/libarkts-copy/src/generated/peers/TypedAstNode.ts +3 -2
  195. package/build/libarkts-copy/src/generated/peers/TypedStatement.ts +3 -2
  196. package/build/libarkts-copy/src/generated/peers/TypeofExpression.ts +5 -6
  197. package/build/libarkts-copy/src/generated/peers/UnaryExpression.ts +5 -6
  198. package/build/libarkts-copy/src/generated/peers/UndefinedLiteral.ts +5 -6
  199. package/build/libarkts-copy/src/generated/peers/UpdateExpression.ts +5 -6
  200. package/build/libarkts-copy/src/generated/peers/ValidationInfo.ts +3 -0
  201. package/build/libarkts-copy/src/generated/peers/VariableDeclaration.ts +5 -6
  202. package/build/libarkts-copy/src/generated/peers/VariableDeclarator.ts +6 -7
  203. package/build/libarkts-copy/src/generated/peers/WhileStatement.ts +5 -6
  204. package/build/libarkts-copy/src/generated/peers/YieldExpression.ts +5 -6
  205. package/build/libarkts-copy/src/index.ts +2 -0
  206. package/build/libarkts-copy/src/plugin-utils.ts +8 -1
  207. package/build/libarkts-copy/src/reexport-for-generated.ts +8 -0
  208. package/build/libarkts-copy/src/tracer.ts +172 -0
  209. package/lib/index.js +1357 -510
  210. package/package.json +2 -2
  211. package/build/libarkts-copy/src/arkts-api/peers/SourcePosition.ts +0 -38
  212. package/build/libarkts-copy/src/generated/peers/FunctionDecl.ts +0 -45
  213. package/build/libarkts-copy/src/generated/peers/InterfaceDecl.ts +0 -45
  214. package/build/libarkts-copy/src/wrapper-compat/README.md +0 -20
  215. package/build/libarkts-copy/src/wrapper-compat/arkts-api/class-by-peer.ts +0 -46
  216. package/build/libarkts-copy/src/wrapper-compat/arkts-api/factory/nodeFactory.ts +0 -454
  217. package/build/libarkts-copy/src/wrapper-compat/arkts-api/factory/nodeTests.ts +0 -99
  218. package/build/libarkts-copy/src/wrapper-compat/arkts-api/index.ts +0 -88
  219. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ArrayExpression.ts +0 -38
  220. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ArrowFunctionExpression.ts +0 -35
  221. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/AssignmentExpression.ts +0 -38
  222. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/BlockStatement.ts +0 -27
  223. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/CallExpression.ts +0 -45
  224. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ClassDeclaration.ts +0 -27
  225. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ClassDefinition.ts +0 -73
  226. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ClassProperty.ts +0 -51
  227. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ETSFunctionType.ts +0 -42
  228. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ETSImportDeclaration.ts +0 -39
  229. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ETSParameterExpression.ts +0 -43
  230. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ExpressionStatement.ts +0 -28
  231. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/FunctionDeclaration.ts +0 -37
  232. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/FunctionExpression.ts +0 -28
  233. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/IfStatement.ts +0 -37
  234. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/MemberExpression.ts +0 -42
  235. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/MethodDefinition.ts +0 -46
  236. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/NumberLiteral.ts +0 -30
  237. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ObjectExpression.ts +0 -37
  238. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/Property.ts +0 -27
  239. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ScriptFunction.ts +0 -46
  240. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/StructDeclaration.ts +0 -28
  241. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TSInterfaceDeclaration.ts +0 -47
  242. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TSTypeAliasDeclaration.ts +0 -40
  243. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TSTypeParameter.ts +0 -36
  244. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TryStatement.ts +0 -41
  245. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/VariableDeclaration.ts +0 -42
  246. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/VariableDeclarator.ts +0 -39
  247. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/AstNode.ts +0 -26
  248. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/Diagnostic.ts +0 -38
  249. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/DiagnosticInfo.ts +0 -34
  250. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/DiagnosticKind.ts +0 -33
  251. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/Program.ts +0 -105
  252. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/SourcePosition.ts +0 -38
  253. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/SourceRange.ts +0 -38
  254. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/SuggestionInfo.ts +0 -34
  255. package/build/libarkts-copy/src/wrapper-compat/arkts-api/static/global.ts +0 -16
  256. package/build/libarkts-copy/src/wrapper-compat/arkts-api/to-be-generated/MemberExpression.ts +0 -108
  257. package/build/libarkts-copy/src/wrapper-compat/arkts-api/types.ts +0 -889
  258. package/build/libarkts-copy/src/wrapper-compat/arkts-api/utilities/nativePtrDecoder.ts +0 -69
  259. package/build/libarkts-copy/src/wrapper-compat/arkts-api/utilities/performance.ts +0 -190
  260. package/build/libarkts-copy/src/wrapper-compat/arkts-api/utilities/private.ts +0 -198
  261. package/build/libarkts-copy/src/wrapper-compat/arkts-api/utilities/public.ts +0 -327
  262. package/build/libarkts-copy/src/wrapper-compat/arkts-api/visitor.ts +0 -421
  263. package/build/libarkts-copy/src/wrapper-compat/index.ts +0 -20
package/lib/index.js CHANGED
@@ -3814,11 +3814,13 @@ var IDLEntity;
3814
3814
  var IDLExtendedAttributes;
3815
3815
  (function (IDLExtendedAttributes) {
3816
3816
  IDLExtendedAttributes["Accessor"] = "Accessor";
3817
+ IDLExtendedAttributes["Annotations"] = "Annotations";
3817
3818
  IDLExtendedAttributes["Async"] = "Async";
3818
3819
  IDLExtendedAttributes["CallSignature"] = "CallSignature";
3819
3820
  IDLExtendedAttributes["CommonMethod"] = "CommonMethod";
3820
3821
  IDLExtendedAttributes["Component"] = "Component";
3821
3822
  IDLExtendedAttributes["ComponentInterface"] = "ComponentInterface";
3823
+ IDLExtendedAttributes["ComponentModifier"] = "ComponentModifier";
3822
3824
  IDLExtendedAttributes["Deprecated"] = "Deprecated";
3823
3825
  IDLExtendedAttributes["Documentation"] = "Documentation";
3824
3826
  IDLExtendedAttributes["DtsName"] = "DtsName";
@@ -3839,11 +3841,14 @@ var IDLExtendedAttributes;
3839
3841
  IDLExtendedAttributes["Synthetic"] = "Synthetic";
3840
3842
  IDLExtendedAttributes["Throws"] = "Throws";
3841
3843
  IDLExtendedAttributes["TraceKey"] = "TraceKey";
3844
+ IDLExtendedAttributes["TypeAnnotations"] = "TypeAnnotations";
3842
3845
  IDLExtendedAttributes["TypeArguments"] = "TypeArguments";
3843
3846
  IDLExtendedAttributes["TypeParameters"] = "TypeParameters";
3844
3847
  IDLExtendedAttributes["VerbatimDts"] = "VerbatimDts";
3845
3848
  IDLExtendedAttributes["HandWrittenImplementation"] = "HandWrittenImplementation";
3846
3849
  IDLExtendedAttributes["ExtraMethod"] = "ExtraMethod";
3850
+ IDLExtendedAttributes["OverloadAlias"] = "OverloadAlias";
3851
+ IDLExtendedAttributes["OverloadPriority"] = "OverloadPriority";
3847
3852
  })(IDLExtendedAttributes || (IDLExtendedAttributes = {}));
3848
3853
  var IDLAccessorAttribute;
3849
3854
  (function (IDLAccessorAttribute) {
@@ -3863,18 +3868,18 @@ function forEachChild(node, cbEnter, cbLeave) {
3863
3868
  const cleanup = cbEnter(node);
3864
3869
  switch (node.kind) {
3865
3870
  case IDLKind.File:
3866
- node.entries.forEach((value) => forEachChild(value, cbEnter));
3871
+ node.entries.forEach((value) => forEachChild(value, cbEnter, cbLeave));
3867
3872
  break;
3868
3873
  case IDLKind.Namespace:
3869
- node.members.forEach((value) => forEachChild(value, cbEnter));
3874
+ node.members.forEach((value) => forEachChild(value, cbEnter, cbLeave));
3870
3875
  break;
3871
3876
  case IDLKind.Interface: {
3872
3877
  let concrete = node;
3873
- concrete.inheritance.forEach((value) => forEachChild(value, cbEnter));
3874
- concrete.constructors.forEach((value) => forEachChild(value, cbEnter));
3875
- concrete.properties.forEach((value) => forEachChild(value, cbEnter));
3876
- concrete.methods.forEach((value) => forEachChild(value, cbEnter));
3877
- concrete.callables.forEach((value) => forEachChild(value, cbEnter));
3878
+ concrete.inheritance.forEach((value) => forEachChild(value, cbEnter, cbLeave));
3879
+ concrete.constructors.forEach((value) => forEachChild(value, cbEnter, cbLeave));
3880
+ concrete.properties.forEach((value) => forEachChild(value, cbEnter, cbLeave));
3881
+ concrete.methods.forEach((value) => forEachChild(value, cbEnter, cbLeave));
3882
+ concrete.callables.forEach((value) => forEachChild(value, cbEnter, cbLeave));
3878
3883
  break;
3879
3884
  }
3880
3885
  case IDLKind.Method:
@@ -3882,53 +3887,53 @@ function forEachChild(node, cbEnter, cbLeave) {
3882
3887
  case IDLKind.Callback:
3883
3888
  case IDLKind.Constructor: {
3884
3889
  let concrete = node;
3885
- (_a = concrete.parameters) === null || _a === void 0 ? void 0 : _a.forEach((value) => forEachChild(value, cbEnter));
3890
+ (_a = concrete.parameters) === null || _a === void 0 ? void 0 : _a.forEach((value) => forEachChild(value, cbEnter, cbLeave));
3886
3891
  if (concrete.returnType)
3887
- forEachChild(concrete.returnType, cbEnter);
3892
+ forEachChild(concrete.returnType, cbEnter, cbLeave);
3888
3893
  break;
3889
3894
  }
3890
3895
  case IDLKind.UnionType: {
3891
3896
  let concrete = node;
3892
- (_b = concrete.types) === null || _b === void 0 ? void 0 : _b.forEach((value) => forEachChild(value, cbEnter));
3897
+ (_b = concrete.types) === null || _b === void 0 ? void 0 : _b.forEach((value) => forEachChild(value, cbEnter, cbLeave));
3893
3898
  break;
3894
3899
  }
3895
3900
  case IDLKind.OptionalType: {
3896
3901
  let concrete = node;
3897
- forEachChild(concrete.type, cbEnter);
3902
+ forEachChild(concrete.type, cbEnter, cbLeave);
3898
3903
  break;
3899
3904
  }
3900
3905
  case IDLKind.Const: {
3901
- forEachChild(node.type, cbEnter);
3906
+ forEachChild(node.type, cbEnter, cbLeave);
3902
3907
  break;
3903
3908
  }
3904
3909
  case IDLKind.Enum: {
3905
- node.elements.forEach((value) => forEachChild(value, cbEnter));
3910
+ node.elements.forEach((value) => forEachChild(value, cbEnter, cbLeave));
3906
3911
  break;
3907
3912
  }
3908
3913
  case IDLKind.Property: {
3909
- forEachChild(node.type, cbEnter);
3914
+ forEachChild(node.type, cbEnter, cbLeave);
3910
3915
  break;
3911
3916
  }
3912
3917
  case IDLKind.Parameter: {
3913
3918
  const concrete = node;
3914
3919
  if (concrete.type)
3915
- forEachChild(concrete.type, cbEnter);
3920
+ forEachChild(concrete.type, cbEnter, cbLeave);
3916
3921
  break;
3917
3922
  }
3918
3923
  case IDLKind.Typedef: {
3919
- forEachChild(node.type, cbEnter);
3924
+ forEachChild(node.type, cbEnter, cbLeave);
3920
3925
  break;
3921
3926
  }
3922
3927
  case IDLKind.ContainerType: {
3923
- node.elementType.forEach((value) => forEachChild(value, cbEnter));
3928
+ node.elementType.forEach((value) => forEachChild(value, cbEnter, cbLeave));
3924
3929
  break;
3925
3930
  }
3926
3931
  case IDLKind.UnspecifiedGenericType: {
3927
- node.typeArguments.forEach((value) => forEachChild(value, cbEnter));
3932
+ node.typeArguments.forEach((value) => forEachChild(value, cbEnter, cbLeave));
3928
3933
  break;
3929
3934
  }
3930
3935
  case IDLKind.ReferenceType: {
3931
- (_c = node.typeArguments) === null || _c === void 0 ? void 0 : _c.forEach((value) => forEachChild(value, cbEnter));
3936
+ (_c = node.typeArguments) === null || _c === void 0 ? void 0 : _c.forEach((value) => forEachChild(value, cbEnter, cbLeave));
3932
3937
  break;
3933
3938
  }
3934
3939
  case IDLKind.TypeParameterType:
@@ -3941,6 +3946,7 @@ function forEachChild(node, cbEnter, cbLeave) {
3941
3946
  throw new Error(`Unhandled ${node.kind}`);
3942
3947
  }
3943
3948
  }
3949
+ cbLeave === null || cbLeave === void 0 ? void 0 : cbLeave(node);
3944
3950
  cleanup === null || cleanup === void 0 ? void 0 : cleanup();
3945
3951
  }
3946
3952
  /** Updates tree in place! */
@@ -4093,9 +4099,15 @@ function isInterface$1(node) {
4093
4099
  function isImport(type) {
4094
4100
  return type.kind == IDLKind.Import;
4095
4101
  }
4102
+ function isCallable(node) {
4103
+ return node.kind === IDLKind.Callable;
4104
+ }
4096
4105
  function isMethod(node) {
4097
4106
  return node.kind === IDLKind.Method;
4098
4107
  }
4108
+ function isConstructor$1(node) {
4109
+ return node.kind === IDLKind.Constructor;
4110
+ }
4099
4111
  function isProperty(node) {
4100
4112
  return node.kind === IDLKind.Property;
4101
4113
  }
@@ -6050,7 +6062,13 @@ class DiagnosticException extends Error {
6050
6062
  /**
6051
6063
  * Template for registering different kinds of messages
6052
6064
  */
6053
- class DiagnosticMessageEntry {
6065
+ class DiagnosticMessageGroup {
6066
+ /**
6067
+ * Generated diagnostic messages belonging to _any_ group
6068
+ */
6069
+ static get allGroupsEntries() {
6070
+ return DiagnosticMessageGroup.collectedResults.entries;
6071
+ }
6054
6072
  constructor(severity, code, codeDescription, mainMessageTemplate, additionalMessageTemplate) {
6055
6073
  this.severity = severity;
6056
6074
  this.code = code;
@@ -6058,10 +6076,10 @@ class DiagnosticMessageEntry {
6058
6076
  // No cases of codeUri for now, can be embedded into codeDescription later if needed
6059
6077
  this.mainMessageTemplate = mainMessageTemplate !== null && mainMessageTemplate !== void 0 ? mainMessageTemplate : codeDescription;
6060
6078
  this.additionalMessageTemplate = additionalMessageTemplate !== null && additionalMessageTemplate !== void 0 ? additionalMessageTemplate : "See";
6061
- if (DiagnosticMessageEntry.diagnosticMessageByCode.has(code)) {
6079
+ if (DiagnosticMessageGroup.diagnosticMessageByCode.has(code)) {
6062
6080
  throw new Error(`Duplicate message code ${code}`);
6063
6081
  }
6064
- DiagnosticMessageEntry.diagnosticMessageByCode.set(code, this);
6082
+ DiagnosticMessageGroup.diagnosticMessageByCode.set(code, this);
6065
6083
  }
6066
6084
  generateDiagnosticMessage(locations, mainMessage, additionalMessage) {
6067
6085
  let msg = {
@@ -6079,24 +6097,928 @@ class DiagnosticMessageEntry {
6079
6097
  return msg;
6080
6098
  }
6081
6099
  reportDiagnosticMessage(locations, mainMessage, additionalMessage) {
6082
- DiagnosticMessageEntry.collectedResults.push(this.generateDiagnosticMessage(locations, mainMessage, additionalMessage));
6100
+ const msg = this.generateDiagnosticMessage(locations, mainMessage, additionalMessage);
6101
+ DiagnosticMessageGroup.collectedResults.push(msg);
6102
+ return msg;
6083
6103
  }
6084
6104
  throwDiagnosticMessage(locations, mainMessage, additionalMessage) {
6085
- throw new DiagnosticException(this.generateDiagnosticMessage(locations, mainMessage, additionalMessage));
6086
- }
6087
- static reportCatched(diagnosticMessage) {
6088
- this.collectedResults.push(diagnosticMessage);
6105
+ throw new DiagnosticException(this.reportDiagnosticMessage(locations, mainMessage, additionalMessage));
6089
6106
  }
6090
6107
  }
6091
6108
  /**
6092
6109
  * Index for DiagnosticMessageEntry by code
6093
6110
  */
6094
- DiagnosticMessageEntry.diagnosticMessageByCode = new Map();
6095
- DiagnosticMessageEntry.collectedResults = new DiagnosticResults();
6096
- const UnknownErrorMessage = new DiagnosticMessageEntry("fatal", 0, "Unknown error");
6097
- const LoadingErrorMessage = new DiagnosticMessageEntry("fatal", 100, "Loading error");
6098
- const ParsingErrorMessage = new DiagnosticMessageEntry("fatal", 101, "Parsing error");
6099
- new DiagnosticMessageEntry("fatal", 102, "Processing error");
6111
+ DiagnosticMessageGroup.diagnosticMessageByCode = new Map();
6112
+ /**
6113
+ * Diagnostic results collected up until now
6114
+ */
6115
+ DiagnosticMessageGroup.collectedResults = new DiagnosticResults();
6116
+ const InternalFatal = new DiagnosticMessageGroup("fatal", "InternalFatal", "Unknown error");
6117
+ const LoadingFatal = new DiagnosticMessageGroup("fatal", "LoadingFatal", "Loading error");
6118
+ const ParsingFatal = new DiagnosticMessageGroup("fatal", "ParsingFatal", "Parsing error");
6119
+ new DiagnosticMessageGroup("fatal", "ProcessingFatal", "Processing error");
6120
+
6121
+ /*
6122
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
6123
+ * Licensed under the Apache License, Version 2.0 (the "License");
6124
+ * you may not use this file except in compliance with the License.
6125
+ * You may obtain a copy of the License at
6126
+ *
6127
+ * http://www.apache.org/licenses/LICENSE-2.0
6128
+ *
6129
+ * Unless required by applicable law or agreed to in writing, software
6130
+ * distributed under the License is distributed on an "AS IS" BASIS,
6131
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6132
+ * See the License for the specific language governing permissions and
6133
+ * limitations under the License.
6134
+ */
6135
+ const DuplicateModifier = new DiagnosticMessageGroup("error", "DuplicateModifier", "Duplicate modifier", "Duplicate of");
6136
+ const NotApplicableModifier = new DiagnosticMessageGroup("error", "NotApplicableModifier", "Not applicable modifier");
6137
+ const DuplicatePackageDeclaration = new DiagnosticMessageGroup("error", "DuplicatePackageDeclaration", "Duplicate package declaration", "Duplicate of");
6138
+ const DuplicateExtendedAttribute = new DiagnosticMessageGroup("error", "DuplicateExtendedAttribute", "Duplicate extended attribute", "Duplicate of");
6139
+ const DuplicateArgumentName = new DiagnosticMessageGroup("error", "DuplicateArgumentName", "Duplicate argument name", "Duplicate of");
6140
+ const IncorrectLiteral = new DiagnosticMessageGroup("error", "IncorrectLiteral", "Incorrect literal");
6141
+ const IncorrectIdentifier = new DiagnosticMessageGroup("error", "IncorrectIdentifier", "Incorrect identifier");
6142
+ const UnexpectedToken = new DiagnosticMessageGroup("error", "UnexpectedToken", "Unexpected token");
6143
+ const UnexpectedEndOfFile = new DiagnosticMessageGroup("fatal", "UnexpectedEndOfFile", "Unexpected end of file");
6144
+ const UnsupportedSyntax = new DiagnosticMessageGroup("error", "UnsupportedSyntax", "Unsupported syntax");
6145
+ const WrongDeclarationPlacement = new DiagnosticMessageGroup("error", "WrongDeclarationPlacement", "Wrong declaration placement");
6146
+ const ExpectedPrimitiveType = new DiagnosticMessageGroup("error", "ExpectedPrimitiveType", "Expected primitive type");
6147
+ const ExpectedReferenceType = new DiagnosticMessageGroup("error", "ExpectedReferenceType", "Expected reference type");
6148
+ const ExpectedGenericArguments = new DiagnosticMessageGroup("error", "ExpectedGenericArguments", "Expected generic arguments");
6149
+ const UnexpectedGenericArguments = new DiagnosticMessageGroup("error", "UnexpectedGenericArguments", "Unexpected generic arguments");
6150
+ class FatalParserException extends Error {
6151
+ constructor(diagnosticMessages) {
6152
+ super();
6153
+ this.diagnosticMessages = diagnosticMessages;
6154
+ }
6155
+ }
6156
+ var TokenKind;
6157
+ (function (TokenKind) {
6158
+ TokenKind["Words"] = "Words";
6159
+ TokenKind["Literal"] = "Literal";
6160
+ TokenKind["Symbol"] = "Symbol";
6161
+ TokenKind["Comment"] = "Comment";
6162
+ TokenKind["Whitespace"] = "Space";
6163
+ TokenKind["End"] = "End";
6164
+ })(TokenKind || (TokenKind = {}));
6165
+ const supportedDeclarations = new Set(["attribute", "callback", "const", "constructor", "dictionary",
6166
+ "enum", "import", "interface", "namespace", "package", "typedef", "version"]);
6167
+ const unsupportedDeclarations = new Set(["deleter", "getter", "includes", "inherit", "iterable", "maplike",
6168
+ "mixin", "partial", "required", "setlike", "setter", "stringifier", "unrestricted"]);
6169
+ const interfaceContent = new Set([IDLKind.Constructor, IDLKind.Const, IDLKind.Property, IDLKind.Method, IDLKind.Callable]);
6170
+ const globalContent = new Set([IDLKind.Namespace, IDLKind.Interface, IDLKind.Enum, IDLKind.Method, IDLKind.Typedef, IDLKind.Callback, IDLKind.Import, IDLKind.Version, IDLKind.Const]);
6171
+ const havingBlocks = new Set([IDLKind.Namespace, IDLKind.Interface, IDLKind.Enum]);
6172
+ const modifierTokens = new Set(["static", "readonly", "async"]);
6173
+ // Uncomment in case of parser debugging
6174
+ function trac(s) {
6175
+ // console.log(s)
6176
+ }
6177
+ class Parser {
6178
+ constructor(fileName, content) {
6179
+ var _a, _b;
6180
+ this._curOffset = 0;
6181
+ this._curLine = 0;
6182
+ // TypeParameters support
6183
+ this._generics = [];
6184
+ // TypeArguments parsing support
6185
+ this._enableInLiteralParsing = false;
6186
+ // symTokens = ["(", ")", "[", "]", "{", "}", ",", "...", ":", ";", "<", "=", ">", "?"]
6187
+ this._reDecimal = /-?(?=[0-9]*\.|[0-9]+[eE])(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][-+]?[0-9]+)?|[0-9]+[Ee][-+]?[0-9]+)/y;
6188
+ this._reInteger = /-?(0([Xx][0-9A-Fa-f]+|[0-7]*)|[1-9][0-9]*)/y;
6189
+ this._reString = /"[^"]*"/y;
6190
+ // -something is handled for -Infinity literal parsing, but rejected for identifiers later
6191
+ this._reWords = /[-]?[_$A-Za-z][_$0-9A-Za-z]*([.][_$A-Za-z][_$0-9A-Za-z]*)*/y;
6192
+ this._reSymbol = /\.\.\.|[()[\]{},:;<=>?]/y;
6193
+ this._reWhitespace = /[\t\n\r ]+/y;
6194
+ this._reComment = /\/\/.*|\/\*[\s\S]*?\*\//y;
6195
+ // Note no sticky behavior.
6196
+ this._reIsDocComment = /\/\/\/.*|\/\*\*[\s\S]*?\*\//;
6197
+ this.currentModifiers = {};
6198
+ this.fileName = fileName;
6199
+ if (undefined === content) {
6200
+ try {
6201
+ content = fs__namespace.readFileSync(fileName).toString();
6202
+ }
6203
+ catch (e) {
6204
+ content = "";
6205
+ throw new FatalParserException([LoadingFatal.reportDiagnosticMessage([{ documentPath: fileName }], (_a = e.message) !== null && _a !== void 0 ? _a : "")]);
6206
+ }
6207
+ }
6208
+ this.content = content;
6209
+ const lines = (_b = content.match(/[^\r\n]*(\n|\r\n)?/g)) !== null && _b !== void 0 ? _b : [];
6210
+ this.offsets = prepareOffsets$1(lines);
6211
+ this.lines = lines.map((s) => s.replace(/(\n|\r\n)$/, ""));
6212
+ }
6213
+ parseIDL() {
6214
+ var _a;
6215
+ const previousDiagnosticsCount = DiagnosticMessageGroup.allGroupsEntries.length;
6216
+ try {
6217
+ trac("parseIDL");
6218
+ this._lexerNext();
6219
+ this._prevToken = this._curToken;
6220
+ let file = this.parseFile();
6221
+ file.text = this.content;
6222
+ return file;
6223
+ }
6224
+ catch (e) {
6225
+ if (!(e instanceof DiagnosticException) && !(e instanceof FatalParserException)) {
6226
+ InternalFatal.reportDiagnosticMessage([{ documentPath: this.fileName }], (_a = e.message) !== null && _a !== void 0 ? _a : "");
6227
+ }
6228
+ throw new FatalParserException(DiagnosticMessageGroup.allGroupsEntries.slice(previousDiagnosticsCount));
6229
+ }
6230
+ }
6231
+ _match(re, kind) {
6232
+ re.lastIndex = this._curOffset;
6233
+ const res = re.exec(this.content);
6234
+ if (!res) {
6235
+ return undefined;
6236
+ }
6237
+ const value = res[0];
6238
+ const startLine = this._curLine + 1;
6239
+ const startCharacter = this._curOffset - this.offsets[this._curLine] + 1;
6240
+ this._curOffset = re.lastIndex;
6241
+ this._curLine += (value.match(/\n/g) || []).length;
6242
+ const endLine = this._curLine + 1;
6243
+ const endCharacter = this._curOffset - this.offsets[this._curLine];
6244
+ const location = { documentPath: this.fileName, lines: this.lines, range: { start: { line: startLine, character: startCharacter }, end: { line: endLine, character: endCharacter } } };
6245
+ this._curToken = { kind, value, location };
6246
+ return this._curToken;
6247
+ }
6248
+ _matchComment() {
6249
+ const token = this._match(this._reComment, TokenKind.Comment);
6250
+ // At any parsing moment `precedingComment` represents possible comment token just before`curToken`.
6251
+ // It can be narrowed by `_reIsDocComment` if needed.
6252
+ if (token) {
6253
+ this.precedingComment = token;
6254
+ }
6255
+ return token;
6256
+ }
6257
+ _lexerNext() {
6258
+ var _a, _b, _c, _d;
6259
+ this._prevToken = this._curToken;
6260
+ this._match(this._reWhitespace, TokenKind.Whitespace);
6261
+ this.precedingComment = undefined;
6262
+ while (this._matchComment()) {
6263
+ this._match(this._reWhitespace, TokenKind.Whitespace);
6264
+ }
6265
+ if (this._curOffset == this.content.length) {
6266
+ const pos = { line: this._curLine + 1, character: this._curOffset - this.offsets[this._curLine] + 1 };
6267
+ this._curToken = { kind: TokenKind.End, value: "", location: { documentPath: this.fileName, lines: this.lines, range: { start: pos, end: pos } } };
6268
+ return;
6269
+ }
6270
+ if (this._enableInLiteralParsing && this.content[this._curOffset] == "\"") {
6271
+ // TypeArguments parsing support
6272
+ const pos = { line: this._curLine + 1, character: this._curOffset - this.offsets[this._curLine] + 1 };
6273
+ this._curToken = { kind: TokenKind.Symbol, value: "\"", location: { documentPath: this.fileName, lines: this.lines, range: { start: pos, end: pos } } };
6274
+ this._curOffset += 1;
6275
+ return;
6276
+ }
6277
+ const token = ((_d = (_c = (_b = (_a = this._match(this._reDecimal, TokenKind.Literal)) !== null && _a !== void 0 ? _a : this._match(this._reInteger, TokenKind.Literal)) !== null && _b !== void 0 ? _b : this._match(this._reString, TokenKind.Literal)) !== null && _c !== void 0 ? _c : this._match(this._reWords, TokenKind.Words)) !== null && _d !== void 0 ? _d : this._match(this._reSymbol, TokenKind.Symbol));
6278
+ if (!token) {
6279
+ const pos = { line: this._curLine + 1, character: this._curOffset - this.offsets[this._curLine] + 1 };
6280
+ ParsingFatal.throwDiagnosticMessage([{ documentPath: this.fileName, lines: this.lines, range: { start: pos, end: pos } }], "Unrecognized symbols");
6281
+ }
6282
+ // Uncomment in case of parser debugging
6283
+ // if (token) {
6284
+ // const visTok = {...token, location: {...token.location, lines: undefined, documentPath: undefined}}
6285
+ // console.log(`Token: ${JSON.stringify(visTok)}`)
6286
+ // }
6287
+ }
6288
+ get curToken() {
6289
+ return this._curToken;
6290
+ }
6291
+ get curKind() {
6292
+ return this._curToken.kind;
6293
+ }
6294
+ get curValue() {
6295
+ return this._curToken.value;
6296
+ }
6297
+ get curLocation() {
6298
+ return this.curToken.location;
6299
+ }
6300
+ see(tok) {
6301
+ return this.curValue == tok;
6302
+ }
6303
+ seeAndSkip(tok) {
6304
+ if (this.curValue == tok) {
6305
+ this._lexerNext();
6306
+ return true;
6307
+ }
6308
+ return false;
6309
+ }
6310
+ seeEof() {
6311
+ return this.curToken.kind == TokenKind.End;
6312
+ }
6313
+ skip(tok) {
6314
+ if (this.curValue != tok) {
6315
+ if (this.curKind == TokenKind.End) {
6316
+ UnexpectedEndOfFile.throwDiagnosticMessage([this.curLocation], `Unexpected end of file, expected "${tok}"`);
6317
+ }
6318
+ UnexpectedToken.throwDiagnosticMessage([this.curLocation], `Unexpected token, expected "${tok}"`);
6319
+ }
6320
+ this._lexerNext();
6321
+ }
6322
+ skipToAfter(tok) {
6323
+ while (!this.see(tok) && !this.seeEof()) {
6324
+ this._lexerNext();
6325
+ }
6326
+ if (!this.seeEof()) {
6327
+ this._lexerNext();
6328
+ }
6329
+ }
6330
+ trackLocation() {
6331
+ const start = this.curLocation;
6332
+ return () => {
6333
+ const end = this._prevToken.location;
6334
+ return {
6335
+ documentPath: this.fileName,
6336
+ range: { start: start.range.start, end: end.range.end },
6337
+ lines: this.lines
6338
+ };
6339
+ };
6340
+ }
6341
+ consumeCurrentExtended() {
6342
+ const ext = this._internalCurrentExtended;
6343
+ this._internalCurrentExtended = undefined;
6344
+ return ext;
6345
+ }
6346
+ assertPossibleModifiers(...mods) {
6347
+ for (const k of Object.keys(this.currentModifiers)) {
6348
+ if (!mods.includes(k)) {
6349
+ NotApplicableModifier.reportDiagnosticMessage([this.currentModifiers[k].location]);
6350
+ }
6351
+ }
6352
+ }
6353
+ parseSingleIdentifier() {
6354
+ const token = this.parseFullIdentifier();
6355
+ if (token.value.includes(".")) {
6356
+ IncorrectIdentifier.throwDiagnosticMessage([this.curLocation]);
6357
+ }
6358
+ return token;
6359
+ }
6360
+ parseFullIdentifier() {
6361
+ if (this.curKind != TokenKind.Words || literalTypes.has(this.curValue) && this.curValue != "undefined") {
6362
+ UnexpectedToken.throwDiagnosticMessage([this.curLocation], "Unexpected token, expected identifier");
6363
+ }
6364
+ if (this.curValue.startsWith("-")) {
6365
+ // Valid for identifiers in WebIDL, but not in Idlize
6366
+ IncorrectIdentifier.throwDiagnosticMessage([this.curLocation]);
6367
+ }
6368
+ const token = this.curToken;
6369
+ this._lexerNext();
6370
+ return token;
6371
+ }
6372
+ parseFullIdentifierOrLiteral() {
6373
+ if (this.curKind != TokenKind.Words && this.curKind != TokenKind.Literal) {
6374
+ UnexpectedToken.throwDiagnosticMessage([this.curLocation], "Unexpected token, expected identifier or literal");
6375
+ }
6376
+ const token = this.curToken;
6377
+ this._lexerNext();
6378
+ return token;
6379
+ }
6380
+ parseLiteral() {
6381
+ if (this.curKind != TokenKind.Literal && !literalTypes.has(this.curValue)) {
6382
+ UnexpectedToken.throwDiagnosticMessage([this.curLocation], "Unexpected token, expected literal");
6383
+ }
6384
+ const token = this.curToken;
6385
+ this._lexerNext();
6386
+ return token;
6387
+ }
6388
+ parseAndPushGenerics(ext) {
6389
+ var _a;
6390
+ const gen = (_a = extractTypeParameters(ext)) !== null && _a !== void 0 ? _a : [];
6391
+ if (this.seeAndSkip("<")) {
6392
+ let next = false;
6393
+ while (!this.seeAndSkip(">")) {
6394
+ if (next) {
6395
+ this.skip(",");
6396
+ }
6397
+ next = true;
6398
+ gen.push(this.parseSingleIdentifier().value);
6399
+ }
6400
+ }
6401
+ // To be restored in parseDeclaration
6402
+ this._generics.push(gen);
6403
+ return gen;
6404
+ }
6405
+ hasGeneric(name) {
6406
+ return this._generics.some(x => x.includes(name));
6407
+ }
6408
+ parseFile() {
6409
+ var _a;
6410
+ const entries = [];
6411
+ while (!this.seeEof()) {
6412
+ const entry = this.parseDeclaration(IDLKind.File);
6413
+ if (entry) {
6414
+ entries.push(entry);
6415
+ }
6416
+ }
6417
+ return createFile(entries, this.fileName, (_a = this.currentPackage) === null || _a === void 0 ? void 0 : _a.split("."), { nodeLocation: { documentPath: this.fileName, lines: this.lines } });
6418
+ }
6419
+ parseDeclaration(scopeKind) {
6420
+ const genericsLevel = this._generics.length;
6421
+ try {
6422
+ const decl = this.parseDeclarationUnsafe(scopeKind);
6423
+ if (!decl) {
6424
+ return;
6425
+ }
6426
+ if (scopeKind == IDLKind.Interface ? !interfaceContent.has(decl.kind) : !globalContent.has(decl.kind)) {
6427
+ // Prefer shorter location ranges for blocks for now
6428
+ const location = havingBlocks.has(decl.kind) ? decl.nameLocation : decl.nodeLocation;
6429
+ WrongDeclarationPlacement.reportDiagnosticMessage([location], `Wrong declaration placement: ${decl.kind} not allowed in ${scopeKind}`);
6430
+ }
6431
+ return decl;
6432
+ }
6433
+ catch (e) {
6434
+ if (e instanceof DiagnosticException && e.diagnosticMessage.severity != "fatal") {
6435
+ this.skipToAfter(";");
6436
+ return;
6437
+ }
6438
+ throw e;
6439
+ }
6440
+ finally {
6441
+ while (this._generics.length > genericsLevel) {
6442
+ this._generics.pop();
6443
+ }
6444
+ }
6445
+ }
6446
+ parseDeclarationUnsafe(scopeKind) {
6447
+ this._internalCurrentExtended = this.parseExtendedAttributes();
6448
+ this.currentModifiers = {};
6449
+ while (modifierTokens.has(this.curValue)) {
6450
+ if (this.currentModifiers[this.curValue]) {
6451
+ DuplicateModifier.reportDiagnosticMessage([this.curLocation]);
6452
+ }
6453
+ this.currentModifiers[this.curValue] = this.curToken;
6454
+ this._lexerNext();
6455
+ }
6456
+ if (unsupportedDeclarations.has(this.curValue)) {
6457
+ UnsupportedSyntax.throwDiagnosticMessage([this.curLocation]);
6458
+ return;
6459
+ }
6460
+ if (supportedDeclarations.has(this.curValue)) {
6461
+ if (this.curValue != "attribute") {
6462
+ this.assertPossibleModifiers();
6463
+ }
6464
+ switch (this.curValue) {
6465
+ case "attribute":
6466
+ this.assertPossibleModifiers("static", "readonly");
6467
+ return this.parseAttribute();
6468
+ case "callback":
6469
+ return this.parseCallback();
6470
+ case "const":
6471
+ return this.parseConst();
6472
+ case "constructor":
6473
+ return this.parseConstructor();
6474
+ case "dictionary":
6475
+ return this.parseDictionary();
6476
+ case "enum":
6477
+ return this.parseEnum();
6478
+ case "import":
6479
+ return this.parseImport();
6480
+ case "interface":
6481
+ return this.parseInterface();
6482
+ case "namespace":
6483
+ return this.parseNamespace();
6484
+ case "package":
6485
+ {
6486
+ const pack = this.parsePackage();
6487
+ if (this.currentPackage) {
6488
+ DuplicatePackageDeclaration.reportDiagnosticMessage([pack.location]);
6489
+ }
6490
+ this.currentPackage = pack.name;
6491
+ if (scopeKind != IDLKind.File) {
6492
+ WrongDeclarationPlacement.reportDiagnosticMessage([pack.location], `Wrong declaration placement: package is not allowed in ${scopeKind}`);
6493
+ }
6494
+ return;
6495
+ }
6496
+ case "typedef":
6497
+ return this.parseTypedef();
6498
+ case "version":
6499
+ return this.parseVersion();
6500
+ }
6501
+ }
6502
+ else {
6503
+ this.assertPossibleModifiers("static", "async");
6504
+ return this.parseOperation();
6505
+ }
6506
+ }
6507
+ parseNamespace() {
6508
+ const sloc = this.trackLocation();
6509
+ const ext = this.consumeCurrentExtended();
6510
+ this.skip("namespace");
6511
+ const name = this.parseSingleIdentifier();
6512
+ const entries = [];
6513
+ this.skip("{");
6514
+ while (!this.seeAndSkip("}")) {
6515
+ const entry = this.parseDeclaration(IDLKind.Namespace);
6516
+ if (entry) {
6517
+ entries.push(entry);
6518
+ }
6519
+ }
6520
+ this.skip(";");
6521
+ return createNamespace(name.value, entries, { extendedAttributes: ext, nodeLocation: sloc(), nameLocation: name.location });
6522
+ }
6523
+ parseInterface() {
6524
+ const sloc = this.trackLocation();
6525
+ const ext = this.consumeCurrentExtended();
6526
+ this.skip("interface");
6527
+ const typeParameters = this.parseAndPushGenerics(ext);
6528
+ const name = this.parseSingleIdentifier();
6529
+ let bases = [];
6530
+ if (this.seeAndSkip(":")) {
6531
+ const typeList = this.parseTypeList();
6532
+ for (const type of typeList) {
6533
+ if (isReferenceType(type)) {
6534
+ bases.push(type);
6535
+ }
6536
+ else {
6537
+ ExpectedReferenceType.reportDiagnosticMessage([type.nodeLocation]);
6538
+ }
6539
+ }
6540
+ }
6541
+ const entries = [];
6542
+ this.skip("{");
6543
+ while (!this.seeAndSkip("}")) {
6544
+ const entry = this.parseDeclaration(IDLKind.Interface);
6545
+ if (entry) {
6546
+ if (isMethod(entry)) {
6547
+ entry.isFree = false;
6548
+ }
6549
+ entries.push(entry);
6550
+ }
6551
+ }
6552
+ this.skip(";");
6553
+ return createInterface(name.value, extractInterfaceSubkind(ext), bases, entries.filter(isConstructor$1), entries.filter(isConstant$1), entries.filter(isProperty), entries.filter(isMethod), entries.filter(isCallable), typeParameters, { extendedAttributes: ext, documentation: extractDocumentation(ext), nodeLocation: sloc(), nameLocation: name.location });
6554
+ }
6555
+ parseExtendedAttributes() {
6556
+ // For future extensions: here is also a good point for doc comments handling
6557
+ if (!this.seeAndSkip("[")) {
6558
+ return;
6559
+ }
6560
+ const ext = [];
6561
+ const names = new Set();
6562
+ const duplicates = new Set();
6563
+ let next = false;
6564
+ while (!this.seeAndSkip("]")) {
6565
+ if (next) {
6566
+ this.skip(",");
6567
+ }
6568
+ next = true;
6569
+ const name = this.parseSingleIdentifier();
6570
+ if (names.has(name.value)) {
6571
+ duplicates.add(name.value);
6572
+ }
6573
+ names.add(name.value);
6574
+ if (name.value == IDLExtendedAttributes.TypeArguments) {
6575
+ // TypeArguments parsing support
6576
+ try {
6577
+ this._enableInLiteralParsing = true;
6578
+ this.skip("=");
6579
+ const vloc = this.trackLocation();
6580
+ const start = this._curOffset; // Already after first quote
6581
+ this.skip("\"");
6582
+ const types = this.parseTypeList();
6583
+ const end = this._curOffset - 1; // Already after second quote
6584
+ this._enableInLiteralParsing = false;
6585
+ this.skip("\"");
6586
+ const stringValue = this.content.slice(start, end);
6587
+ ext.push({ name: name.value, value: stringValue, typesValue: types, nameLocation: name.location, valueLocation: vloc() });
6588
+ }
6589
+ catch (e) {
6590
+ this.skipToAfter("\"");
6591
+ throw e;
6592
+ }
6593
+ finally {
6594
+ this._enableInLiteralParsing = false;
6595
+ }
6596
+ }
6597
+ else {
6598
+ let value;
6599
+ if (this.seeAndSkip("=")) {
6600
+ value = this.parseFullIdentifierOrLiteral();
6601
+ }
6602
+ const converted = value ? valueFromIdentifierOrLiteral(value) : undefined;
6603
+ ext.push({ name: name.value, value: converted, nameLocation: name.location, valueLocation: value === null || value === void 0 ? void 0 : value.location });
6604
+ }
6605
+ }
6606
+ for (const dup of duplicates) {
6607
+ DuplicateExtendedAttribute.reportDiagnosticMessage(ext.filter(x => x.name == dup).map(x => x.nameLocation));
6608
+ }
6609
+ return ext;
6610
+ }
6611
+ parseTypeList() {
6612
+ const types = [this.parseType()];
6613
+ while (this.seeAndSkip(",")) {
6614
+ types.push(this.parseType());
6615
+ }
6616
+ return types;
6617
+ }
6618
+ parseType(outerExt) {
6619
+ var _a;
6620
+ const parsedExt = this.parseExtendedAttributes();
6621
+ const ext = parsedExt ? (outerExt ? parsedExt.concat(outerExt) : parsedExt) : (outerExt ? [...outerExt] : undefined);
6622
+ const sloc = this.trackLocation();
6623
+ if (this.seeAndSkip("(")) {
6624
+ let combinedTypes = [];
6625
+ let next = false;
6626
+ while (!this.seeAndSkip(")")) {
6627
+ if (next) {
6628
+ this.skip("or");
6629
+ }
6630
+ next = true;
6631
+ combinedTypes.push(this.parseType());
6632
+ }
6633
+ const isNullable = this.seeAndSkip("?") || combinedTypes.includes(IDLUndefinedType);
6634
+ combinedTypes = combinedTypes.filter(x => x !== IDLUndefinedType);
6635
+ const distilledType = combinedTypes.length == 1
6636
+ ? combinedTypes[0]
6637
+ : createUnionType(combinedTypes, undefined, { extendedAttributes: ext, nodeLocation: sloc() });
6638
+ if (isNullable) {
6639
+ return createOptionalType(distilledType, { extendedAttributes: ext, nodeLocation: sloc() });
6640
+ }
6641
+ return distilledType;
6642
+ }
6643
+ const name = this.parseFullIdentifier();
6644
+ const genArgs = (_a = extractTypeArguments(ext)) !== null && _a !== void 0 ? _a : [];
6645
+ if (this.seeAndSkip("<")) {
6646
+ let next = false;
6647
+ while (!this.seeAndSkip(">")) {
6648
+ if (next) {
6649
+ this.skip(",");
6650
+ }
6651
+ next = true;
6652
+ genArgs.push(this.parseType());
6653
+ }
6654
+ }
6655
+ let type;
6656
+ if (this.hasGeneric(name.value)) {
6657
+ if (genArgs.length > 0) {
6658
+ UnexpectedGenericArguments.reportDiagnosticMessage([name.location]);
6659
+ }
6660
+ type = createTypeParameterReference(name.value, { extendedAttributes: ext, nodeLocation: sloc(), nameLocation: name.location });
6661
+ }
6662
+ else if (builtinTypes.has(name.value)) {
6663
+ if (genArgs.length > 0) {
6664
+ UnexpectedGenericArguments.reportDiagnosticMessage([name.location]);
6665
+ }
6666
+ type = builtinTypes.get(name.value);
6667
+ }
6668
+ else if (builtinGenericTypeNames.has(name.value)) {
6669
+ if (genArgs.length == 0) {
6670
+ ExpectedGenericArguments.reportDiagnosticMessage([name.location]);
6671
+ }
6672
+ type = createContainerType(name.value, genArgs, { extendedAttributes: ext, nodeLocation: sloc(), nameLocation: name.location });
6673
+ }
6674
+ else {
6675
+ type = createReferenceType(name.value, genArgs.length > 0 ? genArgs : undefined, { extendedAttributes: ext, nodeLocation: sloc(), nameLocation: name.location });
6676
+ }
6677
+ const isNullable = this.seeAndSkip("?");
6678
+ if (isNullable) {
6679
+ return createOptionalType(type, { extendedAttributes: ext, nodeLocation: sloc() });
6680
+ }
6681
+ else {
6682
+ return type;
6683
+ }
6684
+ }
6685
+ parseReferenceType() {
6686
+ const type = this.parseType();
6687
+ if (!isReferenceType(type)) {
6688
+ ExpectedReferenceType.reportDiagnosticMessage([type.nodeLocation]);
6689
+ }
6690
+ return type;
6691
+ }
6692
+ parsePrimitiveType() {
6693
+ const type = this.parseType();
6694
+ if (!isPrimitiveType(type)) {
6695
+ ExpectedPrimitiveType.reportDiagnosticMessage([type.nodeLocation]);
6696
+ }
6697
+ return type;
6698
+ }
6699
+ parseArgTuple() {
6700
+ const args = [];
6701
+ const names = new Set();
6702
+ const duplicates = new Set();
6703
+ this.skip("(");
6704
+ let next = false;
6705
+ while (!this.seeAndSkip(")")) {
6706
+ if (next) {
6707
+ this.skip(",");
6708
+ }
6709
+ next = true;
6710
+ const arg = this.parseArg();
6711
+ if (names.has(arg.name)) {
6712
+ duplicates.add(arg.name);
6713
+ }
6714
+ names.add(arg.name);
6715
+ args.push(arg);
6716
+ }
6717
+ for (const dup of duplicates) {
6718
+ DuplicateArgumentName.reportDiagnosticMessage(args.filter(x => x.name == dup).map(x => x.nameLocation));
6719
+ }
6720
+ return args;
6721
+ }
6722
+ parseArg() {
6723
+ const ext = this.parseExtendedAttributes();
6724
+ const sloc = this.trackLocation();
6725
+ const optional = this.seeAndSkip("optional");
6726
+ // Note `extendedAttributes` forwarding
6727
+ const type = this.parseType(ext);
6728
+ const spread = this.seeAndSkip("...");
6729
+ const name = this.parseSingleIdentifier();
6730
+ // Note absense of `extendedAttributes`, they are only forwarded to `type`, as it was in the old parsing code
6731
+ return createParameter(name.value, type, optional, spread, { nodeLocation: sloc(), nameLocation: name.location });
6732
+ }
6733
+ parseOperation() {
6734
+ const sloc = this.trackLocation();
6735
+ const ext = this.consumeCurrentExtended();
6736
+ const isStatic = !!this.currentModifiers.static;
6737
+ const isAsync = !!this.currentModifiers.async;
6738
+ const isOptional = extractOptional(ext);
6739
+ const isFree = true; // Will be set to false in parseInterface if method is declared within interface
6740
+ const typeParameters = this.parseAndPushGenerics(ext);
6741
+ // Note `extendedAttributes` forwarding
6742
+ const retType = this.parseType(ext);
6743
+ const name = this.parseSingleIdentifier();
6744
+ const args = this.parseArgTuple();
6745
+ this.skip(";");
6746
+ if (ext === null || ext === void 0 ? void 0 : ext.some(x => x.name == IDLExtendedAttributes.CallSignature)) {
6747
+ return createCallable(name.value, args, retType, { isStatic, isAsync }, { extendedAttributes: ext, documentation: extractDocumentation(ext), nodeLocation: sloc(), nameLocation: name.location }, typeParameters);
6748
+ }
6749
+ return createMethod(name.value, args, retType, { isStatic, isAsync, isOptional, isFree }, { extendedAttributes: ext, documentation: extractDocumentation(ext), nodeLocation: sloc(), nameLocation: name.location }, typeParameters);
6750
+ }
6751
+ parseConstructor() {
6752
+ const sloc = this.trackLocation();
6753
+ const ext = this.consumeCurrentExtended();
6754
+ this.skip("constructor");
6755
+ const args = this.parseArgTuple();
6756
+ this.skip(";");
6757
+ return createConstructor(args, undefined, { extendedAttributes: ext, documentation: extractDocumentation(ext), nodeLocation: sloc() });
6758
+ }
6759
+ parseConst() {
6760
+ const sloc = this.trackLocation();
6761
+ const ext = this.consumeCurrentExtended();
6762
+ this.skip("const");
6763
+ const type = this.parseType();
6764
+ const name = this.parseSingleIdentifier();
6765
+ this.skip("=");
6766
+ const value = this.parseLiteral();
6767
+ const extracted = extractLiteral(value);
6768
+ this.skip(";");
6769
+ return createConstant(name.value, type, extracted.extractedString, { extendedAttributes: ext, nodeLocation: sloc(), nameLocation: name.location, valueLocation: value.location });
6770
+ }
6771
+ parseAttribute() {
6772
+ const sloc = this.trackLocation();
6773
+ const ext = this.consumeCurrentExtended();
6774
+ const isReadonly = !!this.currentModifiers.readonly;
6775
+ const isStatic = !!this.currentModifiers.static;
6776
+ const isOptional = extractOptional(ext);
6777
+ this.skip("attribute");
6778
+ const type = this.parseType();
6779
+ const name = this.parseSingleIdentifier();
6780
+ this.skip(";");
6781
+ return createProperty(name.value, type, isReadonly, isStatic, isOptional, { extendedAttributes: ext, documentation: extractDocumentation(ext), nodeLocation: sloc(), nameLocation: name.location });
6782
+ }
6783
+ parseTypedef() {
6784
+ const sloc = this.trackLocation();
6785
+ const ext = this.consumeCurrentExtended();
6786
+ this.skip("typedef");
6787
+ const typeParameters = this.parseAndPushGenerics(ext);
6788
+ const type = this.parseType();
6789
+ const name = this.parseSingleIdentifier();
6790
+ if (isUnionType(type)) {
6791
+ type.name = name.value;
6792
+ }
6793
+ this.skip(";");
6794
+ return createTypedef(name.value, type, typeParameters, { extendedAttributes: ext, documentation: extractDocumentation(ext), nodeLocation: sloc(), nameLocation: name.location });
6795
+ }
6796
+ parseCallback() {
6797
+ const sloc = this.trackLocation();
6798
+ const ext = this.consumeCurrentExtended();
6799
+ this.skip("callback");
6800
+ if (this.see("interface")) {
6801
+ UnsupportedSyntax.throwDiagnosticMessage([this.curLocation], "Unsupported syntax: callback interface");
6802
+ }
6803
+ const typeParameters = this.parseAndPushGenerics(ext);
6804
+ const name = this.parseSingleIdentifier();
6805
+ this.skip("=");
6806
+ const retType = this.parseType();
6807
+ const args = this.parseArgTuple();
6808
+ this.skip(";");
6809
+ return createCallback(name.value, args, retType, { extendedAttributes: ext, documentation: extractDocumentation(ext), nodeLocation: sloc(), nameLocation: name.location }, typeParameters);
6810
+ }
6811
+ parseEnum() {
6812
+ const sloc = this.trackLocation();
6813
+ const ext = this.consumeCurrentExtended();
6814
+ this.skip("enum");
6815
+ const name = this.parseSingleIdentifier();
6816
+ const items = [];
6817
+ this.skip("{");
6818
+ let next = false;
6819
+ while (!this.seeAndSkip("}")) {
6820
+ if (next) {
6821
+ this.skip(",");
6822
+ // Can have trailing comma
6823
+ if (this.seeAndSkip("}")) {
6824
+ break;
6825
+ }
6826
+ }
6827
+ next = true;
6828
+ const ext = this.parseExtendedAttributes();
6829
+ const entry = this.parseLiteral();
6830
+ const member = createEnumMember(entry.value, undefined, IDLNumberType, undefined, { extendedAttributes: ext, nodeLocation: entry.location, nameLocation: entry.location });
6831
+ items.push(member);
6832
+ }
6833
+ return createEnum(name.value, items, { extendedAttributes: ext, documentation: extractDocumentation(ext), nodeLocation: sloc(), nameLocation: name.location });
6834
+ }
6835
+ parseDictionary() {
6836
+ const sloc = this.trackLocation();
6837
+ const ext = this.consumeCurrentExtended();
6838
+ this.skip("dictionary");
6839
+ const name = this.parseSingleIdentifier();
6840
+ const items = [];
6841
+ this.skip("{");
6842
+ while (!this.seeAndSkip("}")) {
6843
+ items.push(this.parseDictionaryEntry());
6844
+ }
6845
+ this.skip(";");
6846
+ return createEnum(name.value, items, { extendedAttributes: ext, documentation: extractDocumentation(ext), nodeLocation: sloc(), nameLocation: name.location });
6847
+ }
6848
+ parseDictionaryEntry() {
6849
+ const ext = this.parseExtendedAttributes();
6850
+ const sloc = this.trackLocation();
6851
+ const type = this.parsePrimitiveType();
6852
+ const name = this.parseSingleIdentifier();
6853
+ this.skip("=");
6854
+ const value = this.parseLiteral();
6855
+ const extracted = extractLiteral(value);
6856
+ this.skip(";");
6857
+ return createEnumMember(name.value, undefined, type, extracted.extractedValue, { extendedAttributes: ext, nodeLocation: sloc(), nameLocation: name.location, valueLocation: value.location });
6858
+ }
6859
+ parsePackage() {
6860
+ const sloc = this.trackLocation();
6861
+ this.skip("package");
6862
+ const packagePath = this.parseFullIdentifierOrLiteral();
6863
+ this.skip(";");
6864
+ return { location: sloc(), name: valueFromIdentifierOrLiteral(packagePath) };
6865
+ }
6866
+ parseImport() {
6867
+ const sloc = this.trackLocation();
6868
+ this.skip("import");
6869
+ const importPath = this.parseFullIdentifierOrLiteral();
6870
+ let alias;
6871
+ if (this.seeAndSkip("as")) {
6872
+ alias = this.parseSingleIdentifier();
6873
+ }
6874
+ this.skip(";");
6875
+ return createImport(valueFromIdentifierOrLiteral(importPath).split("."), alias === null || alias === void 0 ? void 0 : alias.value, { nodeLocation: sloc(), nameLocation: alias === null || alias === void 0 ? void 0 : alias.location, valueLocation: importPath.location });
6876
+ }
6877
+ parseVersion() {
6878
+ const sloc = this.trackLocation();
6879
+ this.skip("version");
6880
+ const versionLiteral = this.parseLiteral();
6881
+ this.skip(";");
6882
+ return createVersion(versionLiteral.value.split("."), { nodeLocation: sloc(), valueLocation: versionLiteral.location });
6883
+ }
6884
+ }
6885
+ function prepareOffsets$1(lines) {
6886
+ let offsets = [];
6887
+ let offset = 0;
6888
+ for (let line of lines) {
6889
+ let plus = line.length;
6890
+ offsets.push(offset);
6891
+ offset += plus;
6892
+ }
6893
+ return offsets;
6894
+ }
6895
+ function valueFromIdentifierOrLiteral(token) {
6896
+ if (token.kind == TokenKind.Words && !literalTypes.has(token.value)) {
6897
+ return token.value;
6898
+ }
6899
+ return extractLiteral(token).extractedString;
6900
+ }
6901
+ const literalTypes = new Map([
6902
+ ["true", "boolean"],
6903
+ ["false", "boolean"],
6904
+ ["Infinity", "number"],
6905
+ ["-Infinity", "number"],
6906
+ ["NaN", "number"],
6907
+ ["null", "null"],
6908
+ ["undefined", "undefined"],
6909
+ ]);
6910
+ const extractedUndefined = { type: "undefined", extractedString: "undefined", extractedValue: "undefined" };
6911
+ function extractLiteral(token) {
6912
+ if (token.kind == TokenKind.Words) {
6913
+ if (!literalTypes.has(token.value)) {
6914
+ IncorrectLiteral.reportDiagnosticMessage([token.location]);
6915
+ return extractedUndefined;
6916
+ }
6917
+ const type = literalTypes.get(token.value);
6918
+ const extractedString = token.value;
6919
+ const extractedValue = type == "number" ? parseFloat(extractedString) : extractedString;
6920
+ return { type, extractedString, extractedValue };
6921
+ }
6922
+ if (token.kind != TokenKind.Literal) {
6923
+ IncorrectLiteral.reportDiagnosticMessage([token.location]);
6924
+ return extractedUndefined;
6925
+ }
6926
+ if (token.value[0] == "\"") {
6927
+ try {
6928
+ const extractedString = unescapeString(token.value);
6929
+ return { type: "string", extractedString, extractedValue: extractedString };
6930
+ }
6931
+ catch (e) {
6932
+ IncorrectLiteral.reportDiagnosticMessage([token.location], `Incorrect literal: ${e.message}`);
6933
+ return extractedUndefined;
6934
+ }
6935
+ }
6936
+ const extractedValue = parseFloat(token.value);
6937
+ if (Number.isNaN(extractedValue)) {
6938
+ // Real NaNs are handled before that, so report an error
6939
+ IncorrectLiteral.reportDiagnosticMessage([token.location]);
6940
+ }
6941
+ return { type: "number", extractedString: token.value, extractedValue };
6942
+ }
6943
+ // Taken from deserialize.ts as is
6944
+ function unescapeString(value) {
6945
+ if (!value.length || value[0] !== '"')
6946
+ return value;
6947
+ value = value.slice(1, -1);
6948
+ value = value.replace(/\\((['"\\bfnrtv])|([0-7]{1-3})|x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4}))/g, (_, all, c, oct, h2, u4) => {
6949
+ if (c !== undefined) {
6950
+ switch (c) {
6951
+ case "'": return "'";
6952
+ case '"': return '"';
6953
+ case "\\": return "\\";
6954
+ case "b": return "\b";
6955
+ case "f": return "\f";
6956
+ case "n": return "\n";
6957
+ case "r": return "\r";
6958
+ case "t": return "\t";
6959
+ case "v": return "\v";
6960
+ }
6961
+ }
6962
+ else if (oct !== undefined) {
6963
+ return String.fromCharCode(parseInt(oct, 8));
6964
+ }
6965
+ else if (h2 !== undefined) {
6966
+ return String.fromCharCode(parseInt(h2, 16));
6967
+ }
6968
+ else if (u4 !== undefined) {
6969
+ return String.fromCharCode(parseInt(u4, 16));
6970
+ }
6971
+ throw new Error(`unknown escape sequence: ${_}`);
6972
+ });
6973
+ return value;
6974
+ }
6975
+ function extractInterfaceSubkind(ext) {
6976
+ var _a;
6977
+ const ent = (_a = ext === null || ext === void 0 ? void 0 : ext.find(x => x.name == "Entity")) === null || _a === void 0 ? void 0 : _a.value;
6978
+ switch (ent) {
6979
+ case IDLEntity.Class: return IDLInterfaceSubkind.Class;
6980
+ case IDLEntity.Literal: return IDLInterfaceSubkind.AnonymousInterface;
6981
+ case IDLEntity.Tuple: return IDLInterfaceSubkind.Tuple;
6982
+ default: return IDLInterfaceSubkind.Interface;
6983
+ }
6984
+ }
6985
+ function extractDocumentation(ext) {
6986
+ var _a;
6987
+ return (_a = ext === null || ext === void 0 ? void 0 : ext.find(x => x.name == "Documentation")) === null || _a === void 0 ? void 0 : _a.value;
6988
+ }
6989
+ function extractOptional(ext) {
6990
+ var _a;
6991
+ return (_a = ext === null || ext === void 0 ? void 0 : ext.some(x => x.name.toLowerCase() == "optional")) !== null && _a !== void 0 ? _a : false;
6992
+ }
6993
+ function sanitizeTypeParameter(param) {
6994
+ const extendsIdx = param.indexOf('extends');
6995
+ if (extendsIdx !== -1) {
6996
+ return param.substring(0, extendsIdx).trim();
6997
+ }
6998
+ const eqIdx = param.indexOf('=');
6999
+ if (eqIdx !== -1) {
7000
+ return param.substring(0, eqIdx).trim();
7001
+ }
7002
+ return param;
7003
+ }
7004
+ function extractTypeParameters(ext) {
7005
+ var _a, _b, _c;
7006
+ return (_c = (_b = (_a = ext === null || ext === void 0 ? void 0 : ext.find(x => x.name == IDLExtendedAttributes.TypeParameters)) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.split(",")) === null || _c === void 0 ? void 0 : _c.map(sanitizeTypeParameter);
7007
+ }
7008
+ function extractTypeArguments(ext) {
7009
+ var _a;
7010
+ return (_a = ext === null || ext === void 0 ? void 0 : ext.find(x => x.name == IDLExtendedAttributes.TypeArguments)) === null || _a === void 0 ? void 0 : _a.typesValue;
7011
+ }
7012
+ const builtinTypesList = [IDLPointerType, IDLVoidType, IDLBooleanType,
7013
+ IDLObjectType, IDLI8Type, IDLU8Type, IDLI16Type, IDLU16Type,
7014
+ IDLI32Type, IDLU32Type, IDLI64Type, IDLU64Type, IDLF32Type,
7015
+ IDLF64Type, IDLBigintType, IDLNumberType, IDLStringType, IDLAnyType,
7016
+ IDLUndefinedType, IDLUnknownType, IDLObjectType, IDLThisType, IDLDate,
7017
+ IDLBufferType, IDLSerializerBuffer
7018
+ ];
7019
+ // Better solution will be to make it registry in idl.ts
7020
+ const builtinTypes = new Map(builtinTypesList.map(x => [x.name, x]));
7021
+ const builtinGenericTypeNames = new Set(["sequence", "record", "Promise"]);
6100
7022
 
6101
7023
  /*
6102
7024
  * Copyright (c) 2024 Huawei Device Co., Ltd.
@@ -6223,10 +7145,9 @@ class IDLDeserializer {
6223
7145
  }
6224
7146
  const implementations = [];
6225
7147
  node.inheritance.forEach(it => {
6226
- var _a;
6227
7148
  const attributes = it.extAttrs;
6228
7149
  const parentTypeArgs = this.extractTypeArguments(file, attributes !== null && attributes !== void 0 ? attributes : [], IDLExtendedAttributes.TypeArguments);
6229
- const attrs = (_a = this.toExtendedAttributes(attributes !== null && attributes !== void 0 ? attributes : [])) === null || _a === void 0 ? void 0 : _a.filter(it => it.name !== IDLExtendedAttributes.TypeArguments);
7150
+ const attrs = this.toExtendedAttributes(attributes !== null && attributes !== void 0 ? attributes : []); // ?.filter(it => it.name !== idl.IDLExtendedAttributes.TypeArguments)
6230
7151
  const ref = createReferenceType(it.inheritance, parentTypeArgs, {
6231
7152
  extendedAttributes: attrs
6232
7153
  });
@@ -6602,8 +7523,136 @@ class IDLDeserializer {
6602
7523
  return attr ? this.toExtendedAttributeValue(attr) : undefined;
6603
7524
  }
6604
7525
  }
7526
+ const DifferenceFound = new DiagnosticMessageGroup("error", "DifferenceFound", "Difference found");
7527
+ const noCompare = new Set(["parent", "fileName", "nodeLocation", "nameLocation", "valueLocation", "typesValue"]);
7528
+ const canContainMoreCompare = new Set(["extendedAttributes", "typeParameters", "typeArguments"]);
7529
+ function safeString(value) {
7530
+ if (typeof value == "symbol") {
7531
+ return String(value);
7532
+ }
7533
+ return JSON.stringify(value, (k, v) => { return noCompare.has(k) ? undefined : v; });
7534
+ }
7535
+ function joinPath(left, right) {
7536
+ if (!right) {
7537
+ return left;
7538
+ }
7539
+ return `${left}.${right}`;
7540
+ }
7541
+ function compareDeep(oldData, newData, paths) {
7542
+ var _a;
7543
+ const location = (newData === null || newData === void 0 ? void 0 : newData.kind) && ((_a = newData === null || newData === void 0 ? void 0 : newData.nameLocation) !== null && _a !== void 0 ? _a : newData === null || newData === void 0 ? void 0 : newData.nodeLocation);
7544
+ const diffs = [];
7545
+ if (typeof oldData != typeof newData) {
7546
+ diffs.push({ path: "", oldValue: safeString(oldData), newValue: safeString(newData) });
7547
+ }
7548
+ else if (Array.isArray(oldData) && Array.isArray(newData)) {
7549
+ const len = Math.max(oldData.length, newData.length);
7550
+ if (oldData.length != newData.length) {
7551
+ diffs.push({ path: "", oldValue: `(length=${oldData.length})`, newValue: `(length=${newData.length})` });
7552
+ }
7553
+ for (let i = 0; i < len; ++i) {
7554
+ const deeperDiffs = compareDeep(oldData[i], newData[i], paths);
7555
+ if (deeperDiffs.length > 0) {
7556
+ diffs.push(...deeperDiffs.map(x => { x.path = joinPath("" + i, x.path); return x; }));
7557
+ }
7558
+ }
7559
+ }
7560
+ else if (typeof newData == "object") {
7561
+ const keys = [...new Set([...Object.getOwnPropertyNames(oldData), ...Object.getOwnPropertyNames(newData)])].filter(x => !noCompare.has(x));
7562
+ for (const k of keys) {
7563
+ let oldValue = oldData[k];
7564
+ let newValue = newData[k];
7565
+ if (canContainMoreCompare.has(k)) {
7566
+ if (newValue == null && Array.isArray(oldValue) && oldValue.length == 0) {
7567
+ continue;
7568
+ }
7569
+ if (oldValue == null && Array.isArray(newValue)) {
7570
+ continue;
7571
+ }
7572
+ if (Array.isArray(oldValue) && Array.isArray(newValue)) {
7573
+ if (newValue.length > oldValue.length) {
7574
+ // Cases when old parser takes attributes from outer declaration and ignores the right ones
7575
+ newValue = newValue.slice(newValue.length - oldValue.length);
7576
+ }
7577
+ else if (oldValue.length > newValue.length) {
7578
+ // Cases when types in parentheses have own attributes, but old parser adds attributes from outer declaration
7579
+ oldValue = oldValue.slice(0, newValue.length);
7580
+ }
7581
+ }
7582
+ }
7583
+ const deeperDiffs = compareDeep(oldValue, newValue, paths);
7584
+ if (deeperDiffs.length > 0) {
7585
+ diffs.push(...deeperDiffs.map(x => { x.path = joinPath(k, x.path); return x; }));
7586
+ }
7587
+ }
7588
+ }
7589
+ else {
7590
+ if (oldData != newData) {
7591
+ diffs.push({ path: "", oldValue: safeString(oldData), newValue: safeString(newData) });
7592
+ }
7593
+ }
7594
+ if (!location) {
7595
+ return diffs;
7596
+ }
7597
+ for (const diff of diffs) {
7598
+ paths.add(diff.path);
7599
+ DifferenceFound.reportDiagnosticMessage([location], `path: ${diff.path} oldValue: ${diff.oldValue} newValue: ${diff.newValue}`);
7600
+ }
7601
+ return [];
7602
+ }
7603
+ function compareParsingResults(oldFile, newFile) {
7604
+ const paths = new Set();
7605
+ compareDeep(oldFile, newFile, paths);
7606
+ if (paths.size > 0) {
7607
+ DifferenceFound.reportDiagnosticMessage([newFile.nodeLocation], "Differences found in those paths:\n" + [...paths].join("\n"));
7608
+ }
7609
+ }
7610
+ function parseIdlNew(fileName, content, registerSynthetics) {
7611
+ let file = new Parser(fileName, content).parseIDL();
7612
+ const ancestors = [];
7613
+ const namespaces = [];
7614
+ // Mimic old parser and deserialize.ts behavior:
7615
+ // 1. Add `fileName`.
7616
+ // 2. Add `parent`.
7617
+ // 3. Possibly register node with `addSyntheticType` if "Synthetic" is in attributes
7618
+ forEachChild(file, (node) => {
7619
+ var _a;
7620
+ if (isPrimitiveType(node)) {
7621
+ return;
7622
+ }
7623
+ node.fileName = fileName;
7624
+ if (registerSynthetics && isEntry(node) && ((_a = node.extendedAttributes) === null || _a === void 0 ? void 0 : _a.some(it => it.name === "Synthetic"))) {
7625
+ const fqName = file.packageClause.concat(namespaces).concat([node.name]).join('.');
7626
+ addSyntheticType(fqName, node);
7627
+ }
7628
+ if (ancestors.length) {
7629
+ node.parent = ancestors[ancestors.length - 1];
7630
+ }
7631
+ if (isNamespace(node)) {
7632
+ namespaces.push(node.name);
7633
+ }
7634
+ ancestors.push(node);
7635
+ }, (node) => {
7636
+ if (isPrimitiveType(node)) {
7637
+ return;
7638
+ }
7639
+ if (isNamespace(node)) {
7640
+ namespaces.pop();
7641
+ }
7642
+ ancestors.pop();
7643
+ });
7644
+ return file;
7645
+ }
6605
7646
  function toIDLFile(fileName, { content, inheritanceMode = 'multiple' } = {}) {
6606
7647
  var _a, _b, _c;
7648
+ let newFile;
7649
+ const mode = process.env.IDLPARSE;
7650
+ if (mode == "compare" || mode == "new") {
7651
+ newFile = parseIdlNew(fileName, content, mode == "new");
7652
+ if (mode == "new") {
7653
+ return [newFile, new Map()];
7654
+ }
7655
+ }
6607
7656
  const lexicalInfo = new Map();
6608
7657
  const deserializer = new IDLDeserializer(lexicalInfo, inheritanceMode);
6609
7658
  if (undefined === content) {
@@ -6612,7 +7661,7 @@ function toIDLFile(fileName, { content, inheritanceMode = 'multiple' } = {}) {
6612
7661
  }
6613
7662
  catch (e) {
6614
7663
  content = "";
6615
- LoadingErrorMessage.throwDiagnosticMessage([{ documentPath: fileName }], (_a = e.message) !== null && _a !== void 0 ? _a : "");
7664
+ throw new FatalParserException([LoadingFatal.reportDiagnosticMessage([{ documentPath: fileName }], (_a = e.message) !== null && _a !== void 0 ? _a : "")]);
6616
7665
  }
6617
7666
  }
6618
7667
  let lines = (_b = content.match(/[^\r\n]*(\n|\r\n)?/g)) !== null && _b !== void 0 ? _b : [];
@@ -6628,9 +7677,9 @@ function toIDLFile(fileName, { content, inheritanceMode = 'multiple' } = {}) {
6628
7677
  if (e.name == "WebIDLParseError") {
6629
7678
  let tokens = e.tokens;
6630
7679
  let range = tokens.length > 0 ? rangeForToken(offsets, tokens[0]) : undefined;
6631
- ParsingErrorMessage.throwDiagnosticMessage([{ documentPath: fileName, range, lines }], e.bareMessage);
7680
+ throw new FatalParserException([ParsingFatal.reportDiagnosticMessage([{ documentPath: fileName, range, lines }], e.bareMessage)]);
6632
7681
  }
6633
- UnknownErrorMessage.throwDiagnosticMessage([{ documentPath: fileName }], (_c = e.message) !== null && _c !== void 0 ? _c : "");
7682
+ throw new FatalParserException([InternalFatal.reportDiagnosticMessage([{ documentPath: fileName, lines }], (_c = e.message) !== null && _c !== void 0 ? _c : "")]);
6634
7683
  }
6635
7684
  const entries = rawParsingResults
6636
7685
  .filter(it => {
@@ -6654,6 +7703,10 @@ function toIDLFile(fileName, { content, inheritanceMode = 'multiple' } = {}) {
6654
7703
  node.nameLocation = nameLocation;
6655
7704
  }
6656
7705
  });
7706
+ if (mode == "compare") {
7707
+ compareParsingResults(file, newFile);
7708
+ return [newFile, new Map()];
7709
+ }
6657
7710
  return [file, lexicalInfo];
6658
7711
  }
6659
7712
  function prepareOffsets(lines) {
@@ -8681,7 +9734,7 @@ function mk(typeName, check, config) {
8681
9734
  }
8682
9735
  return new ValidationBox({
8683
9736
  success: false,
8684
- errorMessage: `Expected "${typeName}"`
9737
+ errorMessage: `Expected "${typeName}" but got "${typeof x}"`
8685
9738
  });
8686
9739
  }, () => {
8687
9740
  const base = {
@@ -8987,6 +10040,7 @@ const HookMethodSchema = D.object({
8987
10040
  replaceImplementation: D.boolean()
8988
10041
  });
8989
10042
  D.object({
10043
+ ApiKind: D.number(),
8990
10044
  TypePrefix: D.string(),
8991
10045
  LibraryPrefix: D.string(),
8992
10046
  OptionalPrefix: D.string(),
@@ -9007,6 +10061,7 @@ D.object({
9007
10061
  globalPackages: T.stringArray()
9008
10062
  });
9009
10063
  const defaultCoreConfiguration = {
10064
+ ApiKind: 0,
9010
10065
  TypePrefix: "",
9011
10066
  LibraryPrefix: "",
9012
10067
  OptionalPrefix: "",
@@ -10834,6 +11889,66 @@ const JSON5 = {
10834
11889
 
10835
11890
  var lib = JSON5;
10836
11891
 
11892
+ /*
11893
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
11894
+ * Licensed under the Apache License, Version 2.0 (the "License");
11895
+ * you may not use this file except in compliance with the License.
11896
+ * You may obtain a copy of the License at
11897
+ *
11898
+ * http://www.apache.org/licenses/LICENSE-2.0
11899
+ *
11900
+ * Unless required by applicable law or agreed to in writing, software
11901
+ * distributed under the License is distributed on an "AS IS" BASIS,
11902
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11903
+ * See the License for the specific language governing permissions and
11904
+ * limitations under the License.
11905
+ */
11906
+ class Config {
11907
+ constructor(ignore, nonNullable, irHack, fragments, parameters) {
11908
+ this.ignore = ignore;
11909
+ this.nonNullable = nonNullable;
11910
+ this.irHack = irHack;
11911
+ this.fragments = fragments;
11912
+ this.parameters = parameters;
11913
+ }
11914
+ static get createPrefix() {
11915
+ return `Create`;
11916
+ }
11917
+ static get updatePrefix() {
11918
+ return `Update`;
11919
+ }
11920
+ static get constPostfix() {
11921
+ return `Const`;
11922
+ }
11923
+ static get nodeTypeAttribute() {
11924
+ return `Es2pandaAstNodeType`;
11925
+ }
11926
+ static get nodeNamespaceAttribute() {
11927
+ return `cpp_namespace`;
11928
+ }
11929
+ static get uselessPrefix() {
11930
+ return `Get`;
11931
+ }
11932
+ static get astNodeCommonAncestor() {
11933
+ return `AstNode`;
11934
+ }
11935
+ static get context() {
11936
+ return `Context`;
11937
+ }
11938
+ static get dataClassPrefix() {
11939
+ return `es2panda_`;
11940
+ }
11941
+ static get defaultAncestor() {
11942
+ return `ArktsObject`;
11943
+ }
11944
+ static get irNamespace() {
11945
+ return `ir`;
11946
+ }
11947
+ }
11948
+ Config.DoNotPrintPeers = [
11949
+ 'es2panda_Context', // useless
11950
+ ];
11951
+
10837
11952
  /*
10838
11953
  * Copyright (c) 2024 Huawei Device Co., Ltd.
10839
11954
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -10859,7 +11974,11 @@ class BridgesConstructions {
10859
11974
  return `impl_${name}`;
10860
11975
  }
10861
11976
  static referenceType(name) {
10862
- return `es2panda_${name}*`;
11977
+ // FIXME: Rewrite CastTypeConvertors using idl.CppInteropArgConverter
11978
+ // and LanguageWriter constructions.
11979
+ // Use c_type attribute from declaration.
11980
+ const addPrefix = (n) => (n.startsWith(Config.dataClassPrefix) ? n : `${Config.dataClassPrefix}${n}`);
11981
+ return `${addPrefix(name)}*`;
10863
11982
  }
10864
11983
  static get sequenceLengthDeclaration() {
10865
11984
  return `std::size_t length`;
@@ -10900,9 +12019,6 @@ class BridgesConstructions {
10900
12019
  static get stringCast() {
10901
12020
  return `getStringCopy`;
10902
12021
  }
10903
- static resultAssignment(value) {
10904
- return `auto ${BridgesConstructions.result} = ${value}`;
10905
- }
10906
12022
  static dropConstCast(value) {
10907
12023
  return `(void*)${value}`;
10908
12024
  }
@@ -10917,63 +12033,6 @@ class BridgesConstructions {
10917
12033
  }
10918
12034
  }
10919
12035
 
10920
- /*
10921
- * Copyright (c) 2024 Huawei Device Co., Ltd.
10922
- * Licensed under the Apache License, Version 2.0 (the "License");
10923
- * you may not use this file except in compliance with the License.
10924
- * You may obtain a copy of the License at
10925
- *
10926
- * http://www.apache.org/licenses/LICENSE-2.0
10927
- *
10928
- * Unless required by applicable law or agreed to in writing, software
10929
- * distributed under the License is distributed on an "AS IS" BASIS,
10930
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10931
- * See the License for the specific language governing permissions and
10932
- * limitations under the License.
10933
- */
10934
- class Config {
10935
- constructor(ignore, nonNullable, irHack, fragments, parameters) {
10936
- this.ignore = ignore;
10937
- this.nonNullable = nonNullable;
10938
- this.irHack = irHack;
10939
- this.fragments = fragments;
10940
- this.parameters = parameters;
10941
- }
10942
- static get createPrefix() {
10943
- return `Create`;
10944
- }
10945
- static get updatePrefix() {
10946
- return `Update`;
10947
- }
10948
- static get constPostfix() {
10949
- return `Const`;
10950
- }
10951
- static get nodeTypeAttribute() {
10952
- return `Es2pandaAstNodeType`;
10953
- }
10954
- static get nodeNamespaceAttribute() {
10955
- return `cpp_namespace`;
10956
- }
10957
- static get uselessPrefix() {
10958
- return `Get`;
10959
- }
10960
- static get astNodeCommonAncestor() {
10961
- return `AstNode`;
10962
- }
10963
- static get context() {
10964
- return `Context`;
10965
- }
10966
- static get dataClassPrefix() {
10967
- return `es2panda_`;
10968
- }
10969
- static get defaultAncestor() {
10970
- return `ArktsObject`;
10971
- }
10972
- static get irNamespace() {
10973
- return `ir`;
10974
- }
10975
- }
10976
-
10977
12036
  /*
10978
12037
  * Copyright (c) 2024 Huawei Device Co., Ltd.
10979
12038
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -11126,7 +12185,7 @@ function isReal(node) {
11126
12185
  return nodeType(node) !== undefined;
11127
12186
  }
11128
12187
  function isDataClass(node) {
11129
- return parent(node) === Config.defaultAncestor;
12188
+ return node.name.startsWith(Config.dataClassPrefix) || parent(node) === Config.defaultAncestor;
11130
12189
  }
11131
12190
  function isCreate(name) {
11132
12191
  return isCreateOrUpdate(name) && name.startsWith(Config.createPrefix);
@@ -11138,6 +12197,9 @@ function isCreateOrUpdate(sourceMethodName) {
11138
12197
  const { rest } = splitCreateOrUpdate(sourceMethodName);
11139
12198
  return rest.length <= 1;
11140
12199
  }
12200
+ function isImplInterface(name) {
12201
+ return dropPrefix(name, Config.dataClassPrefix) === 'Impl';
12202
+ }
11141
12203
  function fixEnumPrefix(name) {
11142
12204
  if (name.startsWith(`es2panda_`)) {
11143
12205
  name = dropPrefix(name, `es2panda_`);
@@ -11225,6 +12287,9 @@ function nodeNamespace(node) {
11225
12287
  var _a;
11226
12288
  return (_a = getNamespacesPathFor(node)[0]) === null || _a === void 0 ? void 0 : _a.name;
11227
12289
  }
12290
+ function fqName(node) {
12291
+ return getQualifiedName(node, "namespace.name");
12292
+ }
11228
12293
  function parent(node) {
11229
12294
  var _a;
11230
12295
  return (_a = node.inheritance[0]) === null || _a === void 0 ? void 0 : _a.name;
@@ -11232,14 +12297,6 @@ function parent(node) {
11232
12297
  function createDefaultTypescriptWriter() {
11233
12298
  return new TSLanguageWriter(new IndentedPrinter(), createEmptyReferenceResolver(), { convert: (node) => throwException(`unexpected type conversion`) });
11234
12299
  }
11235
- function isIrNamespace(node) {
11236
- var _a, _b;
11237
- let cppNamespace = (_b = (_a = node.extendedAttributes) === null || _a === void 0 ? void 0 : _a.find(it => it.name == Config.nodeNamespaceAttribute)) === null || _b === void 0 ? void 0 : _b.value;
11238
- return nodeNamespace(node) === Config.irNamespace || cppNamespace == Config.irNamespace;
11239
- }
11240
- function createSequence(inner) {
11241
- return createContainerType(`sequence`, [inner]);
11242
- }
11243
12300
  function innerType(node) {
11244
12301
  return node.elementType[0];
11245
12302
  }
@@ -11267,8 +12324,13 @@ function makeSignature(parameters, returnType) {
11267
12324
  .map(it => it.name)
11268
12325
  .map(mangleIfKeyword));
11269
12326
  }
11270
- function flatParents(ref, idl) {
11271
- const resolveReference = (ref) => resolveNamedNode(ref.name.split('.'), undefined, [idl]);
12327
+ function makeExpression(writer, arg) {
12328
+ return typeof arg === 'string' ? writer.makeString(arg) : arg;
12329
+ }
12330
+ function makeStatement(writer, arg) {
12331
+ return typeof arg !== 'string' && 'write' in arg ? arg : writer.makeStatement(makeExpression(writer, arg));
12332
+ }
12333
+ function flatParentsImpl(ref, resolveReference) {
11272
12334
  if (isReferenceType(ref)) {
11273
12335
  const type = resolveReference(ref);
11274
12336
  if (!type || !isInterface$1(type)) {
@@ -11281,13 +12343,21 @@ function flatParents(ref, idl) {
11281
12343
  while (queue.length) {
11282
12344
  const node = queue.shift();
11283
12345
  result.push(node);
12346
+ if (result.length > 1 && baseNameString(ref.name) === node.name) {
12347
+ //console.warn(`Cyclic dependency: ${ref.name} -> ${node.name}`);
12348
+ break;
12349
+ }
11284
12350
  node.inheritance
11285
- .map(p => resolveReference(p))
12351
+ .map(p => resolveReference(p, ref))
11286
12352
  .filter(p => p !== undefined && isInterface$1(p))
11287
12353
  .forEach(p => queue.push(p));
11288
12354
  }
11289
12355
  return result; // with self
11290
12356
  }
12357
+ function flatParents(ref, idl) {
12358
+ const resolveReference = (ref, pov) => resolveNamedNode(ref.name.split('.'), pov, [idl]);
12359
+ return flatParentsImpl(ref, resolveReference);
12360
+ }
11291
12361
 
11292
12362
  /*
11293
12363
  * Copyright (c) 2024 Huawei Device Co., Ltd.
@@ -11304,54 +12374,64 @@ function flatParents(ref, idl) {
11304
12374
  * limitations under the License.
11305
12375
  */
11306
12376
  class Typechecker {
11307
- constructor(idl) {
11308
- this.idl = idl;
11309
- this.idl = linearizeNamespaceMembers(idl);
12377
+ constructor(file) {
12378
+ this.file = file;
12379
+ this.namespaces = this.file.entries.filter(e => isNamespace(e));
12380
+ }
12381
+ resolveReference(ref) {
12382
+ const prefix = Config.dataClassPrefix;
12383
+ // XXX: This is a temporary hack until duplicates will not be removed from idl
12384
+ if (ref.name.startsWith(prefix)) {
12385
+ const entry = this.resolveReference2(createReferenceType(ref.name.slice(prefix.length)));
12386
+ if (entry) {
12387
+ return entry;
12388
+ }
12389
+ }
12390
+ return this.resolveReference2(ref);
11310
12391
  }
11311
- findRealDeclaration(name) {
11312
- // Poor man's namespace-aware resolve.
11313
- // TODO: REWORK IT ALL!
11314
- const declarations = this.idl.filter(it => (name === it.name) || (baseNameString(name) == baseNameString(it.name)));
11315
- if (declarations.length === 1) {
11316
- return declarations[0];
12392
+ resolveReference2(ref, debugPrefix = '') {
12393
+ const target = ref.name.split('.');
12394
+ let entry = undefined;
12395
+ if (target.length > 1) { // full-qualified
12396
+ entry = resolveNamedNode(target, undefined, [this.file]);
11317
12397
  }
11318
- const ir = declarations
11319
- .filter(isInterface$1)
11320
- .filter(it => isIrNamespace(it));
11321
- if (ir.length > 0) {
11322
- return ir[0];
12398
+ else {
12399
+ if (ref.parent) {
12400
+ entry = resolveNamedNode(target, ref.parent, [this.file]);
12401
+ }
12402
+ if (!entry) {
12403
+ for (const pov of this.namespaces) {
12404
+ entry = resolveNamedNode(target, pov, [this.file]);
12405
+ if (entry)
12406
+ break;
12407
+ }
12408
+ }
11323
12409
  }
11324
- return undefined;
11325
- }
11326
- isHeir(name, ancestor) {
11327
- if (name === ancestor) {
11328
- return true;
12410
+ if (debugPrefix.length) {
12411
+ console.log(`RESOLVER: ${ref.name} => ${entry ? fqName(entry) : entry}`);
11329
12412
  }
11330
- const declaration = this.findRealDeclaration(name);
11331
- if (declaration === undefined || !isInterface$1(declaration)) {
12413
+ return entry;
12414
+ }
12415
+ // All classes are consideres heirs of ArktsObject now
12416
+ isHeir(ref, ancestor) {
12417
+ const resolveReference = (r, _) => this.resolveReference(r);
12418
+ const iface = isReferenceType(ref) ? resolveReference(ref) : ref;
12419
+ if (!iface || !isInterface$1(iface)) {
11332
12420
  return false;
11333
12421
  }
11334
- let isHeir = declaration.name === ancestor;
11335
- declaration.inheritance.forEach(parent => {
11336
- isHeir || (isHeir = this.isHeir(parent.name, ancestor));
11337
- });
11338
- // TODO: Should be fixed or moved to config
11339
- const objects = [
11340
- "Program", "ArkTsConfig", "AstDumper", "SrcDumper",
11341
- "FunctionSignature", "ValidationInfo"
11342
- ];
11343
- if (!isHeir) {
11344
- if (ancestor === Config.defaultAncestor &&
11345
- objects.includes(declaration.name))
11346
- return true;
12422
+ const parents = flatParentsImpl(iface, resolveReference);
12423
+ if (parents.map(p => p.name).includes(ancestor)) {
12424
+ return true;
11347
12425
  }
11348
- return isHeir;
12426
+ return ancestor === Config.defaultAncestor;
11349
12427
  }
11350
12428
  isPeer(node) {
11351
- if (node === Config.astNodeCommonAncestor)
12429
+ if (node.name === Config.astNodeCommonAncestor)
11352
12430
  return false; // TODO: is handwritten
11353
- if (node === Config.context)
12431
+ if (node.name === Config.context)
11354
12432
  return false; // TODO: is handwritten
12433
+ if (isImplInterface(node.name))
12434
+ return false;
11355
12435
  if (this.isHeir(node, Config.astNodeCommonAncestor))
11356
12436
  return true;
11357
12437
  if (this.isHeir(node, Config.defaultAncestor))
@@ -11362,7 +12442,7 @@ class Typechecker {
11362
12442
  if (!isReferenceType(type)) {
11363
12443
  return false;
11364
12444
  }
11365
- const declaration = this.findRealDeclaration(type.name);
12445
+ const declaration = this.resolveReference(type);
11366
12446
  return declaration !== undefined && isTarget(declaration);
11367
12447
  }
11368
12448
  isConstReturnValue(node) {
@@ -11372,35 +12452,13 @@ class Typechecker {
11372
12452
  return node.name.endsWith(Config.constPostfix);
11373
12453
  }
11374
12454
  nodeTypeName(node) {
11375
- var _a, _b;
12455
+ var _a;
11376
12456
  const value = nodeType(node);
11377
- const idlEnum = this.idl
11378
- .filter(isEnum$1)
11379
- .find(it => it.name === Config.nodeTypeAttribute);
11380
- return (_b = (_a = idlEnum === null || idlEnum === void 0 ? void 0 : idlEnum.elements) === null || _a === void 0 ? void 0 : _a.find(it => { var _a; return ((_a = it.initializer) === null || _a === void 0 ? void 0 : _a.toString()) === value; })) === null || _b === void 0 ? void 0 : _b.name;
11381
- }
11382
- parent(node) {
11383
- const parentName = parent(node);
11384
- if (parentName === undefined)
11385
- return undefined;
11386
- const decl = this.findRealDeclaration(parentName);
11387
- if (decl === undefined)
11388
- return undefined;
11389
- if (!isInterface$1(decl))
11390
- return undefined;
11391
- return decl;
11392
- }
11393
- ancestry(node) {
11394
- let current = node;
11395
- const res = [];
11396
- while (true) {
11397
- res.push(current);
11398
- const parent = this.parent(current);
11399
- if (parent === undefined) {
11400
- return res;
11401
- }
11402
- current = parent;
11403
- }
12457
+ const entry = this.resolveReference(createReferenceType(Config.nodeTypeAttribute));
12458
+ const name = entry && isEnum$1(entry)
12459
+ ? (_a = entry.elements.find(e => { var _a; return ((_a = e.initializer) === null || _a === void 0 ? void 0 : _a.toString()) === value; })) === null || _a === void 0 ? void 0 : _a.name
12460
+ : undefined;
12461
+ return name ? `${Config.nodeTypeAttribute}.${name}` : undefined; // value
11404
12462
  }
11405
12463
  }
11406
12464
 
@@ -11432,7 +12490,7 @@ class SingleFilePrinter extends AbstractVisitor {
11432
12490
  constructor(idl) {
11433
12491
  super();
11434
12492
  this.idl = idl;
11435
- this.typechecker = new Typechecker(this.idl.entries);
12493
+ this.typechecker = new Typechecker(this.idl);
11436
12494
  }
11437
12495
  printEnum(node) { }
11438
12496
  visit(node) {
@@ -11479,7 +12537,7 @@ class InteropPrinter extends AbstractVisitor {
11479
12537
  constructor(file) {
11480
12538
  super();
11481
12539
  this.file = file;
11482
- this.typechecker = new Typechecker(this.file.entries);
12540
+ this.typechecker = new Typechecker(this.file);
11483
12541
  }
11484
12542
  print() {
11485
12543
  this.file.entries.forEach(it => this.visit(it));
@@ -11569,9 +12627,6 @@ class BaseTypeConvertor {
11569
12627
  return convertType(this, type);
11570
12628
  }
11571
12629
  }
11572
- function composedConvertType(result, effect, type) {
11573
- return result.convertType(effect.convertType(type));
11574
- }
11575
12630
 
11576
12631
  /*
11577
12632
  * Copyright (c) 2024 Huawei Device Co., Ltd.
@@ -11725,7 +12780,7 @@ class CastToTypeConvertor extends BaseTypeConvertor {
11725
12780
  sequence: (type) => BridgesConstructions.arrayOf(this.convertType(innerType(type))),
11726
12781
  enum: (type) => type.name,
11727
12782
  reference: (type) => {
11728
- return BridgesConstructions.referenceType(typechecker.isHeir(type.name, Config.astNodeCommonAncestor)
12783
+ return BridgesConstructions.referenceType(typechecker.isHeir(type, Config.astNodeCommonAncestor)
11729
12784
  ? Config.astNodeCommonAncestor
11730
12785
  : baseName(type));
11731
12786
  },
@@ -11769,6 +12824,8 @@ class BridgesPrinter extends InteropPrinter {
11769
12824
  this.config = config;
11770
12825
  this.castTypeConvertor = new CastTypeConvertor(this.typechecker);
11771
12826
  this.nativeTypeConvertor = new NativeTypeConvertor(this.typechecker);
12827
+ this.returnTypeConvertor = new ReturnTypeConvertor$1(this.typechecker);
12828
+ this.interopMacroConvertor = new InteropMacroTypeConvertor(this.typechecker);
11772
12829
  this.writer = new CppLanguageWriter(new IndentedPrinter(), createEmptyReferenceResolver(), { convert: (node) => this.nativeTypeConvertor.convertType(node) }, new class extends PrimitiveTypeList {
11773
12830
  constructor() {
11774
12831
  super(...arguments);
@@ -11776,82 +12833,62 @@ class BridgesPrinter extends InteropPrinter {
11776
12833
  this.Void = new PrimitiveType(`void`);
11777
12834
  }
11778
12835
  }());
11779
- this.returnTypeConvertor = new ReturnTypeConvertor$1(this.typechecker);
11780
- this.interopMacroConvertor = new InteropMacroTypeConvertor(this.typechecker);
11781
- }
11782
- printInteropMacro(methodName, signature) {
11783
- this.writer.writeExpressionStatement(this.writer.makeFunctionCall(BridgesConstructions.interopMacro(isVoidType(signature.returnType), signature.args.length), [methodName]
11784
- .concat((() => {
11785
- if (isVoidType(signature.returnType)) {
11786
- return [];
11787
- }
11788
- return [this.returnTypeConvertor.convertType(signature.returnType)];
11789
- })()
11790
- .concat(signature.args)
11791
- .map(it => this.interopMacroConvertor.convertType(it)))
11792
- .map(it => this.writer.makeString(it))));
11793
12836
  }
11794
12837
  printMethod(iface, node) {
12838
+ if (this.config.ignore.isIgnoredMethod(iface.name, node.name))
12839
+ return;
11795
12840
  const [methodName, signature] = BridgesPrinter.makeFunctionDeclaration(iface, node, this.returnTypeConvertor);
11796
- this.writer.writeFunctionImplementation(BridgesConstructions.implFunction(methodName), signature, (_) => this.printBody(iface, node, signature));
12841
+ this.writer.writeFunctionImplementation(BridgesConstructions.implFunction(methodName), signature, (_) => {
12842
+ let pandaMethodName = BridgesConstructions.callMethod(methodName);
12843
+ if (this.config.irHack.isIrHackInterface(iface.name)) {
12844
+ pandaMethodName = pandaMethodName.replace(iface.name, `${iface.name}Ir`);
12845
+ }
12846
+ this.printBody(node, signature, pandaMethodName);
12847
+ });
11797
12848
  this.printInteropMacro(methodName, signature);
11798
12849
  this.writer.writeLines(``);
11799
12850
  }
12851
+ printInteropMacro(methodName, signature) {
12852
+ const isVoid = isVoidType(signature.returnType);
12853
+ const args = (isVoid ? [] : [signature.returnType])
12854
+ .concat(signature.args)
12855
+ .map(a => this.interopMacroConvertor.convertType(a));
12856
+ args.splice(0, 0, methodName);
12857
+ this.writer.writeExpressionStatement(this.writer.makeFunctionCall(BridgesConstructions.interopMacro(isVoid, signature.args.length), args.map(it => this.writer.makeString(it))));
12858
+ }
11800
12859
  static makeFunctionDeclaration(iface, node, converter) {
11801
12860
  var _a;
11802
- const signature = new MethodSignature(converter.convertType(node.returnType), node.parameters.map(it => it.type), undefined, node.parameters.map(it => it.isOptional ? ArgumentModifier.OPTIONAL : undefined), undefined, node.parameters.map(it => mangleIfKeyword(it.name)));
11803
- if (!isCreateOrUpdate(node.name)) {
12861
+ const signature = makeSignature(node.parameters.map(p => ({
12862
+ name: mangleIfKeyword(p.name),
12863
+ type: p.type,
12864
+ isOptional: p.isOptional
12865
+ })), converter.convertType(node.returnType));
12866
+ if (!isCreateOrUpdate(node.name) && !isImplInterface(iface.name)) {
11804
12867
  signature.args.splice(1, 0, createReferenceType(iface.name));
11805
12868
  signature.argNames.splice(1, 0, 'receiver');
11806
12869
  }
11807
12870
  const fixArgName = (name, prev) => name.endsWith('Len') ? (prev !== null && prev !== void 0 ? prev : name.slice(0, -3)) + 'SequenceLength' : name === 'ctx' ? 'context' : name;
11808
12871
  // Not necessary, just to keep old names
11809
12872
  signature.argNames = (_a = signature.argNames) === null || _a === void 0 ? void 0 : _a.map((v, i) => fixArgName(v, i === 0 ? undefined : signature.argNames[i - 1]));
11810
- return [InteropConstructions.method(iface.name, node.name), signature];
11811
- }
11812
- printBody(iface, node, signature) {
11813
- this.printParameters(signature);
11814
- this.printDeclarations(node);
11815
- this.printEs2pandaCall(iface, node, signature);
11816
- this.printReturn(node);
11817
- }
11818
- printParameters(signature) {
11819
- signature.args.forEach((type, index) => {
11820
- var _a, _b;
11821
- const name = (_b = (_a = signature.argNames) === null || _a === void 0 ? void 0 : _a.at(index)) !== null && _b !== void 0 ? _b : `arg${index}`;
11822
- this.writer.writeStatement(this.writer.makeAssign(BridgesConstructions.castedParameter(name), undefined, this.writer.makeFunctionCall(this.castTypeConvertor.convertType(type), [this.writer.makeString(name)])));
11823
- });
12873
+ const methodName = isImplInterface(iface.name) ? node.name : InteropConstructions.method(iface.name, node.name);
12874
+ return [methodName, signature];
11824
12875
  }
11825
- printDeclarations(node) {
12876
+ printBody(node, signature, pandaMethodName) {
12877
+ const writer = this.writer;
12878
+ const argNames = signature.argNames.map(BridgesConstructions.castedParameter);
12879
+ const statements = signature.args.map((type, index) => this.writer.makeAssign(BridgesConstructions.castedParameter(signature.argName(index)), undefined, writer.makeFunctionCall(this.castTypeConvertor.convertType(type), [writer.makeString(signature.argName(index))])));
11826
12880
  if (isSequence(node.returnType)) {
11827
- this.writer.writeExpressionStatement(this.writer.makeString(BridgesConstructions.sequenceLengthDeclaration));
12881
+ argNames.push(BridgesConstructions.sequenceLengthPass);
12882
+ statements.push(makeStatement(writer, BridgesConstructions.sequenceLengthDeclaration));
11828
12883
  }
11829
- }
11830
- printEs2pandaCall(iface, node, signature) {
12884
+ const nativeCall = writer.makeFunctionCall(pandaMethodName, argNames.map(a => writer.makeString(a)));
12885
+ writer.writeStatements(...statements);
11831
12886
  if (isVoidType(node.returnType)) {
11832
- this.writer.writeExpressionStatement(this.makeEs2pandaMethodCall(iface, node, signature));
11833
- return;
12887
+ writer.writeStatements(writer.makeStatement(nativeCall), writer.makeReturn(writer.makeString('')));
11834
12888
  }
11835
- this.writer.writeExpressionStatement(this.writer.makeString(BridgesConstructions.resultAssignment(this.makeEs2pandaMethodCall(iface, node, signature).asString())));
11836
- }
11837
- makeEs2pandaMethodCall(iface, node, signature) {
11838
- let suffix = this.config.irHack.isIrHackInterface(iface.name) ? 'Ir' : '';
11839
- let method = BridgesConstructions.callMethod(InteropConstructions.method(iface.name, node.name));
11840
- method = method.replace(iface.name, iface.name + suffix);
11841
- return this.writer.makeFunctionCall(method, signature.argNames
11842
- .map(it => ({
11843
- asString: () => BridgesConstructions.castedParameter(it),
11844
- }))
11845
- .concat(isSequence(node.returnType) // XXX: original return type
11846
- ? this.writer.makeString(BridgesConstructions.sequenceLengthPass)
11847
- : []));
11848
- }
11849
- printReturn(node) {
11850
- if (isVoidType(node.returnType)) {
11851
- this.writer.writeStatement(this.writer.makeReturn(this.writer.makeString(``)));
11852
- return;
12889
+ else {
12890
+ writer.writeStatements(writer.makeAssign(BridgesConstructions.result, undefined, nativeCall, true, false), writer.makeReturn(writer.makeString(this.maybeDropConst(this.makeReturnExpression(node.returnType), node))));
11853
12891
  }
11854
- this.writer.writeStatement(this.writer.makeReturn(this.writer.makeString(this.maybeDropConst(this.makeReturnExpression(node.returnType), node))));
11855
12892
  }
11856
12893
  makeReturnExpression(returnType) {
11857
12894
  if (isSequence(returnType)) {
@@ -11948,10 +12985,10 @@ class IndexPrinter extends SingleFilePrinter {
11948
12985
  this.writer = createDefaultTypescriptWriter();
11949
12986
  }
11950
12987
  filterInterface(node) {
11951
- return !this.typechecker.isPeer(node.name);
12988
+ return !this.typechecker.isPeer(node) || Config.DoNotPrintPeers.includes(fqName(node));
11952
12989
  }
11953
12990
  printInterface(node) {
11954
- this.writer.writeExpressionStatement(this.writer.makeString(`export * from "./peers/${node.name}"`));
12991
+ this.writer.writeExpressionStatement(this.writer.makeString(`export * from "./peers/${dropPrefix(node.name, Config.dataClassPrefix)}"`));
11955
12992
  }
11956
12993
  }
11957
12994
 
@@ -12091,7 +13128,7 @@ class MultiFilePrinter extends AbstractVisitor {
12091
13128
  constructor(idl) {
12092
13129
  super();
12093
13130
  this.idl = idl;
12094
- this.typechecker = new Typechecker(this.idl.entries);
13131
+ this.typechecker = new Typechecker(this.idl);
12095
13132
  this.output = [];
12096
13133
  }
12097
13134
  visit(node) {
@@ -12121,15 +13158,15 @@ class MultiFilePrinter extends AbstractVisitor {
12121
13158
  * limitations under the License.
12122
13159
  */
12123
13160
  class PeersConstructions {
13161
+ static peerName(name) {
13162
+ return dropPrefix(name, Config.dataClassPrefix);
13163
+ }
12124
13164
  static fileName(node) {
12125
- return `${node}.ts`;
13165
+ return `${this.peerName(node)}.ts`;
12126
13166
  }
12127
13167
  static get pointerParameter() {
12128
13168
  return `pointer`;
12129
13169
  }
12130
- static get validatePeer() {
12131
- return `assertValidPeer`;
12132
- }
12133
13170
  static get super() {
12134
13171
  return `super`;
12135
13172
  }
@@ -12148,8 +13185,8 @@ class PeersConstructions {
12148
13185
  name: parameter,
12149
13186
  type: `object | undefined`
12150
13187
  },
12151
- returnType: (type) => `${parameter} is ${type}`,
12152
- body: (type) => `${parameter} instanceof ${type}`
13188
+ returnType: (type) => `${parameter} is ${PeersConstructions.peerName(type)}`,
13189
+ body: (type) => `${parameter} instanceof ${PeersConstructions.peerName(type)}`
12153
13190
  };
12154
13191
  }
12155
13192
  static get unpackNullable() {
@@ -12204,13 +13241,13 @@ class PeersConstructions {
12204
13241
  return `setChildrenParentPtr`;
12205
13242
  }
12206
13243
  static newOf(iface) {
12207
- return `new ${iface}`;
13244
+ return `new ${this.peerName(iface)}`;
12208
13245
  }
12209
13246
  static callPeerMethod(iface, method) {
12210
13247
  return `${iface}.${method}`;
12211
13248
  }
12212
13249
  static brand(iface) {
12213
- return `brand${capitalize(iface)}`;
13250
+ return `brand${capitalize(this.peerName(iface))}`;
12214
13251
  }
12215
13252
  }
12216
13253
 
@@ -12245,9 +13282,8 @@ class Importer {
12245
13282
  if (this.seen.has(it)) {
12246
13283
  return it;
12247
13284
  }
12248
- if (!this.typechecker.isPeer(it)) {
12249
- return it;
12250
- }
13285
+ // the 'it' parameter can be a modified peer name
13286
+ // and therefor cannot be resolved here
12251
13287
  this.seen.add(it);
12252
13288
  this.import(it, it);
12253
13289
  return it;
@@ -12355,34 +13391,24 @@ class LibraryTypeConvertor extends TopLevelTypeConvertor {
12355
13391
  * See the License for the specific language governing permissions and
12356
13392
  * limitations under the License.
12357
13393
  */
12358
- class ImporterTypeConvertor extends TopLevelTypeConvertor {
12359
- constructor(importer, typechecker) {
12360
- super(typechecker, {
12361
- optional: (type) => {
12362
- this.convertType(type.type);
12363
- return type;
12364
- },
12365
- sequence: (type) => {
12366
- this.convertType(type.elementType[0]);
12367
- return type;
12368
- },
12369
- enum: (type) => {
12370
- this.importer.withEnumImport(type.name);
12371
- return type;
12372
- },
12373
- reference: (type) => {
12374
- this.importer.withPeerImport(baseName(type));
12375
- return type;
12376
- },
12377
- string: (type) => type,
12378
- number: (type) => type,
12379
- boolean: (type) => type,
12380
- void: (type) => type,
12381
- pointer: (type) => type,
12382
- undefined: (type) => type
12383
- });
12384
- this.importer = importer;
13394
+ function convertAndImport(importer, converter, type) {
13395
+ const result = converter.convertType(type);
13396
+ if (isOptionalType(type)) {
13397
+ convertAndImport(importer, converter, type.type);
12385
13398
  }
13399
+ else if (isContainerType(type) && IDLContainerUtils.isSequence(type)) {
13400
+ convertAndImport(importer, converter, type.elementType[0]);
13401
+ }
13402
+ else if (isReferenceType(type)) {
13403
+ const node = converter.typechecker.resolveReference(type);
13404
+ if (node && isEnum$1(node)) {
13405
+ importer.withEnumImport(result);
13406
+ }
13407
+ else if (node && isInterface$1(node) && converter.typechecker.isPeer(node)) {
13408
+ importer.withPeerImport(result);
13409
+ }
13410
+ }
13411
+ return result;
12386
13412
  }
12387
13413
 
12388
13414
  /*
@@ -12445,12 +13471,12 @@ class BindingReturnValueTypeConvertor extends TopLevelTypeConvertor {
12445
13471
  super(typechecker, {
12446
13472
  sequence: (type) => wrap(PeersConstructions.arrayOfPointersToArrayOfPeers),
12447
13473
  string: (type) => wrap(PeersConstructions.receiveString),
12448
- reference: (type) => this.typechecker.isHeir(type.name, Config.astNodeCommonAncestor)
13474
+ reference: (type) => this.typechecker.isHeir(type, Config.astNodeCommonAncestor)
12449
13475
  ? wrap(PeersConstructions.unpackNonNullable)
12450
13476
  : wrap(baseNameString(type.name)),
12451
13477
  optional: (type) => {
12452
13478
  if (isReferenceType(type.type)) {
12453
- if (this.typechecker.isHeir(type.type.name, Config.astNodeCommonAncestor)) {
13479
+ if (this.typechecker.isHeir(type.type, Config.astNodeCommonAncestor)) {
12454
13480
  return wrap(PeersConstructions.unpackNullable);
12455
13481
  }
12456
13482
  return wrap(PeersConstructions.newOf(baseNameString(type.type.name)));
@@ -12501,16 +13527,20 @@ class PeerPrinter extends SingleFilePrinter {
12501
13527
  super(idl);
12502
13528
  this.config = config;
12503
13529
  this.node = node;
12504
- this.typechecker = new Typechecker(this.idl.entries);
13530
+ this.typechecker = new Typechecker(this.idl);
12505
13531
  this.importer = new Importer(this.typechecker, `.`, this.node.name);
12506
13532
  this.bindingParameterTypeConvertor = new BindingParameterTypeConvertor(this.typechecker);
12507
13533
  this.bindingReturnValueTypeConvertor = new BindingReturnValueTypeConvertor(this.typechecker);
12508
13534
  this.parent = (_a = parent(this.node)) !== null && _a !== void 0 ? _a : Config.defaultAncestor;
12509
- this.writer = new TSLanguageWriter(new IndentedPrinter(), createEmptyReferenceResolver(), { convert: (node) => composedConvertType(new LibraryTypeConvertor(this.typechecker), new ImporterTypeConvertor(this.importer, this.typechecker), node)
12510
- });
13535
+ this.writer = new TSLanguageWriter(new IndentedPrinter(), createEmptyReferenceResolver(), { convert: (node) => convertAndImport(this.importer, new class extends LibraryTypeConvertor {
13536
+ convertTypeReference(type) {
13537
+ return dropPrefix(super.convertTypeReference(type), Config.dataClassPrefix);
13538
+ }
13539
+ }(this.typechecker), node) });
12511
13540
  }
12512
13541
  printPeer() {
12513
- this.writer.writeClass(this.node.name, () => this.printBody(), this.parent ? this.importer.withPeerImport(baseNameString(this.parent)) : undefined);
13542
+ this.writer.writeClass(PeersConstructions.peerName(this.node.name), // XXX: Change peer name
13543
+ () => this.printBody(), this.parent ? this.importer.withPeerImport(baseNameString(this.parent)) : undefined);
12514
13544
  }
12515
13545
  printBody() {
12516
13546
  this.printConstructor();
@@ -12519,21 +13549,16 @@ class PeerPrinter extends SingleFilePrinter {
12519
13549
  this.printBrand();
12520
13550
  }
12521
13551
  printConstructor() {
12522
- this.writer.writeConstructorImplementation(this.node.name, new MethodSignature(IDLVoidType, [
12523
- IDLPointerType
12524
- ], undefined, undefined, undefined, [
12525
- PeersConstructions.pointerParameter
12526
- ]), () => {
12527
- var _a;
12528
- if (isReal(this.node)) {
12529
- this.writer.writeExpressionStatement(this.writer.makeFunctionCall(PeersConstructions.validatePeer, [
12530
- this.writer.makeString(PeersConstructions.pointerParameter),
12531
- this.writer.makeString((_a = nodeType(this.node)) !== null && _a !== void 0 ? _a : throwException(`missing attribute node type: ${this.node.name}`)),
12532
- ]));
12533
- }
12534
- this.writer.writeExpressionStatements(this.writer.makeFunctionCall(PeersConstructions.super, [
12535
- this.writer.makeString(PeersConstructions.pointerParameter)
12536
- ]));
13552
+ isReal(this.node);
13553
+ const isAstNodeDescendant = this.typechecker.isHeir(this.node, Config.astNodeCommonAncestor);
13554
+ const args = [IDLPointerType];
13555
+ const argNames = [PeersConstructions.pointerParameter];
13556
+ if (isAstNodeDescendant) {
13557
+ args.push(createReferenceType(Config.nodeTypeAttribute));
13558
+ argNames.push('astNodeType');
13559
+ }
13560
+ this.writer.writeConstructorImplementation(this.node.name, new MethodSignature(IDLVoidType, args, undefined, undefined, undefined, argNames), () => {
13561
+ this.writer.writeExpressionStatements(this.writer.makeFunctionCall(PeersConstructions.super, argNames.map(n => this.writer.makeString(n))));
12537
13562
  });
12538
13563
  }
12539
13564
  printTypeGuard() {
@@ -12546,7 +13571,10 @@ class PeerPrinter extends SingleFilePrinter {
12546
13571
  if (isCreateOrUpdate(it.name)) {
12547
13572
  // TODO: This condition is not clear - classes with c_type attribute
12548
13573
  // is not abstract too, is it?
13574
+ // The check for a native type allows types that is descendants of
13575
+ // AstNode but have not type attribute, for example, varbinder.FunctionDecl
12549
13576
  if (isAbstract(this.node) && nativeType(this.node) === undefined) {
13577
+ console.log(`Skipped ${this.node.name}.${it.name}`);
12550
13578
  return;
12551
13579
  }
12552
13580
  return this.printCreateOrUpdate(it);
@@ -12651,18 +13679,19 @@ class PeerPrinter extends SingleFilePrinter {
12651
13679
  this.writer.writeMethodImplementation(makeMethod(PeersConstructions.createOrUpdate(this.node.name, node.name), node.parameters
12652
13680
  .map(it => createParameter(it.name, flattenType(it.type)))
12653
13681
  .concat(extraParameters), flattenType(node.returnType), [MethodModifier.STATIC]), (writer) => {
12654
- const newExpr = this.writer.makeNewObject(this.node.name, [
12655
- this.writer.makeFunctionCall(this.writer.makeString(PeersConstructions.callBinding(this.node.name, node.name, nodeNamespace(this.node))), this.makeBindingArguments(node.parameters)),
12656
- ]);
13682
+ var _a;
13683
+ const nativeCall = this.writer.makeFunctionCall(this.writer.makeString(PeersConstructions.callBinding(this.node.name, node.name, nodeNamespace(this.node))), this.makeBindingArguments(node.parameters));
12657
13684
  const varName = 'result';
12658
13685
  const makeStmt = (property) => PeerPrinter.makeExtraStatement(property, PeerPrinter.resolveProperty(property, this.node, this.idl), ['should_not_be_here', varName], this.writer);
12659
13686
  const extraStatements = this.config.parameters.getParameters(this.node.name)
12660
13687
  .map(makeStmt);
12661
13688
  if (isReal(this.node)) {
13689
+ const astNodeType = (_a = this.typechecker.nodeTypeName(this.node)) !== null && _a !== void 0 ? _a : throwException(`missing attribute node type: ${this.node.name}`);
13690
+ const newExpr = writer.makeNewObject(this.node.name, [nativeCall, writer.makeString(astNodeType)]);
12662
13691
  this.writer.writeStatements(this.writer.makeAssign(varName, createReferenceType(this.node.name), newExpr, true), ...extraStatements, this.writer.makeStatement(this.writer.makeMethodCall(varName, PeersConstructions.setChildrenParentPtrMethod, [])), this.writer.makeReturn(this.writer.makeString(varName)));
12663
13692
  }
12664
13693
  else {
12665
- this.writer.writeStatement(this.writer.makeReturn(newExpr));
13694
+ writer.writeStatement(writer.makeReturn(writer.makeNewObject(this.node.name, [nativeCall])));
12666
13695
  }
12667
13696
  });
12668
13697
  }
@@ -12680,8 +13709,8 @@ class PeerPrinter extends SingleFilePrinter {
12680
13709
  if (enumValue === undefined) {
12681
13710
  return;
12682
13711
  }
12683
- const qualified = `${this.importer.withEnumImport(Config.nodeTypeAttribute)}.${enumValue}`;
12684
- this.writer.writeExpressionStatements(this.writer.makeString(`if (!nodeByType.has(${qualified})) {`), this.writer.makeString(` nodeByType.set(${qualified}, (peer: KNativePointer) => new ${this.node.name}(peer))`), this.writer.makeString(`}`));
13712
+ this.importer.withEnumImport(Config.nodeTypeAttribute);
13713
+ this.writer.writeExpressionStatements(this.writer.makeString(`if (!nodeByType.has(${enumValue})) {`), this.writer.makeString(` nodeByType.set(${enumValue}, (peer: KNativePointer) => new ${this.node.name}(peer, ${enumValue}))`), this.writer.makeString(`}`));
12685
13714
  }
12686
13715
  printBrand() {
12687
13716
  this.writer.writeProperty(PeersConstructions.brand(this.node.name), IDLUndefinedType, [FieldModifier.PROTECTED, FieldModifier.READONLY]);
@@ -12708,7 +13737,7 @@ class AllPeersPrinter extends MultiFilePrinter {
12708
13737
  this.config = config;
12709
13738
  }
12710
13739
  filterInterface(node) {
12711
- return !this.typechecker.isPeer(node.name);
13740
+ return !this.typechecker.isPeer(node) || Config.DoNotPrintPeers.includes(fqName(node));
12712
13741
  }
12713
13742
  printInterface(node) {
12714
13743
  return {
@@ -12772,8 +13801,7 @@ class FactoryPrinter extends SingleFilePrinter {
12772
13801
  super(idl);
12773
13802
  this.config = config;
12774
13803
  this.importer = new Importer(this.typechecker, `peers`);
12775
- this.writer = new TSLanguageWriter(new IndentedPrinter(), createEmptyReferenceResolver(), { convert: (node) => composedConvertType(new LibraryTypeConvertor(this.typechecker), new ImporterTypeConvertor(this.importer, this.typechecker), node)
12776
- });
13804
+ this.writer = new TSLanguageWriter(new IndentedPrinter(), createEmptyReferenceResolver(), { convert: (node) => convertAndImport(this.importer, new LibraryTypeConvertor(this.typechecker), node) });
12777
13805
  }
12778
13806
  prologue() {
12779
13807
  this.writer.writeExpressionStatements(this.writer.makeString(FactoryConstructions.prologue));
@@ -12784,7 +13812,7 @@ class FactoryPrinter extends SingleFilePrinter {
12784
13812
  this.writer.writeExpressionStatements(this.writer.makeString(FactoryConstructions.epilogue));
12785
13813
  }
12786
13814
  filterInterface(node) {
12787
- return !this.typechecker.isPeer(node.name) || FactoryPrinter.getUniversalCreate(node) == undefined;
13815
+ return !this.typechecker.isPeer(node) || FactoryPrinter.getUniversalCreate(node) == undefined;
12788
13816
  }
12789
13817
  printInterface(node) {
12790
13818
  this.printCreate(node);
@@ -12915,7 +13943,7 @@ class Transformer {
12915
13943
  class BaseInterfaceFilterTransformer extends Transformer {
12916
13944
  constructor(file, removeNamespaces = false) {
12917
13945
  super(file, removeNamespaces);
12918
- this.typechecker = new Typechecker(this.file.entries);
13946
+ this.typechecker = new Typechecker(this.file);
12919
13947
  }
12920
13948
  transformInterface(entry) {
12921
13949
  if (this.shouldFilterOutInterface(entry)) {
@@ -12933,7 +13961,7 @@ class BaseInterfaceFilterTransformer extends Transformer {
12933
13961
  .map(innerTypeIfContainer)
12934
13962
  .filter(it => {
12935
13963
  if (isReferenceType(it)) {
12936
- const decl = this.typechecker.findRealDeclaration(it.name);
13964
+ const decl = this.typechecker.resolveReference(it);
12937
13965
  if (!decl || isInterface$1(decl) && predicate(decl)) {
12938
13966
  return true;
12939
13967
  }
@@ -12975,77 +14003,6 @@ class OptionsFilterTransformer extends BaseInterfaceFilterTransformer {
12975
14003
  }
12976
14004
  }
12977
14005
 
12978
- /*
12979
- * Copyright (c) 2024 Huawei Device Co., Ltd.
12980
- * Licensed under the Apache License, Version 2.0 (the "License");
12981
- * you may not use this file except in compliance with the License.
12982
- * You may obtain a copy of the License at
12983
- *
12984
- * http://www.apache.org/licenses/LICENSE-2.0
12985
- *
12986
- * Unless required by applicable law or agreed to in writing, software
12987
- * distributed under the License is distributed on an "AS IS" BASIS,
12988
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12989
- * See the License for the specific language governing permissions and
12990
- * limitations under the License.
12991
- */
12992
- class AddContextDeclarationTransformer extends Transformer {
12993
- constructor(file) {
12994
- super(file);
12995
- }
12996
- transformInterface(entry) {
12997
- return entry;
12998
- }
12999
- transformed() {
13000
- let file = createFile(this.file.entries
13001
- .concat(createInterface(Config.context, IDLInterfaceSubkind.Class, undefined, undefined, undefined, undefined, undefined, undefined, undefined, {
13002
- extendedAttributes: [{
13003
- name: Config.nodeNamespaceAttribute,
13004
- value: Config.irNamespace
13005
- }]
13006
- })), this.file.fileName, this.file.packageClause);
13007
- return linkParentBack(file);
13008
- }
13009
- }
13010
-
13011
- /*
13012
- * Copyright (c) 2024 Huawei Device Co., Ltd.
13013
- * Licensed under the Apache License, Version 2.0 (the "License");
13014
- * you may not use this file except in compliance with the License.
13015
- * You may obtain a copy of the License at
13016
- *
13017
- * http://www.apache.org/licenses/LICENSE-2.0
13018
- *
13019
- * Unless required by applicable law or agreed to in writing, software
13020
- * distributed under the License is distributed on an "AS IS" BASIS,
13021
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13022
- * See the License for the specific language governing permissions and
13023
- * limitations under the License.
13024
- */
13025
- class MultipleDeclarationFilterTransformer extends Transformer {
13026
- constructor(file) {
13027
- super(file);
13028
- this.seen = new Map();
13029
- // TODO: namespaces
13030
- linearizeNamespaceMembers(this.file.entries).forEach(it => {
13031
- var _a;
13032
- let name = baseNameString(it.name);
13033
- const oldValue = (_a = this.seen.get(name)) !== null && _a !== void 0 ? _a : 0;
13034
- this.seen.set(name, oldValue + 1);
13035
- });
13036
- }
13037
- transformInterface(entry) {
13038
- var _a;
13039
- const occurence = (_a = this.seen.get(baseNameString(entry.name))) !== null && _a !== void 0 ? _a : 0;
13040
- if (occurence > 1 && !isIrNamespace(entry)) {
13041
- console.log(`FILTERED (MULTIPLE) ${entry.name}`);
13042
- this.seen.set(baseNameString(entry.name), occurence - 1);
13043
- return undefined;
13044
- }
13045
- return entry;
13046
- }
13047
- }
13048
-
13049
14006
  /*
13050
14007
  * Copyright (c) 2024 Huawei Device Co., Ltd.
13051
14008
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -13087,120 +14044,6 @@ class ParameterTransformer extends Transformer {
13087
14044
  }
13088
14045
  }
13089
14046
 
13090
- /*
13091
- * Copyright (c) 2024 Huawei Device Co., Ltd.
13092
- * Licensed under the Apache License, Version 2.0 (the "License");
13093
- * you may not use this file except in compliance with the License.
13094
- * You may obtain a copy of the License at
13095
- *
13096
- * http://www.apache.org/licenses/LICENSE-2.0
13097
- *
13098
- * Unless required by applicable law or agreed to in writing, software
13099
- * distributed under the License is distributed on an "AS IS" BASIS,
13100
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13101
- * See the License for the specific language governing permissions and
13102
- * limitations under the License.
13103
- */
13104
- class TwinMergeTransformer extends Transformer {
13105
- constructor(file) {
13106
- super(file);
13107
- const all = linearizeNamespaceMembers(file.entries).filter(isInterface$1);
13108
- this.twins = new Set();
13109
- all
13110
- .filter(it => this.hasPrefix(it.name))
13111
- .forEach(it => {
13112
- const twin = all.find(candidate => this.withPrefix(baseNameString(candidate.name)) === it.name);
13113
- if (twin === undefined)
13114
- return;
13115
- if (!isIrNamespace(twin))
13116
- return;
13117
- this.twins.add(twin.name);
13118
- });
13119
- }
13120
- hasTwin(name) {
13121
- name = baseNameString(name);
13122
- if (this.hasPrefix(name)) {
13123
- return this.twins.has(this.withoutPrefix(name));
13124
- }
13125
- return this.twins.has(name);
13126
- }
13127
- transformInterface(node) {
13128
- if (node.name === Config.astNodeCommonAncestor) { // TODO: is handwritten
13129
- return createUpdatedInterface(node, node.methods.map(it => this.transformMethod(it)));
13130
- }
13131
- if (this.hasTwin(node.name) && this.hasPrefix(node.name)) {
13132
- return undefined;
13133
- }
13134
- if (this.hasTwin(node.name) || this.hasPrefix(node.name)) {
13135
- return createUpdatedInterface(node, node.methods.map(it => this.transformMethod(it)), this.withoutPrefix(node.name), [createReferenceType(Config.defaultAncestor)]);
13136
- }
13137
- return createUpdatedInterface(node, node.methods.map(it => this.transformMethod(it)));
13138
- }
13139
- transformMethod(node) {
13140
- return createUpdatedMethod(node, this.withoutPrefix(node.name), node.parameters.map(it => this.transformParameter(it)), this.transformType(node.returnType));
13141
- }
13142
- transformParameter(node) {
13143
- return createParameter(this.withoutPrefix(node.name), this.transformType(node.type), node.isOptional, node.isVariadic);
13144
- }
13145
- transformType(node) {
13146
- if (isContainerType(node)) {
13147
- if (isSequence(node)) {
13148
- return createSequence(this.transformType(innerType(node)));
13149
- }
13150
- }
13151
- if (isReferenceType(node)) {
13152
- return createReferenceType(this.withoutPrefix(node.name), node.typeArguments);
13153
- }
13154
- return node;
13155
- }
13156
- withoutPrefix(name) {
13157
- if (name.startsWith(Config.dataClassPrefix)) {
13158
- return name.slice(Config.dataClassPrefix.length);
13159
- }
13160
- return name;
13161
- }
13162
- withPrefix(name) {
13163
- return `${Config.dataClassPrefix}${name}`;
13164
- }
13165
- hasPrefix(name) {
13166
- return name.startsWith(Config.dataClassPrefix);
13167
- }
13168
- }
13169
-
13170
- /*
13171
- * Copyright (c) 2024 Huawei Device Co., Ltd.
13172
- * Licensed under the Apache License, Version 2.0 (the "License");
13173
- * you may not use this file except in compliance with the License.
13174
- * You may obtain a copy of the License at
13175
- *
13176
- * http://www.apache.org/licenses/LICENSE-2.0
13177
- *
13178
- * Unless required by applicable law or agreed to in writing, software
13179
- * distributed under the License is distributed on an "AS IS" BASIS,
13180
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13181
- * See the License for the specific language governing permissions and
13182
- * limitations under the License.
13183
- */
13184
- class AstNodeFilterTransformer extends BaseInterfaceFilterTransformer {
13185
- constructor(idl) {
13186
- super(idl, true);
13187
- }
13188
- shouldFilterOutInterface(node) {
13189
- if (this.typechecker.isHeir(node.name, Config.astNodeCommonAncestor))
13190
- return false;
13191
- if (this.typechecker.isHeir(node.name, Config.defaultAncestor))
13192
- return false;
13193
- console.log(`FILTERED (AST) ${node.name}`);
13194
- return true;
13195
- }
13196
- shouldFilterOutMethod(node, name) {
13197
- return false;
13198
- }
13199
- shouldFilterOutProperty(node, name) {
13200
- return false;
13201
- }
13202
- }
13203
-
13204
14047
  /*
13205
14048
  * Copyright (c) 2024 Huawei Device Co., Ltd.
13206
14049
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -13219,7 +14062,7 @@ class NullabilityTransformer extends Transformer {
13219
14062
  constructor(file, config) {
13220
14063
  super(file);
13221
14064
  this.config = config;
13222
- this.typechecker = new Typechecker(this.file.entries);
14065
+ this.typechecker = new Typechecker(this.file);
13223
14066
  }
13224
14067
  transformInterface(node) {
13225
14068
  return createUpdatedInterface(node, node.methods
@@ -13243,7 +14086,7 @@ class NullabilityTransformer extends Transformer {
13243
14086
  // TODO: maybe heirs of defaultAncestors aren't nullable
13244
14087
  // TODO: handwritten
13245
14088
  if (isReferenceType(type)) {
13246
- if (this.typechecker.isPeer(type.name) || type.name === Config.astNodeCommonAncestor) {
14089
+ if (this.typechecker.isPeer(type) || type.name === Config.astNodeCommonAncestor) {
13247
14090
  return createOptionalType(type);
13248
14091
  }
13249
14092
  }
@@ -13286,7 +14129,7 @@ function remove(array, value) {
13286
14129
  class AttributeTransformer extends Transformer {
13287
14130
  constructor(file) {
13288
14131
  super(file);
13289
- this.convertor = new LibraryTypeConvertor(new Typechecker(this.file.entries));
14132
+ this.convertor = new LibraryTypeConvertor(new Typechecker(this.file));
13290
14133
  }
13291
14134
  convertToKey(type) {
13292
14135
  if (isOptionalType(type)) {
@@ -13482,10 +14325,10 @@ class DynamicEmitter {
13482
14325
  let idl = this.file;
13483
14326
  this.printFile(this.enumsPrinter, idl);
13484
14327
  idl = this.withLog(new OptionsFilterTransformer(this.config, idl));
13485
- idl = this.withLog(new AddContextDeclarationTransformer(idl));
13486
- idl = this.withLog(new TwinMergeTransformer(idl));
13487
- idl = this.withLog(new MultipleDeclarationFilterTransformer(idl));
13488
- idl = this.withLog(new AstNodeFilterTransformer(idl));
14328
+ //idl = this.withLog(new AddContextDeclarationTransformer(idl))
14329
+ //idl = this.withLog(new TwinMergeTransformer(idl))
14330
+ //idl = this.withLog(new MultipleDeclarationFilterTransformer(idl))
14331
+ //idl = this.withLog(new AstNodeFilterTransformer(idl))
13489
14332
  this.printPeers(idl);
13490
14333
  this.printInterop(idl);
13491
14334
  }
@@ -13583,8 +14426,8 @@ class IgnoreOptions {
13583
14426
  this.ignored.set(ns, new Map());
13584
14427
  }
13585
14428
  const last = name.at(-1);
13586
- const key = last === '-' || last === '+' ? name.slice(0, -1) : name;
13587
- this.ignored.get(ns).set(key, last !== '+');
14429
+ const key = last === '!' ? name.slice(0, -last.length) : name;
14430
+ this.ignored.get(ns).set(key, last !== '!');
13588
14431
  });
13589
14432
  }
13590
14433
  isIgnoredMethod(iface, method) {
@@ -13595,9 +14438,13 @@ class IgnoreOptions {
13595
14438
  var _a;
13596
14439
  return (_a = this.partial) === null || _a === void 0 ? void 0 : _a.some(it => { var _a; return it.interface === iface && ((_a = it.properties) === null || _a === void 0 ? void 0 : _a.includes(name)); });
13597
14440
  }
13598
- isIgnoredInterface(name, ns = '') {
14441
+ isIgnoredInterface(name, namespace = '') {
13599
14442
  var _a, _b;
13600
- return (_b = (_a = this.ignored.get(ns)) === null || _a === void 0 ? void 0 : _a.get(name)) !== null && _b !== void 0 ? _b : false;
14443
+ const ns = this.ignored.get(namespace);
14444
+ if (ns && ((_b = (_a = ns.get(name)) !== null && _a !== void 0 ? _a : ns.get('*')) !== null && _b !== void 0 ? _b : false)) {
14445
+ return true;
14446
+ }
14447
+ return false;
13601
14448
  }
13602
14449
  }
13603
14450
  // TODO: remove when interfaces fixed!