@idlizer/arktscgen 2.1.7 → 2.1.9-arktscgen-4

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 (354) hide show
  1. package/build/libarkts-copy/generator/options.json5 +34 -0
  2. package/build/libarkts-copy/native/meson.build +128 -75
  3. package/build/libarkts-copy/native/meson_options.txt +6 -0
  4. package/build/libarkts-copy/native/src/bridges.cc +271 -8
  5. package/build/libarkts-copy/native/src/common.cc +166 -45
  6. package/build/libarkts-copy/native/src/common.h +53 -8
  7. package/build/libarkts-copy/native/src/generated/bridges.cc +2654 -319
  8. package/build/libarkts-copy/package.json +31 -17
  9. package/build/libarkts-copy/src/Es2pandaNativeModule.ts +97 -3
  10. package/build/libarkts-copy/src/arkts-api/AbstractVisitor.ts +1 -1
  11. package/build/libarkts-copy/src/arkts-api/ChainExpressionFilter.ts +78 -0
  12. package/build/libarkts-copy/src/arkts-api/CheckedBackFilter.ts +86 -8
  13. package/build/libarkts-copy/src/arkts-api/CompileWithCache.ts +193 -0
  14. package/build/libarkts-copy/src/arkts-api/ImportStorage.ts +78 -0
  15. package/build/libarkts-copy/src/arkts-api/InferVoidReturnType.ts +89 -0
  16. package/build/libarkts-copy/src/arkts-api/ProgramProvider.ts +50 -0
  17. package/build/libarkts-copy/src/arkts-api/SetBaseOverloads.ts +10 -17
  18. package/build/libarkts-copy/src/arkts-api/class-by-peer.ts +2 -3
  19. package/build/libarkts-copy/src/arkts-api/factory/nodeFactory.ts +89 -6
  20. package/build/libarkts-copy/src/arkts-api/index.ts +10 -1
  21. package/build/libarkts-copy/src/arkts-api/node-cache.ts +8 -4
  22. package/build/libarkts-copy/src/arkts-api/node-utilities/AnnotationDeclaration.ts +32 -0
  23. package/build/libarkts-copy/src/arkts-api/node-utilities/AnnotationUsage.ts +37 -0
  24. package/build/libarkts-copy/src/arkts-api/node-utilities/ArkTsConfig.ts +26 -0
  25. package/build/libarkts-copy/src/arkts-api/node-utilities/ArrayExpression.ts +1 -1
  26. package/build/libarkts-copy/src/arkts-api/node-utilities/BinaryExpression.ts +37 -0
  27. package/build/libarkts-copy/src/arkts-api/node-utilities/BlockExpression.ts +27 -0
  28. package/build/libarkts-copy/src/arkts-api/node-utilities/BlockStatement.ts +29 -0
  29. package/build/libarkts-copy/src/arkts-api/node-utilities/CallExpression.ts +2 -2
  30. package/build/libarkts-copy/src/arkts-api/node-utilities/ChainExpression.ts +27 -0
  31. package/build/libarkts-copy/src/arkts-api/node-utilities/ClassDeclaration.ts +54 -0
  32. package/build/libarkts-copy/src/arkts-api/node-utilities/ClassDefinition.ts +1 -1
  33. package/build/libarkts-copy/src/arkts-api/node-utilities/ClassProperty.ts +3 -3
  34. package/build/libarkts-copy/src/arkts-api/node-utilities/ConditionalExpression.ts +36 -0
  35. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSFunctionType.ts +2 -2
  36. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSImportDeclaration.ts +3 -33
  37. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSNewClassInstanceExpression.ts +34 -0
  38. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSParameterExpression.ts +3 -9
  39. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSPrimitiveType.ts +28 -0
  40. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSStructDeclaration.ts +1 -1
  41. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSTuple.ts +1 -1
  42. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSTypeReference.ts +27 -0
  43. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSTypeReferencePart.ts +36 -0
  44. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSUndefinedType.ts +24 -0
  45. package/build/libarkts-copy/src/arkts-api/node-utilities/ETSUnionType.ts +27 -0
  46. package/build/libarkts-copy/src/arkts-api/node-utilities/Identifier.ts +27 -0
  47. package/build/libarkts-copy/src/arkts-api/node-utilities/ImportSpecifier.ts +31 -0
  48. package/build/libarkts-copy/src/arkts-api/node-utilities/MemberExpression.ts +1 -1
  49. package/build/libarkts-copy/src/arkts-api/node-utilities/MethodDefinition.ts +2 -2
  50. package/build/libarkts-copy/src/arkts-api/node-utilities/NullLiteral.ts +24 -0
  51. package/build/libarkts-copy/src/arkts-api/node-utilities/NumberLiteral.ts +2 -2
  52. package/build/libarkts-copy/src/arkts-api/node-utilities/ObjectExpression.ts +1 -1
  53. package/build/libarkts-copy/src/arkts-api/node-utilities/Program.ts +40 -0
  54. package/build/libarkts-copy/src/arkts-api/node-utilities/ReturnStatement.ts +27 -0
  55. package/build/libarkts-copy/src/arkts-api/node-utilities/StringLiteral.ts +27 -0
  56. package/build/libarkts-copy/src/arkts-api/node-utilities/SuperExpression.ts +24 -0
  57. package/build/libarkts-copy/src/arkts-api/node-utilities/TSAsExpression.ts +36 -0
  58. package/build/libarkts-copy/src/arkts-api/node-utilities/TSClassImplements.ts +31 -0
  59. package/build/libarkts-copy/src/arkts-api/node-utilities/TSInterfaceBody.ts +28 -0
  60. package/build/libarkts-copy/src/arkts-api/node-utilities/TSInterfaceDeclaration.ts +2 -2
  61. package/build/libarkts-copy/src/arkts-api/node-utilities/TSNonNullExpression.ts +27 -0
  62. package/build/libarkts-copy/src/arkts-api/node-utilities/TSTypeParameter.ts +1 -1
  63. package/build/libarkts-copy/src/arkts-api/node-utilities/TSTypeParameterDeclaration.ts +31 -0
  64. package/build/libarkts-copy/src/arkts-api/node-utilities/TSTypeParameterInstantiation.ts +30 -0
  65. package/build/libarkts-copy/src/arkts-api/node-utilities/TSTypeReferencePart.ts +1 -1
  66. package/build/libarkts-copy/src/arkts-api/node-utilities/TemplateLiteral.ts +35 -0
  67. package/build/libarkts-copy/src/arkts-api/node-utilities/ThisExpression.ts +24 -0
  68. package/build/libarkts-copy/src/arkts-api/node-utilities/UndefinedLiteral.ts +24 -0
  69. package/build/libarkts-copy/src/arkts-api/node-utilities/VariableDeclaration.ts +1 -1
  70. package/build/libarkts-copy/src/arkts-api/node-utilities/VariableDeclarator.ts +1 -1
  71. package/build/libarkts-copy/src/arkts-api/peers/ArktsObject.ts +3 -1
  72. package/build/libarkts-copy/src/arkts-api/peers/AstNode.ts +75 -12
  73. package/build/libarkts-copy/src/arkts-api/peers/Config.ts +8 -1
  74. package/build/libarkts-copy/src/arkts-api/peers/Context.ts +71 -4
  75. package/build/libarkts-copy/src/arkts-api/peers/{Program.ts → ExternalSource.ts} +2 -22
  76. package/build/libarkts-copy/src/arkts-api/peers/Options.ts +34 -0
  77. package/build/libarkts-copy/src/arkts-api/plugins.ts +26 -12
  78. package/build/libarkts-copy/src/arkts-api/static/global.ts +7 -4
  79. package/build/libarkts-copy/src/arkts-api/static/profiler.ts +180 -23
  80. package/build/libarkts-copy/src/arkts-api/utilities/private.ts +32 -8
  81. package/build/libarkts-copy/src/arkts-api/utilities/public.ts +54 -12
  82. package/build/libarkts-copy/src/arkts-api/visitor.ts +32 -37
  83. package/build/libarkts-copy/src/arkts-api/wrapper-compat.ts +32 -0
  84. package/build/libarkts-copy/src/checkSdk.ts +25 -0
  85. package/build/libarkts-copy/src/generated/Es2pandaEnums.ts +448 -436
  86. package/build/libarkts-copy/src/generated/Es2pandaNativeModule.ts +778 -63
  87. package/build/libarkts-copy/src/generated/factory.ts +12 -15
  88. package/build/libarkts-copy/src/generated/index.ts +10 -3
  89. package/build/libarkts-copy/src/generated/peers/AnnotatedAstNode.ts +7 -1
  90. package/build/libarkts-copy/src/generated/peers/AnnotatedExpression.ts +7 -1
  91. package/build/libarkts-copy/src/generated/peers/AnnotatedStatement.ts +7 -1
  92. package/build/libarkts-copy/src/generated/peers/AnnotationDeclaration.ts +58 -6
  93. package/build/libarkts-copy/src/generated/peers/AnnotationUsage.ts +10 -4
  94. package/build/libarkts-copy/src/generated/peers/ArkTsConfig.ts +75 -0
  95. package/build/libarkts-copy/src/generated/peers/ArrayExpression.ts +11 -5
  96. package/build/libarkts-copy/src/generated/peers/ArrowFunctionExpression.ts +40 -6
  97. package/build/libarkts-copy/src/generated/peers/AssertStatement.ts +9 -3
  98. package/build/libarkts-copy/src/generated/peers/AssignmentExpression.ts +11 -5
  99. package/build/libarkts-copy/src/generated/peers/AstDumper.ts +7 -1
  100. package/build/libarkts-copy/src/generated/peers/AstVerifier.ts +7 -1
  101. package/build/libarkts-copy/src/generated/peers/AstVisitor.ts +7 -1
  102. package/build/libarkts-copy/src/generated/peers/AwaitExpression.ts +9 -3
  103. package/build/libarkts-copy/src/generated/peers/BigIntLiteral.ts +9 -3
  104. package/build/libarkts-copy/src/generated/peers/BinaryExpression.ts +9 -3
  105. package/build/libarkts-copy/src/generated/peers/BindingProps.ts +7 -1
  106. package/build/libarkts-copy/src/generated/peers/BlockExpression.ts +10 -4
  107. package/build/libarkts-copy/src/generated/peers/BlockStatement.ts +26 -7
  108. package/build/libarkts-copy/src/generated/peers/BooleanLiteral.ts +9 -3
  109. package/build/libarkts-copy/src/generated/peers/BreakStatement.ts +10 -4
  110. package/build/libarkts-copy/src/generated/peers/CallExpression.ts +20 -3
  111. package/build/libarkts-copy/src/generated/peers/CatchClause.ts +10 -4
  112. package/build/libarkts-copy/src/generated/peers/ChainExpression.ts +9 -3
  113. package/build/libarkts-copy/src/generated/peers/CharLiteral.ts +9 -3
  114. package/build/libarkts-copy/src/generated/peers/ClassDeclaration.ts +33 -4
  115. package/build/libarkts-copy/src/generated/peers/ClassDefinition.ts +128 -42
  116. package/build/libarkts-copy/src/generated/peers/ClassElement.ts +28 -4
  117. package/build/libarkts-copy/src/generated/peers/ClassExpression.ts +9 -3
  118. package/build/libarkts-copy/src/generated/peers/ClassProperty.ts +39 -5
  119. package/build/libarkts-copy/src/generated/peers/ClassStaticBlock.ts +9 -3
  120. package/build/libarkts-copy/src/generated/peers/CodeGen.ts +7 -1
  121. package/build/libarkts-copy/src/generated/peers/ConditionalExpression.ts +9 -3
  122. package/build/libarkts-copy/src/generated/peers/ContinueStatement.ts +10 -4
  123. package/build/libarkts-copy/src/generated/peers/DebuggerStatement.ts +9 -3
  124. package/build/libarkts-copy/src/generated/peers/Declaration.ts +7 -1
  125. package/build/libarkts-copy/src/generated/peers/Decorator.ts +9 -3
  126. package/build/libarkts-copy/src/generated/peers/{OverloadInfo.ts → DiagnosticInfo.ts} +8 -2
  127. package/build/libarkts-copy/src/generated/peers/DirectEvalExpression.ts +9 -3
  128. package/build/libarkts-copy/src/generated/peers/DoWhileStatement.ts +9 -3
  129. package/build/libarkts-copy/src/generated/peers/DynamicImportData.ts +7 -1
  130. package/build/libarkts-copy/src/generated/peers/ETSClassLiteral.ts +10 -4
  131. package/build/libarkts-copy/src/generated/peers/ETSFunctionType.ts +10 -4
  132. package/build/libarkts-copy/src/generated/peers/ETSImportDeclaration.ts +16 -5
  133. package/build/libarkts-copy/src/generated/peers/ETSKeyofType.ts +10 -4
  134. package/build/libarkts-copy/src/generated/peers/ETSModule.ts +59 -4
  135. package/build/libarkts-copy/src/generated/peers/ETSNewArrayInstanceExpression.ts +10 -4
  136. package/build/libarkts-copy/src/generated/peers/ETSNewClassInstanceExpression.ts +11 -5
  137. package/build/libarkts-copy/src/generated/peers/ETSNewMultiDimArrayInstanceExpression.ts +11 -5
  138. package/build/libarkts-copy/src/generated/peers/ETSNullType.ts +10 -4
  139. package/build/libarkts-copy/src/generated/peers/ETSPackageDeclaration.ts +10 -4
  140. package/build/libarkts-copy/src/generated/peers/ETSParameterExpression.ts +46 -12
  141. package/build/libarkts-copy/src/generated/peers/ETSPrimitiveType.ts +10 -4
  142. package/build/libarkts-copy/src/generated/peers/ETSReExportDeclaration.ts +7 -1
  143. package/build/libarkts-copy/src/generated/peers/ETSStringLiteralType.ts +10 -4
  144. package/build/libarkts-copy/src/generated/peers/ETSStructDeclaration.ts +10 -4
  145. package/build/libarkts-copy/src/generated/peers/ETSTuple.ts +14 -8
  146. package/build/libarkts-copy/src/generated/peers/ETSTypeReference.ts +10 -4
  147. package/build/libarkts-copy/src/generated/peers/ETSTypeReferencePart.ts +11 -5
  148. package/build/libarkts-copy/src/generated/peers/ETSUndefinedType.ts +10 -4
  149. package/build/libarkts-copy/src/generated/peers/ETSUnionType.ts +15 -4
  150. package/build/libarkts-copy/src/generated/peers/ETSWildcardType.ts +10 -4
  151. package/build/libarkts-copy/src/generated/peers/EmptyStatement.ts +16 -4
  152. package/build/libarkts-copy/src/generated/peers/ErrorLogger.ts +7 -1
  153. package/build/libarkts-copy/src/generated/peers/ExportAllDeclaration.ts +9 -3
  154. package/build/libarkts-copy/src/generated/peers/ExportDefaultDeclaration.ts +9 -3
  155. package/build/libarkts-copy/src/generated/peers/ExportNamedDeclaration.ts +18 -7
  156. package/build/libarkts-copy/src/generated/peers/ExportSpecifier.ts +26 -3
  157. package/build/libarkts-copy/src/generated/peers/Expression.ts +7 -1
  158. package/build/libarkts-copy/src/generated/peers/ExpressionStatement.ts +9 -3
  159. package/build/libarkts-copy/src/generated/peers/ForInStatement.ts +9 -3
  160. package/build/libarkts-copy/src/generated/peers/ForOfStatement.ts +9 -3
  161. package/build/libarkts-copy/src/generated/peers/ForUpdateStatement.ts +8 -2
  162. package/build/libarkts-copy/src/generated/peers/FunctionDecl.ts +7 -1
  163. package/build/libarkts-copy/src/generated/peers/FunctionDeclaration.ts +44 -6
  164. package/build/libarkts-copy/src/generated/peers/FunctionExpression.ts +10 -4
  165. package/build/libarkts-copy/src/generated/peers/FunctionSignature.ts +7 -1
  166. package/build/libarkts-copy/src/generated/peers/IRNode.ts +7 -1
  167. package/build/libarkts-copy/src/generated/peers/Identifier.ts +16 -5
  168. package/build/libarkts-copy/src/generated/peers/IfStatement.ts +14 -3
  169. package/build/libarkts-copy/src/generated/peers/ImportDeclaration.ts +28 -4
  170. package/build/libarkts-copy/src/generated/peers/ImportDefaultSpecifier.ts +9 -3
  171. package/build/libarkts-copy/src/generated/peers/ImportExpression.ts +9 -3
  172. package/build/libarkts-copy/src/generated/peers/ImportNamespaceSpecifier.ts +9 -3
  173. package/build/libarkts-copy/src/generated/peers/ImportSource.ts +7 -1
  174. package/build/libarkts-copy/src/generated/peers/ImportSpecifier.ts +9 -3
  175. package/build/libarkts-copy/src/generated/peers/IndexInfo.ts +7 -1
  176. package/build/libarkts-copy/src/generated/peers/InterfaceDecl.ts +7 -1
  177. package/build/libarkts-copy/src/generated/peers/LabelPair.ts +7 -1
  178. package/build/libarkts-copy/src/generated/peers/LabelledStatement.ts +9 -3
  179. package/build/libarkts-copy/src/generated/peers/Literal.ts +15 -1
  180. package/build/libarkts-copy/src/generated/peers/LoopStatement.ts +7 -1
  181. package/build/libarkts-copy/src/generated/peers/MaybeOptionalExpression.ts +7 -1
  182. package/build/libarkts-copy/src/generated/peers/MemberExpression.ts +9 -3
  183. package/build/libarkts-copy/src/generated/peers/MetaProperty.ts +9 -3
  184. package/build/libarkts-copy/src/generated/peers/MethodDefinition.ts +26 -10
  185. package/build/libarkts-copy/src/generated/peers/NamedType.ts +9 -3
  186. package/build/libarkts-copy/src/generated/peers/NewExpression.ts +9 -3
  187. package/build/libarkts-copy/src/generated/peers/NullLiteral.ts +9 -3
  188. package/build/libarkts-copy/src/generated/peers/NumberLiteral.ts +15 -9
  189. package/build/libarkts-copy/src/generated/peers/ObjectDescriptor.ts +7 -1
  190. package/build/libarkts-copy/src/generated/peers/ObjectExpression.ts +10 -4
  191. package/build/libarkts-copy/src/generated/peers/OmittedExpression.ts +9 -3
  192. package/build/libarkts-copy/src/generated/peers/OpaqueTypeNode.ts +10 -4
  193. package/build/libarkts-copy/src/generated/peers/PrefixAssertionExpression.ts +9 -3
  194. package/build/libarkts-copy/src/generated/peers/Program.ts +194 -0
  195. package/build/libarkts-copy/src/generated/peers/Property.ts +10 -4
  196. package/build/libarkts-copy/src/generated/peers/RegExpLiteral.ts +9 -3
  197. package/build/libarkts-copy/src/generated/peers/ReturnStatement.ts +10 -4
  198. package/build/libarkts-copy/src/generated/peers/ScopeFindResult.ts +7 -1
  199. package/build/libarkts-copy/src/generated/peers/ScriptFunction.ts +77 -10
  200. package/build/libarkts-copy/src/generated/peers/ScriptFunctionData.ts +7 -1
  201. package/build/libarkts-copy/src/generated/peers/SequenceExpression.ts +9 -3
  202. package/build/libarkts-copy/src/generated/peers/SignatureInfo.ts +7 -1
  203. package/build/libarkts-copy/src/generated/peers/SourcePosition.ts +7 -1
  204. package/build/libarkts-copy/src/generated/peers/SourceRange.ts +7 -1
  205. package/build/libarkts-copy/src/generated/peers/SpreadElement.ts +10 -4
  206. package/build/libarkts-copy/src/generated/peers/SrcDumper.ts +46 -9
  207. package/build/libarkts-copy/src/generated/peers/Statement.ts +7 -1
  208. package/build/libarkts-copy/src/generated/peers/StringLiteral.ts +10 -4
  209. package/build/libarkts-copy/src/generated/peers/{ETSDynamicFunctionType.ts → SuggestionInfo.ts} +7 -5
  210. package/build/libarkts-copy/src/generated/peers/SuperExpression.ts +10 -4
  211. package/build/libarkts-copy/src/generated/peers/SwitchCaseStatement.ts +10 -4
  212. package/build/libarkts-copy/src/generated/peers/SwitchStatement.ts +10 -4
  213. package/build/libarkts-copy/src/generated/peers/TSAnyKeyword.ts +10 -4
  214. package/build/libarkts-copy/src/generated/peers/TSArrayType.ts +10 -4
  215. package/build/libarkts-copy/src/generated/peers/TSAsExpression.ts +10 -4
  216. package/build/libarkts-copy/src/generated/peers/TSBigintKeyword.ts +10 -4
  217. package/build/libarkts-copy/src/generated/peers/TSBooleanKeyword.ts +10 -4
  218. package/build/libarkts-copy/src/generated/peers/TSClassImplements.ts +11 -5
  219. package/build/libarkts-copy/src/generated/peers/TSConditionalType.ts +10 -4
  220. package/build/libarkts-copy/src/generated/peers/TSConstructorType.ts +10 -4
  221. package/build/libarkts-copy/src/generated/peers/TSEnumDeclaration.ts +48 -6
  222. package/build/libarkts-copy/src/generated/peers/TSEnumMember.ts +11 -5
  223. package/build/libarkts-copy/src/generated/peers/TSExternalModuleReference.ts +10 -4
  224. package/build/libarkts-copy/src/generated/peers/TSFunctionType.ts +10 -4
  225. package/build/libarkts-copy/src/generated/peers/TSImportEqualsDeclaration.ts +10 -4
  226. package/build/libarkts-copy/src/generated/peers/TSImportType.ts +10 -4
  227. package/build/libarkts-copy/src/generated/peers/TSIndexSignature.ts +10 -4
  228. package/build/libarkts-copy/src/generated/peers/TSIndexedAccessType.ts +10 -4
  229. package/build/libarkts-copy/src/generated/peers/TSInferType.ts +10 -4
  230. package/build/libarkts-copy/src/generated/peers/TSInterfaceBody.ts +10 -4
  231. package/build/libarkts-copy/src/generated/peers/TSInterfaceDeclaration.ts +78 -8
  232. package/build/libarkts-copy/src/generated/peers/TSInterfaceHeritage.ts +10 -4
  233. package/build/libarkts-copy/src/generated/peers/TSIntersectionType.ts +10 -4
  234. package/build/libarkts-copy/src/generated/peers/TSLiteralType.ts +10 -4
  235. package/build/libarkts-copy/src/generated/peers/TSMappedType.ts +10 -4
  236. package/build/libarkts-copy/src/generated/peers/TSMethodSignature.ts +10 -4
  237. package/build/libarkts-copy/src/generated/peers/TSModuleBlock.ts +10 -4
  238. package/build/libarkts-copy/src/generated/peers/TSModuleDeclaration.ts +10 -4
  239. package/build/libarkts-copy/src/generated/peers/TSNamedTupleMember.ts +10 -4
  240. package/build/libarkts-copy/src/generated/peers/TSNeverKeyword.ts +10 -4
  241. package/build/libarkts-copy/src/generated/peers/TSNonNullExpression.ts +10 -4
  242. package/build/libarkts-copy/src/generated/peers/TSNullKeyword.ts +10 -4
  243. package/build/libarkts-copy/src/generated/peers/TSNumberKeyword.ts +10 -4
  244. package/build/libarkts-copy/src/generated/peers/TSObjectKeyword.ts +10 -4
  245. package/build/libarkts-copy/src/generated/peers/TSParameterProperty.ts +10 -4
  246. package/build/libarkts-copy/src/generated/peers/TSParenthesizedType.ts +10 -4
  247. package/build/libarkts-copy/src/generated/peers/TSPropertySignature.ts +10 -4
  248. package/build/libarkts-copy/src/generated/peers/TSQualifiedName.ts +10 -4
  249. package/build/libarkts-copy/src/generated/peers/TSSignatureDeclaration.ts +10 -4
  250. package/build/libarkts-copy/src/generated/peers/TSStringKeyword.ts +10 -4
  251. package/build/libarkts-copy/src/generated/peers/TSThisType.ts +10 -4
  252. package/build/libarkts-copy/src/generated/peers/TSTupleType.ts +10 -4
  253. package/build/libarkts-copy/src/generated/peers/TSTypeAliasDeclaration.ts +53 -6
  254. package/build/libarkts-copy/src/generated/peers/TSTypeAssertion.ts +10 -4
  255. package/build/libarkts-copy/src/generated/peers/TSTypeLiteral.ts +10 -4
  256. package/build/libarkts-copy/src/generated/peers/TSTypeOperator.ts +10 -4
  257. package/build/libarkts-copy/src/generated/peers/TSTypeParameter.ts +41 -7
  258. package/build/libarkts-copy/src/generated/peers/TSTypeParameterDeclaration.ts +15 -4
  259. package/build/libarkts-copy/src/generated/peers/TSTypeParameterInstantiation.ts +10 -4
  260. package/build/libarkts-copy/src/generated/peers/TSTypePredicate.ts +10 -4
  261. package/build/libarkts-copy/src/generated/peers/TSTypeQuery.ts +10 -4
  262. package/build/libarkts-copy/src/generated/peers/TSTypeReference.ts +10 -4
  263. package/build/libarkts-copy/src/generated/peers/TSUndefinedKeyword.ts +10 -4
  264. package/build/libarkts-copy/src/generated/peers/TSUnionType.ts +10 -4
  265. package/build/libarkts-copy/src/generated/peers/TSUnknownKeyword.ts +10 -4
  266. package/build/libarkts-copy/src/generated/peers/TSVoidKeyword.ts +10 -4
  267. package/build/libarkts-copy/src/generated/peers/TaggedTemplateExpression.ts +10 -4
  268. package/build/libarkts-copy/src/generated/peers/TemplateElement.ts +11 -5
  269. package/build/libarkts-copy/src/generated/peers/TemplateLiteral.ts +10 -4
  270. package/build/libarkts-copy/src/generated/peers/ThisExpression.ts +10 -4
  271. package/build/libarkts-copy/src/generated/peers/ThrowStatement.ts +10 -4
  272. package/build/libarkts-copy/src/generated/peers/TryStatement.ts +11 -5
  273. package/build/libarkts-copy/src/generated/peers/TypeNode.ts +37 -3
  274. package/build/libarkts-copy/src/generated/peers/TypedAstNode.ts +7 -1
  275. package/build/libarkts-copy/src/generated/peers/TypedStatement.ts +7 -1
  276. package/build/libarkts-copy/src/generated/peers/TypeofExpression.ts +10 -4
  277. package/build/libarkts-copy/src/generated/peers/UnaryExpression.ts +15 -4
  278. package/build/libarkts-copy/src/generated/peers/UndefinedLiteral.ts +9 -3
  279. package/build/libarkts-copy/src/generated/peers/UpdateExpression.ts +10 -4
  280. package/build/libarkts-copy/src/generated/peers/VReg.ts +7 -1
  281. package/build/libarkts-copy/src/generated/peers/ValidationInfo.ts +7 -1
  282. package/build/libarkts-copy/src/generated/peers/VariableDeclaration.ts +48 -8
  283. package/build/libarkts-copy/src/generated/peers/VariableDeclarator.ts +11 -5
  284. package/build/libarkts-copy/src/generated/peers/VerificationContext.ts +7 -1
  285. package/build/libarkts-copy/src/generated/peers/VerifierMessage.ts +7 -1
  286. package/build/libarkts-copy/src/generated/peers/WhileStatement.ts +15 -4
  287. package/build/libarkts-copy/src/generated/peers/YieldExpression.ts +10 -4
  288. package/build/libarkts-copy/src/index.ts +13 -1
  289. package/build/libarkts-copy/src/plugin-utils.ts +117 -0
  290. package/build/libarkts-copy/src/utils.ts +17 -28
  291. package/build/libarkts-copy/src/wrapper-compat/README.md +16 -0
  292. package/build/libarkts-copy/src/wrapper-compat/arkts-api/class-by-peer.ts +46 -0
  293. package/build/libarkts-copy/src/wrapper-compat/arkts-api/factory/nodeFactory.ts +454 -0
  294. package/build/libarkts-copy/src/wrapper-compat/arkts-api/factory/nodeTests.ts +99 -0
  295. package/build/libarkts-copy/src/wrapper-compat/arkts-api/index.ts +88 -0
  296. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ArrayExpression.ts +38 -0
  297. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ArrowFunctionExpression.ts +35 -0
  298. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/AssignmentExpression.ts +38 -0
  299. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/BlockStatement.ts +27 -0
  300. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/CallExpression.ts +45 -0
  301. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ClassDeclaration.ts +27 -0
  302. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ClassDefinition.ts +73 -0
  303. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ClassProperty.ts +51 -0
  304. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ETSFunctionType.ts +42 -0
  305. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ETSImportDeclaration.ts +39 -0
  306. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ETSParameterExpression.ts +43 -0
  307. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ExpressionStatement.ts +28 -0
  308. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/FunctionDeclaration.ts +37 -0
  309. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/FunctionExpression.ts +28 -0
  310. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/IfStatement.ts +37 -0
  311. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/MemberExpression.ts +42 -0
  312. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/MethodDefinition.ts +46 -0
  313. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/NumberLiteral.ts +30 -0
  314. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ObjectExpression.ts +37 -0
  315. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/Property.ts +27 -0
  316. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/ScriptFunction.ts +46 -0
  317. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/StructDeclaration.ts +28 -0
  318. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TSInterfaceDeclaration.ts +47 -0
  319. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TSTypeAliasDeclaration.ts +40 -0
  320. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TSTypeParameter.ts +36 -0
  321. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/TryStatement.ts +41 -0
  322. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/VariableDeclaration.ts +42 -0
  323. package/build/libarkts-copy/src/wrapper-compat/arkts-api/node-utilities/VariableDeclarator.ts +39 -0
  324. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/ArktsObject.ts +45 -0
  325. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/AstNode.ts +26 -0
  326. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/Config.ts +53 -0
  327. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/Context.ts +60 -0
  328. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/Diagnostic.ts +39 -0
  329. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/DiagnosticInfo.ts +33 -0
  330. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/DiagnosticKind.ts +33 -0
  331. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/ImportPathManager.ts +34 -0
  332. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/Program.ts +105 -0
  333. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/SourcePosition.ts +38 -0
  334. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/SourceRange.ts +38 -0
  335. package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/SuggestionInfo.ts +33 -0
  336. package/build/libarkts-copy/src/wrapper-compat/arkts-api/static/global.ts +16 -0
  337. package/build/libarkts-copy/src/wrapper-compat/arkts-api/static/globalUtils.ts +27 -0
  338. package/build/libarkts-copy/src/wrapper-compat/arkts-api/to-be-generated/MemberExpression.ts +108 -0
  339. package/build/libarkts-copy/src/wrapper-compat/arkts-api/types.ts +907 -0
  340. package/build/libarkts-copy/src/wrapper-compat/arkts-api/utilities/nativePtrDecoder.ts +69 -0
  341. package/build/libarkts-copy/src/wrapper-compat/arkts-api/utilities/performance.ts +190 -0
  342. package/build/libarkts-copy/src/wrapper-compat/arkts-api/utilities/private.ts +198 -0
  343. package/build/libarkts-copy/src/wrapper-compat/arkts-api/utilities/public.ts +325 -0
  344. package/build/libarkts-copy/src/wrapper-compat/arkts-api/visitor.ts +421 -0
  345. package/build/libarkts-copy/src/wrapper-compat/index.ts +20 -0
  346. package/lib/index.js +323 -148
  347. package/package.json +2 -2
  348. package/templates/Es2pandaEnums.ts +4 -0
  349. package/templates/Es2pandaNativeModule.ts +5 -1
  350. package/templates/factory.ts +5 -1
  351. package/templates/index.ts +5 -1
  352. package/templates/node-map.ts +5 -1
  353. package/templates/peer.ts +5 -1
  354. package/build/libarkts-copy/README.md +0 -36
package/lib/index.js CHANGED
@@ -136,7 +136,7 @@ function error(
136
136
  : 1;
137
137
 
138
138
  const precedingLastLine = lastLine(
139
- tokensToText(sliceTokens(-5), { precedes: true }),
139
+ tokensToText(sliceTokens(-maxTokens), { precedes: true }),
140
140
  );
141
141
 
142
142
  const subsequentTokens = sliceTokens(maxTokens);
@@ -3658,6 +3658,8 @@ class Language {
3658
3658
  case "java": return Language.JAVA;
3659
3659
  case "ts": return Language.TS;
3660
3660
  case "cangjie": return Language.CJ;
3661
+ case "cpp": return Language.CPP;
3662
+ case "kotlin": return Language.KOTLIN;
3661
3663
  default: throw new Error(`Unsupported language ${name}`);
3662
3664
  }
3663
3665
  }
@@ -3667,6 +3669,7 @@ Language.ARKTS = new Language("ArkTS", ".ts", true); // using .ts for ArkTS unti
3667
3669
  Language.JAVA = new Language("Java", ".java", false);
3668
3670
  Language.CPP = new Language("C++", ".cc", false);
3669
3671
  Language.CJ = new Language("CangJie", ".cj", false);
3672
+ Language.KOTLIN = new Language("Kotlin", ".kt", false);
3670
3673
 
3671
3674
  /*
3672
3675
  * Copyright (c) 2024 Huawei Device Co., Ltd.
@@ -3830,10 +3833,12 @@ var IDLExtendedAttributes;
3830
3833
  IDLExtendedAttributes["Protected"] = "Protected";
3831
3834
  IDLExtendedAttributes["Synthetic"] = "Synthetic";
3832
3835
  IDLExtendedAttributes["Throws"] = "Throws";
3836
+ IDLExtendedAttributes["TraceKey"] = "TraceKey";
3833
3837
  IDLExtendedAttributes["TypeArguments"] = "TypeArguments";
3834
3838
  IDLExtendedAttributes["TypeParameters"] = "TypeParameters";
3835
3839
  IDLExtendedAttributes["VerbatimDts"] = "VerbatimDts";
3836
3840
  IDLExtendedAttributes["HandWrittenImplementation"] = "HandWrittenImplementation";
3841
+ IDLExtendedAttributes["ExtraMethod"] = "ExtraMethod";
3837
3842
  })(IDLExtendedAttributes || (IDLExtendedAttributes = {}));
3838
3843
  var IDLAccessorAttribute;
3839
3844
  (function (IDLAccessorAttribute) {
@@ -3850,6 +3855,7 @@ var IDLInterfaceSubkind;
3850
3855
  })(IDLInterfaceSubkind || (IDLInterfaceSubkind = {}));
3851
3856
  /** Updates tree in place! */
3852
3857
  function updateEachChild(node, op, cbLeave) {
3858
+ var _a;
3853
3859
  const old = node;
3854
3860
  node = op(old);
3855
3861
  if (node.kind !== old.kind) {
@@ -3932,7 +3938,11 @@ function updateEachChild(node, op, cbLeave) {
3932
3938
  concrete.typeArguments = concrete.typeArguments.map(it => updateEachChild(it, op, cbLeave));
3933
3939
  break;
3934
3940
  }
3935
- case IDLKind.ReferenceType:
3941
+ case IDLKind.ReferenceType: {
3942
+ const concrete = node;
3943
+ concrete.typeArguments = (_a = concrete.typeArguments) === null || _a === void 0 ? void 0 : _a.map(it => updateEachChild(it, op, cbLeave));
3944
+ break;
3945
+ }
3936
3946
  case IDLKind.TypeParameterType:
3937
3947
  case IDLKind.EnumMember:
3938
3948
  case IDLKind.Import:
@@ -4041,15 +4051,6 @@ function createOptionalType(element, nodeInitializer) {
4041
4051
  }
4042
4052
  return Object.assign(Object.assign({ kind: IDLKind.OptionalType, type: element }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlTypeBrand: innerIdlSymbol });
4043
4053
  }
4044
- /**
4045
- * This placeholder is used when a class has no superclass.
4046
- * Examples:
4047
- * class definition: inheritance:
4048
- * `C extends T` : [T]
4049
- * `C implements T` : [Top, T]
4050
- * `C extends T implements I, J` : [T, I, J]
4051
- */
4052
- const IDLTopType = createReferenceType("__TOP__");
4053
4054
  // must match with toIDLType in deserialize.ts
4054
4055
  const IDLPointerType = createPrimitiveType('pointer');
4055
4056
  const IDLVoidType = createPrimitiveType('void');
@@ -4084,15 +4085,10 @@ createPrimitiveType('InteropReturnBuffer');
4084
4085
  function createNamespace(name, members, nodeInitializer) {
4085
4086
  return Object.assign(Object.assign({ kind: IDLKind.Namespace, members: members !== null && members !== void 0 ? members : [], name: name }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlEntryBrand: innerIdlSymbol, _idlNamedNodeBrand: innerIdlSymbol });
4086
4087
  }
4087
- function isSpecialNodes(node) {
4088
- return node === IDLTopType
4089
- || node === IDLObjectType
4090
- || isPrimitiveType(node);
4091
- }
4092
4088
  function linkParentBack(node) {
4093
4089
  const parentStack = [];
4094
4090
  updateEachChild(node, (node) => {
4095
- if (isSpecialNodes(node)) {
4091
+ if (isPrimitiveType(node)) {
4096
4092
  return node;
4097
4093
  }
4098
4094
  if (parentStack.length) {
@@ -4105,7 +4101,7 @@ function linkParentBack(node) {
4105
4101
  parentStack.push(node);
4106
4102
  return node;
4107
4103
  }, (node) => {
4108
- if (isSpecialNodes(node)) {
4104
+ if (isPrimitiveType(node)) {
4109
4105
  return;
4110
4106
  }
4111
4107
  parentStack.pop();
@@ -4483,7 +4479,10 @@ function printParameters(parameters) {
4483
4479
  return (_b = (_a = parameters === null || parameters === void 0 ? void 0 : parameters.map(it => nameWithType(it, it.isVariadic, it.isOptional))) === null || _a === void 0 ? void 0 : _a.join(", ")) !== null && _b !== void 0 ? _b : "";
4484
4480
  }
4485
4481
  function printConstructor(idl) {
4486
- return [`constructor(${printParameters(idl.parameters)});`];
4482
+ return [
4483
+ ...printExtendedAttributes(idl),
4484
+ `constructor(${printParameters(idl.parameters)});`
4485
+ ];
4487
4486
  }
4488
4487
  function nameWithType(idl, isVariadic = false, isOptional = false) {
4489
4488
  const type = printType(idl.type);
@@ -4549,6 +4548,7 @@ const attributesToQuote = new Set([
4549
4548
  IDLExtendedAttributes.DtsTag,
4550
4549
  IDLExtendedAttributes.Import,
4551
4550
  IDLExtendedAttributes.Interfaces,
4551
+ IDLExtendedAttributes.TraceKey,
4552
4552
  IDLExtendedAttributes.TypeArguments,
4553
4553
  IDLExtendedAttributes.TypeParameters,
4554
4554
  ]);
@@ -4618,28 +4618,10 @@ function printCallback(idl) {
4618
4618
  ];
4619
4619
  }
4620
4620
  function printInterfaceInherit(idl) {
4621
- var _a;
4622
4621
  if (idl.inheritance.length === 0) {
4623
4622
  return "";
4624
4623
  }
4625
- const inheritance = [...idl.inheritance];
4626
- const types = [];
4627
- if (idl.subkind === IDLInterfaceSubkind.Class) {
4628
- if (inheritance[0] !== IDLTopType) {
4629
- const ref = clone(inheritance[0]);
4630
- (_a = ref.extendedAttributes) !== null && _a !== void 0 ? _a : (ref.extendedAttributes = []);
4631
- if (!hasExtAttribute(ref, IDLExtendedAttributes.Extends)) {
4632
- ref.extendedAttributes = ref.extendedAttributes.concat([
4633
- { name: IDLExtendedAttributes.Extends }
4634
- ]);
4635
- }
4636
- types.push(`${printType(ref)}`);
4637
- inheritance.shift();
4638
- }
4639
- }
4640
- inheritance.forEach(type => {
4641
- types.push(printType(type));
4642
- });
4624
+ const types = idl.inheritance.map(type => printType(type));
4643
4625
  return ": " + types.join(', ');
4644
4626
  }
4645
4627
  function printInterface(idl) {
@@ -4768,6 +4750,12 @@ function maybeUnwrapOptionalType(type) {
4768
4750
  }
4769
4751
  return type;
4770
4752
  }
4753
+ function maybeOptional(type, optional = false) {
4754
+ if (optional) {
4755
+ return createOptionalType(type);
4756
+ }
4757
+ return type;
4758
+ }
4771
4759
  const DebugUtils = {
4772
4760
  debugPrintType: (type) => {
4773
4761
  if (isContainerType(type)) {
@@ -4875,13 +4863,10 @@ function warn(message) {
4875
4863
  console.log(`WARNING: ${message}`);
4876
4864
  }
4877
4865
  function forceWriteFile(filePath, content) {
4878
- path__namespace.dirname(filePath).split(path__namespace.sep).reduce((last, dir) => {
4879
- const dirPath = path__namespace.join(last, dir);
4880
- if (!fs__namespace.existsSync(dirPath)) {
4881
- fs__namespace.mkdirSync(dirPath);
4882
- }
4883
- return dirPath;
4884
- }, ".");
4866
+ const dirPath = path__namespace.dirname(filePath);
4867
+ if (!fs__namespace.existsSync(dirPath)) {
4868
+ fs__namespace.mkdirSync(dirPath, { recursive: true });
4869
+ }
4885
4870
  fs__namespace.writeFileSync(filePath, content);
4886
4871
  }
4887
4872
  function rightmostIndexOf(array, predicate) {
@@ -5221,7 +5206,7 @@ const D = {
5221
5206
  };
5222
5207
  });
5223
5208
  },
5224
- null(x) {
5209
+ null() {
5225
5210
  return new ConfigDescriberLeaf(xs => {
5226
5211
  if (typeof xs === 'object' && xs === null) {
5227
5212
  return ValidationBox.ok(null);
@@ -5306,7 +5291,8 @@ D.object({
5306
5291
  forceResource: T.stringArray(),
5307
5292
  forceContext: T.stringArray(),
5308
5293
  hooks: D.map(D.string(), D.map(D.string(), HookMethodSchema)).onMerge('replace'),
5309
- externalModuleTypes: D.map(D.string(), D.string()).onMerge('replace'),
5294
+ externalTypes: D.map(D.string(), D.string()).onMerge('replace'),
5295
+ externalPackages: T.stringArray(),
5310
5296
  moduleName: D.string(),
5311
5297
  modules: D.map(D.string(), ModuleConfigurationSchema).onMerge('replace'),
5312
5298
  globalPackages: T.stringArray()
@@ -5325,7 +5311,8 @@ const defaultCoreConfiguration = {
5325
5311
  forceResource: [],
5326
5312
  forceContext: [],
5327
5313
  hooks: new Map(),
5328
- externalModuleTypes: new Map(),
5314
+ externalTypes: new Map(),
5315
+ externalPackages: [],
5329
5316
  moduleName: "",
5330
5317
  modules: new Map(),
5331
5318
  globalPackages: []
@@ -5593,6 +5580,7 @@ class IndentedPrinter {
5593
5580
  return this.output;
5594
5581
  }
5595
5582
  printTo(file) {
5583
+ fs__namespace.mkdirSync(path.dirname(file), { recursive: true });
5596
5584
  fs__namespace.writeFileSync(file, this.getOutput().join("\n"));
5597
5585
  }
5598
5586
  withIndent(prints) {
@@ -5701,6 +5689,18 @@ class MethodCallExpression extends FunctionCallExpression {
5701
5689
  return `${this.receiver}${this.nullable ? "?" : ""}.${super.asString()}`;
5702
5690
  }
5703
5691
  }
5692
+ class MethodStaticCallExpression extends MethodCallExpression {
5693
+ constructor(receiver, method, params, nullable = false) {
5694
+ super(receiver, method, params, nullable);
5695
+ this.receiver = receiver;
5696
+ this.nullable = nullable;
5697
+ }
5698
+ }
5699
+ class ThisCallExpression extends FunctionCallExpression {
5700
+ constructor(params) {
5701
+ super("this", params);
5702
+ }
5703
+ }
5704
5704
  class FieldAccessExpression {
5705
5705
  constructor(receiver, field, nullable = false) {
5706
5706
  this.receiver = receiver;
@@ -5903,6 +5903,9 @@ class LambdaExpression {
5903
5903
  stmt.write(writer);
5904
5904
  }
5905
5905
  }
5906
+ writer.features.forEach(([feature, module]) => {
5907
+ this.originalWriter.addFeature(feature, module);
5908
+ });
5906
5909
  return (this.body ? ((_a = this.body) === null || _a === void 0 ? void 0 : _a.length) > 1 ? '\n' : '' : '').concat(writer.getOutput()
5907
5910
  .filter(line => line !== "")
5908
5911
  .map(line => indentedBy(line.endsWith('{') || line.endsWith('}') || line.endsWith(';') ? line : `${line};`, 1))
@@ -5940,6 +5943,7 @@ var MethodModifier;
5940
5943
  MethodModifier[MethodModifier["THROWS"] = 8] = "THROWS";
5941
5944
  MethodModifier[MethodModifier["FREE"] = 9] = "FREE";
5942
5945
  MethodModifier[MethodModifier["FORCE_CONTEXT"] = 10] = "FORCE_CONTEXT";
5946
+ MethodModifier[MethodModifier["OVERRIDE"] = 11] = "OVERRIDE";
5943
5947
  })(MethodModifier || (MethodModifier = {}));
5944
5948
  var ClassModifier;
5945
5949
  (function (ClassModifier) {
@@ -5947,6 +5951,11 @@ var ClassModifier;
5947
5951
  ClassModifier[ClassModifier["PRIVATE"] = 1] = "PRIVATE";
5948
5952
  ClassModifier[ClassModifier["PROTECTED"] = 2] = "PROTECTED";
5949
5953
  })(ClassModifier || (ClassModifier = {}));
5954
+ var DelegationType;
5955
+ (function (DelegationType) {
5956
+ DelegationType[DelegationType["THIS"] = 0] = "THIS";
5957
+ DelegationType[DelegationType["SUPER"] = 1] = "SUPER";
5958
+ })(DelegationType || (DelegationType = {}));
5950
5959
  class Method {
5951
5960
  constructor(name, signature, modifiers = undefined, generics) {
5952
5961
  this.name = name;
@@ -5968,6 +5977,7 @@ PrintHint.AsPointer = new PrintHint('AsPointer');
5968
5977
  PrintHint.AsConstPointer = new PrintHint('AsConstPointer');
5969
5978
  PrintHint.AsValue = new PrintHint('AsValue');
5970
5979
  PrintHint.AsConstReference = new PrintHint('AsConstReference');
5980
+ PrintHint.AsReference = new PrintHint('AsReference');
5971
5981
  class MethodSignature {
5972
5982
  constructor(returnType, args, defaults = undefined, argsModifiers = undefined, printHints, argNames) {
5973
5983
  this.returnType = returnType;
@@ -6023,11 +6033,15 @@ class LanguageWriter {
6023
6033
  this.resolver = resolver;
6024
6034
  this.language = language;
6025
6035
  this.namespaceStack = [];
6036
+ this.features = [];
6026
6037
  }
6027
6038
  indentDepth() {
6028
6039
  return this.printer.indentDepth();
6029
6040
  }
6030
6041
  maybeSemicolon() { return ";"; }
6042
+ addFeature(feature, module) {
6043
+ this.features.push([feature, module]);
6044
+ }
6031
6045
  // version of makeCast which uses TypeCheck.typeCast<T>(value) call for ETS language writer
6032
6046
  // Use it only if TypeChecker class is added as import to the generated file
6033
6047
  makeTypeCast(value, type, options) {
@@ -6054,12 +6068,17 @@ class LanguageWriter {
6054
6068
  var _a;
6055
6069
  this.writeMethodImplementation(new Method(method.name, method.signature, [MethodModifier.SETTER].concat((_a = method.modifiers) !== null && _a !== void 0 ? _a : [])), op);
6056
6070
  }
6071
+ // Deprecated
6072
+ // Use instead declarationCall parameter in writeConstructorImplementation(...)
6057
6073
  writeSuperCall(params) {
6058
6074
  this.printer.print(`super(${params.join(", ")})${this.maybeSemicolon()}`);
6059
6075
  }
6060
6076
  writeMethodCall(receiver, method, params, nullable = false) {
6061
6077
  this.printer.print(`${receiver}${nullable ? "?" : ""}.${method}(${params.join(", ")})`);
6062
6078
  }
6079
+ writeStaticMethodCall(receiver, method, params, nullable = false) {
6080
+ this.writeMethodCall(receiver, method, params, nullable);
6081
+ }
6063
6082
  writeStatement(stmt) {
6064
6083
  stmt.write(this);
6065
6084
  }
@@ -6110,6 +6129,14 @@ class LanguageWriter {
6110
6129
  makeMethodCall(receiver, method, params, nullable) {
6111
6130
  return new MethodCallExpression(receiver, method, params, nullable);
6112
6131
  }
6132
+ // Deprecated
6133
+ // Use instead declarationCall parameter in writeConstructorImplementation(...) with DelegationType.THIS
6134
+ makeThisCall(params) {
6135
+ return new ThisCallExpression(params);
6136
+ }
6137
+ makeStaticMethodCall(receiver, method, params, nullable) {
6138
+ return new MethodStaticCallExpression(receiver, method, params, nullable);
6139
+ }
6113
6140
  makeFieldAccess(receiver, method, nullable) {
6114
6141
  return new FieldAccessExpression(receiver, method, nullable);
6115
6142
  }
@@ -6291,6 +6318,9 @@ class LanguageWriter {
6291
6318
  makeCallIsObject(value) {
6292
6319
  return this.makeString(`typeof ${value} === "object"`);
6293
6320
  }
6321
+ makeStaticBlock(op) {
6322
+ op(this);
6323
+ }
6294
6324
  instanceOf(convertor, value, _duplicateMembers) {
6295
6325
  return this.makeString(`${value} instanceof ${this.getNodeName(convertor.idlType)}`);
6296
6326
  }
@@ -6647,6 +6677,11 @@ class CppPointerPropertyAccessExpression {
6647
6677
  return `${this.expression}->${this.name}`;
6648
6678
  }
6649
6679
  }
6680
+ class CPPMethodStaticCallExpression extends MethodStaticCallExpression {
6681
+ asString() {
6682
+ return `${this.receiver}::${this.name}(${this.params.map(it => it.asString()).join(', ')})`;
6683
+ }
6684
+ }
6650
6685
  ////////////////////////////////////////////////////////////////
6651
6686
  // STATEMENTS //
6652
6687
  ////////////////////////////////////////////////////////////////
@@ -6743,8 +6778,13 @@ class CppLanguageWriter extends CLikeLanguageWriter {
6743
6778
  constructor(printer, resolver, typeConvertor, primitivesTypes) {
6744
6779
  super(printer, resolver, Language.CPP);
6745
6780
  this.primitivesTypes = primitivesTypes;
6781
+ this.classMode = 'normal';
6782
+ this.currentClass = [];
6746
6783
  this.typeConvertor = typeConvertor;
6747
6784
  }
6785
+ changeModeTo(mode) {
6786
+ this.classMode = mode;
6787
+ }
6748
6788
  getNodeName(type) {
6749
6789
  return this.typeConvertor.convert(type);
6750
6790
  }
@@ -6752,14 +6792,28 @@ class CppLanguageWriter extends CLikeLanguageWriter {
6752
6792
  var _a;
6753
6793
  return new CppLanguageWriter(new IndentedPrinter(), (_a = options === null || options === void 0 ? void 0 : options.resolver) !== null && _a !== void 0 ? _a : this.resolver, this.typeConvertor, this.primitivesTypes);
6754
6794
  }
6795
+ writeDeclaration(name, signature, modifiers, postfix) {
6796
+ const realName = this.classMode === 'normal' ? name : `${this.currentClass.at(0)}::${name}`;
6797
+ const newModifiers = this.classMode === 'normal'
6798
+ ? modifiers
6799
+ : (modifiers !== null && modifiers !== void 0 ? modifiers : []).filter(it => it !== MethodModifier.STATIC).concat(MethodModifier.INLINE);
6800
+ super.writeDeclaration(realName, signature, newModifiers, postfix);
6801
+ }
6755
6802
  writeClass(name, op, superClass, interfaces) {
6756
- const superClasses = (superClass ? [superClass] : []).concat(interfaces !== null && interfaces !== void 0 ? interfaces : []);
6757
- const extendsClause = superClasses.length > 0 ? ` : ${superClasses.map(c => `public ${c}`).join(", ")}` : '';
6758
- this.printer.print(`class ${name}${extendsClause} {`);
6759
- this.pushIndent();
6803
+ if (this.classMode === 'normal') {
6804
+ const superClasses = (superClass ? [superClass] : []).concat(interfaces !== null && interfaces !== void 0 ? interfaces : []);
6805
+ const extendsClause = superClasses.length > 0 ? ` : ${superClasses.map(c => `public ${c}`).join(", ")}` : '';
6806
+ this.printer.print(`class ${name}${extendsClause} {`);
6807
+ this.pushIndent();
6808
+ }
6809
+ if (this.classMode === 'detached') {
6810
+ this.currentClass.push(name);
6811
+ }
6760
6812
  op(this);
6761
- this.popIndent();
6762
- this.printer.print(`};`);
6813
+ if (this.classMode === 'normal') {
6814
+ this.popIndent();
6815
+ this.printer.print(`};`);
6816
+ }
6763
6817
  }
6764
6818
  writeInterface(name, op, superInterfaces, generics) {
6765
6819
  throw new Error("Method not implemented.");
@@ -6772,6 +6826,9 @@ class CppLanguageWriter extends CLikeLanguageWriter {
6772
6826
  super.writeMethodCall(receiver, method, params, nullable);
6773
6827
  }
6774
6828
  }
6829
+ writeStaticMethodCall(receiver, method, params, nullable) {
6830
+ this.printer.print(`${receiver}::${method}(${params.join(', ')});`);
6831
+ }
6775
6832
  writeFieldDeclaration(name, type, modifiers, optional, initExpr) {
6776
6833
  let filter = function (modifier_name) {
6777
6834
  return modifier_name !== FieldModifier.STATIC;
@@ -6782,9 +6839,9 @@ class CppLanguageWriter extends CLikeLanguageWriter {
6782
6839
  this.printer.print(`${forceAsNamedNode(type).name} ${name};`);
6783
6840
  this.printer.popIndent();
6784
6841
  }
6785
- writeConstructorImplementation(className, signature, op, superCall, modifiers) {
6786
- const superInvocation = superCall
6787
- ? ` : ${superCall.name}(${superCall.signature.args.map((_, i) => superCall === null || superCall === void 0 ? void 0 : superCall.signature.argName(i)).join(", ")})`
6842
+ writeConstructorImplementation(className, signature, op, delegationCall, modifiers) {
6843
+ const superInvocation = delegationCall
6844
+ ? ` : ${delegationCall.delegationName}(${delegationCall.delegationArgs.map(it => it.asString()).join(", ")})`
6788
6845
  : "";
6789
6846
  const argList = signature.args.map((it, index) => {
6790
6847
  var _a;
@@ -6874,6 +6931,9 @@ class CppLanguageWriter extends CLikeLanguageWriter {
6874
6931
  makeUnionVariantCast(value, type, convertor, index) {
6875
6932
  return this.makeString(`${value}.value${index}`);
6876
6933
  }
6934
+ makeStaticMethodCall(receiver, method, params, nullable) {
6935
+ return new CPPMethodStaticCallExpression(receiver, method, params, nullable);
6936
+ }
6877
6937
  makeLoop(counter, limit, statement) {
6878
6938
  return new CLikeLoopStatement(counter, limit, statement);
6879
6939
  }
@@ -7014,6 +7074,9 @@ class CppLanguageWriter extends CLikeLanguageWriter {
7014
7074
  case PrintHint.AsPointer:
7015
7075
  postfix = '*';
7016
7076
  break;
7077
+ case PrintHint.AsReference:
7078
+ postfix = '&';
7079
+ break;
7017
7080
  case PrintHint.AsConstPointer:
7018
7081
  constModifier = 'const ';
7019
7082
  postfix = '*';
@@ -7265,11 +7328,13 @@ class TSLanguageWriter extends LanguageWriter {
7265
7328
  writeMethodDeclaration(name, signature, modifiers) {
7266
7329
  this.writeDeclaration(name, signature, true, false, modifiers);
7267
7330
  }
7268
- writeConstructorImplementation(className, signature, op, superCall, modifiers) {
7331
+ writeConstructorImplementation(className, signature, op, delegationCall, modifiers) {
7332
+ var _a;
7269
7333
  this.writeDeclaration(`${modifiers ? modifiers.map((it) => MethodModifier[it].toLowerCase()).join(' ') + ' ' : ''}constructor`, signature, false, true);
7270
7334
  this.pushIndent();
7271
- if (superCall) {
7272
- this.print(`super(${superCall.signature.args.map((_, i) => superCall === null || superCall === void 0 ? void 0 : superCall.signature.argName(i)).join(", ")})`);
7335
+ if (delegationCall) {
7336
+ const delegationType = ((delegationCall === null || delegationCall === void 0 ? void 0 : delegationCall.delegationType) == DelegationType.THIS) ? "this" : "super";
7337
+ this.print(`${delegationType}(${(_a = delegationCall.delegationArgs) === null || _a === void 0 ? void 0 : _a.map(it => it.asString()).join(", ")})`);
7273
7338
  }
7274
7339
  op(this);
7275
7340
  this.popIndent();
@@ -7557,6 +7622,12 @@ class CJFeatureNameConvertor extends DeclarationNameConvertor {
7557
7622
  }
7558
7623
  }
7559
7624
  CJFeatureNameConvertor.I = new CJFeatureNameConvertor();
7625
+ class KotlinFeatureNameConvertor extends DeclarationNameConvertor {
7626
+ convertEnum(decl) {
7627
+ return decl.name;
7628
+ }
7629
+ }
7630
+ KotlinFeatureNameConvertor.I = new KotlinFeatureNameConvertor();
7560
7631
  function createDeclarationNameConvertor(language) {
7561
7632
  switch (language) {
7562
7633
  case Language.ARKTS: return ETSDeclarationNameConvertor.I;
@@ -7691,15 +7762,15 @@ class ETSLambdaExpression extends LambdaExpression {
7691
7762
  function generateTypeCheckerName(typeName) {
7692
7763
  typeName = typeName
7693
7764
  .replaceAll('[]', 'BracketsArray')
7694
- .split('.').at(-1); // Todo: hack for namespaces. Remove when ready to use FQNames
7765
+ .split('.').join('_');
7695
7766
  return `is${typeName.replaceAll('[]', 'Brackets')}`;
7696
7767
  }
7697
- function generateEnumToNumericName(typeName) {
7698
- typeName = typeName.split('.').at(-1); // Todo: hack for namespaces. Remove when ready to use FQNames
7768
+ function generateEnumToNumericName(entry) {
7769
+ const typeName = getQualifiedName(entry, "namespace.name").split('.').join('_');
7699
7770
  return `${typeName}_ToNumeric`;
7700
7771
  }
7701
- function generateEnumFromNumericName(typeName) {
7702
- typeName = typeName.split('.').at(-1); // Todo: hack for namespaces. Remove when ready to use FQNames
7772
+ function generateEnumFromNumericName(entry) {
7773
+ const typeName = getQualifiedName(entry, "namespace.name").split('.').join('_');
7703
7774
  return `${typeName}_FromNumeric`;
7704
7775
  }
7705
7776
  function makeArrayTypeCheckCall(valueAccessor, typeName, writer) {
@@ -7728,7 +7799,7 @@ class ETSLanguageWriter extends TSLanguageWriter {
7728
7799
  return new ArkTSMapForEachStatement(map, key, value, op);
7729
7800
  }
7730
7801
  makeMapSize(map) {
7731
- return this.makeString(`${super.makeMapSize(map).asString()} as int32`); // TODO: cast really needed?
7802
+ return this.makeString(`${super.makeMapSize(map).asString()}`); // TODO: cast really needed?
7732
7803
  }
7733
7804
  get supportedModifiers() {
7734
7805
  return [MethodModifier.PUBLIC, MethodModifier.PRIVATE, MethodModifier.NATIVE, MethodModifier.STATIC];
@@ -7741,8 +7812,7 @@ class ETSLanguageWriter extends TSLanguageWriter {
7741
7812
  }
7742
7813
  i32FromEnum(value, enumEntry) {
7743
7814
  if (ETSLanguageWriter.isUseTypeChecker) {
7744
- const enumName = this.getNodeName(enumEntry);
7745
- return this.makeMethodCall('TypeChecker', generateEnumToNumericName(enumName), [value]);
7815
+ return this.makeMethodCall('TypeChecker', generateEnumToNumericName(enumEntry), [value]);
7746
7816
  }
7747
7817
  return isStringEnum(enumEntry)
7748
7818
  ? this.makeMethodCall(value.asString(), 'getOrdinal', [])
@@ -7751,7 +7821,7 @@ class ETSLanguageWriter extends TSLanguageWriter {
7751
7821
  enumFromI32(value, enumEntry) {
7752
7822
  const enumName = this.getNodeName(enumEntry);
7753
7823
  if (ETSLanguageWriter.isUseTypeChecker) {
7754
- return this.makeMethodCall('TypeChecker', generateEnumFromNumericName(enumName), [value]);
7824
+ return this.makeMethodCall('TypeChecker', generateEnumFromNumericName(enumEntry), [value]);
7755
7825
  }
7756
7826
  return isStringEnum(enumEntry)
7757
7827
  ? this.makeString(`${enumName}.values()[${value.asString()}]`)
@@ -7843,8 +7913,8 @@ class ETSLanguageWriter extends TSLanguageWriter {
7843
7913
  // The explicit cast forces ui2abc to call valueOf on an int, which fails the compilation
7844
7914
  // TODO Fix this cast
7845
7915
  if (bitness === 8)
7846
- return value;
7847
- return `${value} as int32`; // FIXME: is there int8 in ARKTS?
7916
+ return `(${value}).toChar()`;
7917
+ return `(${value}).toInt()`; // FIXME: is there int8 in ARKTS?
7848
7918
  }
7849
7919
  castToBoolean(value) { return `${value} ? 1 : 0`; }
7850
7920
  instanceOf(convertor, value, duplicateMembers) {
@@ -7881,6 +7951,16 @@ class ETSLanguageWriter extends TSLanguageWriter {
7881
7951
  }
7882
7952
  makeCast(value, node, options) {
7883
7953
  var _a;
7954
+ if (node === IDLI64Type)
7955
+ return this.makeMethodCall(value.asString(), `toLong`, []);
7956
+ if (node === IDLI32Type)
7957
+ return this.makeMethodCall(value.asString(), `toInt`, []);
7958
+ if (node === IDLI8Type)
7959
+ return this.makeMethodCall(value.asString(), `toByte`, []);
7960
+ if (node === IDLF64Type)
7961
+ return this.makeMethodCall(value.asString(), `toDouble`, []);
7962
+ if (node === IDLF32Type)
7963
+ return this.makeMethodCall(value.asString(), `toFloat`, []);
7884
7964
  return new TSCastExpression(value, `${this.getNodeName(node)}`, (_a = options === null || options === void 0 ? void 0 : options.unsafe) !== null && _a !== void 0 ? _a : false);
7885
7965
  }
7886
7966
  static get isUseTypeChecker() { return this._isUseTypeChecker; }
@@ -7994,6 +8074,32 @@ class UnionRuntimeTypeChecker {
7994
8074
  * See the License for the specific language governing permissions and
7995
8075
  * limitations under the License.
7996
8076
  */
8077
+ var LayoutNodeRole;
8078
+ (function (LayoutNodeRole) {
8079
+ LayoutNodeRole[LayoutNodeRole["PEER"] = 0] = "PEER";
8080
+ LayoutNodeRole[LayoutNodeRole["INTERFACE"] = 1] = "INTERFACE";
8081
+ LayoutNodeRole[LayoutNodeRole["GLOBAL"] = 2] = "GLOBAL";
8082
+ LayoutNodeRole[LayoutNodeRole["COMPONENT"] = 3] = "COMPONENT";
8083
+ LayoutNodeRole[LayoutNodeRole["SERIALIZER"] = 4] = "SERIALIZER";
8084
+ })(LayoutNodeRole || (LayoutNodeRole = {}));
8085
+
8086
+ /*
8087
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
8088
+ * Licensed under the Apache License, Version 2.0 (the "License");
8089
+ * you may not use this file except in compliance with the License.
8090
+ * You may obtain a copy of the License at
8091
+ *
8092
+ * http://www.apache.org/licenses/LICENSE-2.0
8093
+ *
8094
+ * Unless required by applicable law or agreed to in writing, software
8095
+ * distributed under the License is distributed on an "AS IS" BASIS,
8096
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8097
+ * See the License for the specific language governing permissions and
8098
+ * limitations under the License.
8099
+ */
8100
+ function getSerializerName(declaration) {
8101
+ return `${getQualifiedName(declaration, "namespace.name").split('.').join('_')}_serializer`;
8102
+ }
7997
8103
  class BaseArgConvertor {
7998
8104
  constructor(idlType, runtimeTypes, isScoped, useArray, param) {
7999
8105
  this.idlType = idlType;
@@ -8101,7 +8207,7 @@ class AggregateConvertor extends BaseArgConvertor {
8101
8207
  convertorSerialize(param, value, printer) {
8102
8208
  this.memberConvertors.forEach((it, index) => {
8103
8209
  let memberName = this.members[index][0];
8104
- let memberAccess = `${value}.${memberName}`;
8210
+ let memberAccess = `${value}.${printer.escapeKeyword(memberName)}`;
8105
8211
  printer.writeStatement(printer.makeAssign(`${value}_${memberName}`, undefined, printer.makeString(memberAccess), true));
8106
8212
  it.convertorSerialize(param, `${value}_${memberName}`, printer);
8107
8213
  });
@@ -8127,9 +8233,7 @@ class AggregateConvertor extends BaseArgConvertor {
8127
8233
  /**
8128
8234
  * todo: check UnionType name creation for union of unnamed nodes (isNamedNode() == false)
8129
8235
  */
8130
- const memberType = prop.isOptional
8131
- ? createUnionType([IDLUndefinedType, prop.type])
8132
- : prop.type;
8236
+ const memberType = maybeOptional(prop.type, prop.isOptional);
8133
8237
  return writer.makeAssign(`${bufferName}_${prop.name}`, memberType, expr, true, true);
8134
8238
  }, writer));
8135
8239
  }
@@ -8179,10 +8283,14 @@ class InterfaceConvertor extends BaseArgConvertor {
8179
8283
  throw new Error("Must never be used");
8180
8284
  }
8181
8285
  convertorSerialize(param, value, printer) {
8182
- printer.writeMethodCall(`${param}Serializer`, `write${this.library.getInteropName(this.idlType)}`, [value]);
8286
+ const accessor = getSerializerName(this.declaration);
8287
+ printer.addFeature(accessor, this.library.layout.resolve({ node: this.declaration, role: LayoutNodeRole.SERIALIZER }));
8288
+ printer.writeStaticMethodCall(accessor, 'write', [`${param}Serializer`, value]);
8183
8289
  }
8184
8290
  convertorDeserialize(bufferName, deserializerName, assigneer, writer) {
8185
- return assigneer(writer.makeMethodCall(`${deserializerName}`, `read${this.library.getInteropName(this.idlType)}`, []));
8291
+ const accessor = getSerializerName(this.declaration);
8292
+ writer.addFeature(accessor, this.library.layout.resolve({ node: this.declaration, role: LayoutNodeRole.SERIALIZER }));
8293
+ return assigneer(writer.makeStaticMethodCall(accessor, 'read', [writer.makeString(deserializerName)]));
8186
8294
  }
8187
8295
  nativeType() {
8188
8296
  return this.idlType;
@@ -8346,13 +8454,13 @@ class OptionConvertor extends BaseArgConvertor {
8346
8454
  const valueType = `${value}_type`.replaceAll('.', '_');
8347
8455
  const serializedType = (printer.language == Language.JAVA ? undefined : IDLI32Type);
8348
8456
  printer.writeStatement(printer.makeAssign(valueType, serializedType, printer.makeRuntimeType(RuntimeType.UNDEFINED), true, false));
8349
- if (printer.language != Language.CJ) {
8457
+ if (printer.language != Language.CJ && printer.language != Language.KOTLIN) {
8350
8458
  printer.runtimeType(this, valueType, value);
8351
8459
  printer.writeMethodCall(`${param}Serializer`, "writeInt8", [printer.castToInt(valueType, 8)]);
8352
8460
  }
8353
8461
  printer.print(`if (${printer.makeRuntimeTypeCondition(valueType, false, RuntimeType.UNDEFINED, value).asString()}) {`);
8354
8462
  printer.pushIndent();
8355
- if (printer.language == Language.CJ) {
8463
+ if (printer.language == Language.CJ || printer.language == Language.KOTLIN) {
8356
8464
  printer.writeMethodCall(`${param}Serializer`, "writeInt8", ["RuntimeType.OBJECT.ordinal"]); // everything is object, except None<T>
8357
8465
  }
8358
8466
  const valueValue = `${value}_value`.replaceAll('.', '_');
@@ -8360,7 +8468,7 @@ class OptionConvertor extends BaseArgConvertor {
8360
8468
  this.typeConvertor.convertorSerialize(param, this.typeConvertor.getObjectAccessor(printer.language, valueValue), printer);
8361
8469
  printer.popIndent();
8362
8470
  printer.print(`}`);
8363
- if (printer.language == Language.CJ) {
8471
+ if (printer.language == Language.CJ || printer.language == Language.KOTLIN) {
8364
8472
  printer.print('else {');
8365
8473
  printer.pushIndent();
8366
8474
  printer.writeMethodCall(`${param}Serializer`, "writeInt8", ["RuntimeType.UNDEFINED.ordinal"]); // undefined
@@ -8376,7 +8484,7 @@ class OptionConvertor extends BaseArgConvertor {
8376
8484
  const statements = [];
8377
8485
  statements.push(writer.makeAssign(runtimeBufferName, undefined, writer.makeCast(writer.makeString(`${deserializerName}.readInt8()`), writer.getRuntimeType()), true));
8378
8486
  const bufferType = this.nativeType();
8379
- statements.push(writer.makeAssign(bufferName, bufferType, writer.language == Language.CJ ? writer.makeNull() : undefined, true, false));
8487
+ statements.push(writer.makeAssign(bufferName, bufferType, (writer.language == Language.CJ || writer.language == Language.KOTLIN) ? writer.makeNull() : undefined, true, false));
8380
8488
  const thenStatement = new BlockStatement([
8381
8489
  this.typeConvertor.convertorDeserialize(`${bufferName}_`, deserializerName, (expr) => {
8382
8490
  const receiver = writer.language === Language.CPP
@@ -8446,7 +8554,7 @@ class UnionConvertor extends BaseArgConvertor {
8446
8554
  statements.push(writer.makeAssign(`${bufferName}.selector`, undefined, writer.makeString(selectorBuffer), false));
8447
8555
  const branches = this.memberConvertors.map((it, index) => {
8448
8556
  const receiver = this.getObjectAccessor(writer.language, bufferName, { index: `${index}` });
8449
- const expr = writer.makeString(`${selectorBuffer} == ${index}`);
8557
+ const expr = writer.makeString(`${selectorBuffer} == ${writer.castToInt(index.toString(), 8)}`);
8450
8558
  const stmt = new BlockStatement([
8451
8559
  writer.makeSetUnionSelector(bufferName, `${index}`),
8452
8560
  it.convertorDeserialize(`${bufferName}_u`, deserializerName, (expr) => {
@@ -8507,8 +8615,9 @@ class FunctionConvertor extends BaseArgConvertor {
8507
8615
  }
8508
8616
  }
8509
8617
  class MaterializedClassConvertor extends BaseArgConvertor {
8510
- constructor(param, declaration) {
8618
+ constructor(library, param, declaration) {
8511
8619
  super(createReferenceType(declaration), [RuntimeType.OBJECT], false, false, param);
8620
+ this.library = library;
8512
8621
  this.declaration = declaration;
8513
8622
  }
8514
8623
  convertorArg(param, writer) {
@@ -8517,18 +8626,20 @@ class MaterializedClassConvertor extends BaseArgConvertor {
8517
8626
  return `static_cast<${generatorTypePrefix()}${qualifiedName(this.declaration, "_", "namespace.name")}>(${param})`;
8518
8627
  case Language.JAVA:
8519
8628
  case Language.CJ:
8520
- return `MaterializedBase.toPeerPtr(${param})`;
8629
+ return `MaterializedBase.toPeerPtr(${writer.escapeKeyword(param)})`;
8521
8630
  default:
8522
8631
  return `toPeerPtr(${param})`;
8523
8632
  }
8524
8633
  }
8525
8634
  convertorSerialize(param, value, printer) {
8526
- printer.writeStatement(printer.makeStatement(printer.makeMethodCall(`${param}Serializer`, `write${qualifiedName(this.declaration, "_", "namespace.name")}`, [
8527
- printer.makeString(value)
8528
- ])));
8635
+ const accessorRoot = getSerializerName(this.declaration);
8636
+ printer.addFeature(accessorRoot, this.library.layout.resolve({ node: this.declaration, role: LayoutNodeRole.SERIALIZER }));
8637
+ printer.writeStaticMethodCall(accessorRoot, 'write', [`${param}Serializer`, value]);
8529
8638
  }
8530
8639
  convertorDeserialize(bufferName, deserializerName, assigneer, writer) {
8531
- const readStatement = writer.makeCast(writer.makeMethodCall(`${deserializerName}`, `read${qualifiedName(this.declaration, "_", "namespace.name")}`, []), this.declaration);
8640
+ const accessorRoot = getSerializerName(this.declaration);
8641
+ writer.addFeature(accessorRoot, this.library.layout.resolve({ node: this.declaration, role: LayoutNodeRole.SERIALIZER }));
8642
+ const readStatement = writer.makeCast(writer.makeStaticMethodCall(accessorRoot, "read", [writer.makeString(deserializerName)]), this.declaration);
8532
8643
  return assigneer(readStatement);
8533
8644
  }
8534
8645
  nativeType() {
@@ -8562,28 +8673,6 @@ function warnCustomObject(type, msg) {
8562
8673
  }
8563
8674
  }
8564
8675
 
8565
- /*
8566
- * Copyright (c) 2024 Huawei Device Co., Ltd.
8567
- * Licensed under the Apache License, Version 2.0 (the "License");
8568
- * you may not use this file except in compliance with the License.
8569
- * You may obtain a copy of the License at
8570
- *
8571
- * http://www.apache.org/licenses/LICENSE-2.0
8572
- *
8573
- * Unless required by applicable law or agreed to in writing, software
8574
- * distributed under the License is distributed on an "AS IS" BASIS,
8575
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8576
- * See the License for the specific language governing permissions and
8577
- * limitations under the License.
8578
- */
8579
- var LayoutNodeRole;
8580
- (function (LayoutNodeRole) {
8581
- LayoutNodeRole[LayoutNodeRole["PEER"] = 0] = "PEER";
8582
- LayoutNodeRole[LayoutNodeRole["INTERFACE"] = 1] = "INTERFACE";
8583
- LayoutNodeRole[LayoutNodeRole["GLOBAL"] = 2] = "GLOBAL";
8584
- LayoutNodeRole[LayoutNodeRole["COMPONENT"] = 3] = "COMPONENT";
8585
- })(LayoutNodeRole || (LayoutNodeRole = {}));
8586
-
8587
8676
  function isInModule(nodeOrPackage, module) {
8588
8677
  if (typeof nodeOrPackage === 'object')
8589
8678
  return isInModule(getPackageName(nodeOrPackage), module);
@@ -8661,10 +8750,6 @@ var IDLValidationDiagnosticsCode;
8661
8750
  [IDLValidationDiagnosticsCode.ENUM_IS_NOT_CONSISTENT]: "Enum includes both string and number values",
8662
8751
  [IDLValidationDiagnosticsCode.REFERENCE_IS_NOT_RESOLVED]: "Can not resolve reference",
8663
8752
  });
8664
- [
8665
- IDLTopType.name,
8666
- IDLObjectType.name,
8667
- ];
8668
8753
 
8669
8754
  /*
8670
8755
  * Copyright (c) 2024 Huawei Device Co., Ltd.
@@ -8872,13 +8957,12 @@ class IDLDeserializer {
8872
8957
  interfaceSubkind(node) {
8873
8958
  var _a, _b;
8874
8959
  const nodeIDLEntity = (_b = (_a = node.extAttrs.find(it => it.name === "Entity")) === null || _a === void 0 ? void 0 : _a.rhs) === null || _b === void 0 ? void 0 : _b.value;
8875
- if (nodeIDLEntity == IDLEntity.Class)
8876
- return IDLInterfaceSubkind.Class;
8877
- if (nodeIDLEntity == IDLEntity.Interface)
8878
- return IDLInterfaceSubkind.Interface;
8879
- if (nodeIDLEntity == IDLEntity.Tuple)
8880
- return IDLInterfaceSubkind.Tuple;
8881
- return IDLInterfaceSubkind.Interface;
8960
+ switch (nodeIDLEntity) {
8961
+ case IDLEntity.Class: return IDLInterfaceSubkind.Class;
8962
+ case IDLEntity.Literal: return IDLInterfaceSubkind.AnonymousInterface;
8963
+ case IDLEntity.Tuple: return IDLInterfaceSubkind.Tuple;
8964
+ default: return IDLInterfaceSubkind.Interface;
8965
+ }
8882
8966
  }
8883
8967
  toIDLInterface(file, node) {
8884
8968
  const generics = this.extractGenerics(node.extAttrs);
@@ -8889,29 +8973,16 @@ class IDLDeserializer {
8889
8973
  return [];
8890
8974
  }
8891
8975
  const implementations = [];
8892
- let extension = undefined;
8893
8976
  node.inheritance.forEach(it => {
8894
8977
  var _a;
8895
8978
  const attributes = it.extAttrs;
8896
8979
  const parentTypeArgs = this.extractTypeArguments(file, attributes !== null && attributes !== void 0 ? attributes : [], IDLExtendedAttributes.TypeArguments);
8897
8980
  const attrs = (_a = this.toExtendedAttributes(attributes !== null && attributes !== void 0 ? attributes : [])) === null || _a === void 0 ? void 0 : _a.filter(it => it.name !== IDLExtendedAttributes.TypeArguments);
8898
- const baseClass = attrs === null || attrs === void 0 ? void 0 : attrs.find(it => it.name === IDLExtendedAttributes.Extends);
8899
8981
  const ref = createReferenceType(it.inheritance, parentTypeArgs, {
8900
8982
  extendedAttributes: attrs
8901
8983
  });
8902
- if (baseClass) {
8903
- extension = ref;
8904
- }
8905
- else {
8906
- implementations.push(ref);
8907
- }
8984
+ implementations.push(ref);
8908
8985
  });
8909
- if (subkind === IDLInterfaceSubkind.Class && extension === undefined && this.inheritanceMode === 'multiple') {
8910
- extension = IDLTopType;
8911
- }
8912
- if (extension) {
8913
- return [extension, ...implementations];
8914
- }
8915
8986
  return implementations;
8916
8987
  })(), node.members
8917
8988
  .filter(isConstructor)
@@ -9403,10 +9474,11 @@ class BridgesConstructions {
9403
9474
  * limitations under the License.
9404
9475
  */
9405
9476
  class Config {
9406
- constructor(ignore, nonNullable, irHack) {
9477
+ constructor(ignore, nonNullable, irHack, fragments) {
9407
9478
  this.ignore = ignore;
9408
9479
  this.nonNullable = nonNullable;
9409
9480
  this.irHack = irHack;
9481
+ this.fragments = fragments;
9410
9482
  }
9411
9483
  static get createPrefix() {
9412
9484
  return `Create`;
@@ -9790,6 +9862,11 @@ class Typechecker {
9790
9862
  return true;
9791
9863
  if (this.isHeir(node, Config.defaultAncestor))
9792
9864
  return true;
9865
+ // TODO: fix
9866
+ if (node === "Program")
9867
+ return true;
9868
+ if (node === "ArkTsConfig")
9869
+ return true;
9793
9870
  return false;
9794
9871
  }
9795
9872
  isReferenceTo(type, isTarget) {
@@ -9813,6 +9890,29 @@ class Typechecker {
9813
9890
  .find(it => it.name === Config.nodeTypeAttribute);
9814
9891
  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;
9815
9892
  }
9893
+ parent(node) {
9894
+ const parentName = parent(node);
9895
+ if (parentName === undefined)
9896
+ return undefined;
9897
+ const decl = this.findRealDeclaration(parentName);
9898
+ if (decl === undefined)
9899
+ return undefined;
9900
+ if (!isInterface$1(decl))
9901
+ return undefined;
9902
+ return decl;
9903
+ }
9904
+ ancestry(node) {
9905
+ let current = node;
9906
+ const res = [];
9907
+ while (true) {
9908
+ res.push(current);
9909
+ const parent = this.parent(current);
9910
+ if (parent === undefined) {
9911
+ return res;
9912
+ }
9913
+ current = parent;
9914
+ }
9915
+ }
9816
9916
  }
9817
9917
 
9818
9918
  /*
@@ -9864,6 +9964,7 @@ class SingleFilePrinter extends AbstractVisitor {
9864
9964
  this.epilogue();
9865
9965
  return [
9866
9966
  (_b = (_a = this.importer) === null || _a === void 0 ? void 0 : _a.getOutput()) !== null && _b !== void 0 ? _b : [],
9967
+ [''],
9867
9968
  this.writer.getOutput()
9868
9969
  ]
9869
9970
  .flat()
@@ -9950,6 +10051,7 @@ class BaseTypeConvertor {
9950
10051
  case IDLStringType: return this.conversions.string(type);
9951
10052
  case IDLVoidType: return this.conversions.void(type);
9952
10053
  case IDLPointerType: return this.conversions.pointer(type);
10054
+ case IDLUndefinedType: return this.conversions.undefined(type);
9953
10055
  }
9954
10056
  throwException(`unsupported primitive type: ${JSON.stringify(type)}`);
9955
10057
  }
@@ -10015,7 +10117,8 @@ let ReturnTypeConvertor$1 = class ReturnTypeConvertor extends BaseTypeConvertor
10015
10117
  f64: (type) => type,
10016
10118
  boolean: (type) => type,
10017
10119
  void: (type) => type,
10018
- pointer: (type) => type
10120
+ pointer: (type) => type,
10121
+ undefined: (type) => type
10019
10122
  });
10020
10123
  }
10021
10124
  };
@@ -10036,7 +10139,7 @@ let ReturnTypeConvertor$1 = class ReturnTypeConvertor extends BaseTypeConvertor
10036
10139
  */
10037
10140
  class InteropTypeConvertor extends BaseTypeConvertor {
10038
10141
  constructor(typechecker, heirConversions) {
10039
- super(typechecker, Object.assign({ enum: (type) => `KInt`, reference: (type) => `KNativePointer`, optional: (type) => throwException(`no nullable allowed at interop level`), i8: (type) => `KBoolean`, iu8: (type) => 'KInt', i16: (type) => `KInt`, i32: (type) => `KInt`, iu32: (type) => `KUInt`, i64: (type) => `KLong`, iu64: (type) => `KULong`, f32: (type) => `KFloat`, f64: (type) => `KDouble`, boolean: (type) => `KBoolean`, void: (type) => `void`, pointer: (type) => `KNativePointer` }, heirConversions));
10142
+ super(typechecker, Object.assign({ enum: (type) => `KInt`, reference: (type) => `KNativePointer`, optional: (type) => throwException(`no nullable allowed at interop level`), undefined: (type) => throwException(`no nullable allowed at interop level`), i8: (type) => `KBoolean`, iu8: (type) => 'KInt', i16: (type) => `KInt`, i32: (type) => `KInt`, iu32: (type) => `KUInt`, i64: (type) => `KLong`, iu64: (type) => `KULong`, f32: (type) => `KFloat`, f64: (type) => `KDouble`, boolean: (type) => `KBoolean`, void: (type) => `void`, pointer: (type) => `KNativePointer` }, heirConversions));
10040
10143
  }
10041
10144
  }
10042
10145
 
@@ -10120,7 +10223,8 @@ class CastTypeConvertor extends BaseTypeConvertor {
10120
10223
  string: (type) => BridgesConstructions.stringCast,
10121
10224
  optional: (type) => throwException(`no optional type allowed at interop level conversion`),
10122
10225
  void: (type) => throwException(`no void typed parameters allowed`),
10123
- pointer: (type) => throwException(`no pointer typed parameters allowed`)
10226
+ pointer: (type) => throwException(`no pointer typed parameters allowed`),
10227
+ undefined: (type) => throwException(`no undefined typed parameters allowed`)
10124
10228
  });
10125
10229
  this.castToTypeConvertor = new CastToTypeConvertor(this.typechecker);
10126
10230
  }
@@ -10149,7 +10253,8 @@ class CastToTypeConvertor extends BaseTypeConvertor {
10149
10253
  optional: (type) => throwException(`no optional type allowed at interop level conversion`),
10150
10254
  string: (type) => "const char*",
10151
10255
  void: (type) => throwException(`no void typed parameters allowed`),
10152
- pointer: (type) => throwException(`no pointer typed parameters allowed`)
10256
+ pointer: (type) => throwException(`no pointer typed parameters allowed`),
10257
+ undefined: (type) => throwException(`no undefined typed parameters allowed`)
10153
10258
  });
10154
10259
  this.nativeTypeConvertor = new NativeTypeConvertor(this.typechecker);
10155
10260
  }
@@ -10427,7 +10532,8 @@ class ReturnTypeConvertor extends BaseTypeConvertor {
10427
10532
  boolean: (type) => type,
10428
10533
  string: (type) => type,
10429
10534
  void: (type) => type,
10430
- pointer: (type) => type
10535
+ pointer: (type) => type,
10536
+ undefined: (type) => throwException(`undefined type is not allowed`)
10431
10537
  });
10432
10538
  }
10433
10539
  }
@@ -10594,6 +10700,9 @@ class PeersConstructions {
10594
10700
  static callPeerMethod(iface, method) {
10595
10701
  return `${iface}.${method}`;
10596
10702
  }
10703
+ static brand(iface) {
10704
+ return `brand${capitalize(iface)}`;
10705
+ }
10597
10706
  }
10598
10707
 
10599
10708
  /*
@@ -10642,6 +10751,14 @@ class Importer {
10642
10751
  this.import(it, `../Es2pandaEnums`);
10643
10752
  return it;
10644
10753
  }
10754
+ withReexportImport(it) {
10755
+ if (this.seen.has(it)) {
10756
+ return it;
10757
+ }
10758
+ this.seen.add(it);
10759
+ this.import(it, "../../reexport-for-generated");
10760
+ return it;
10761
+ }
10645
10762
  import(name, from) {
10646
10763
  this.writer.writeExpressionStatement(this.writer.makeString(PeersConstructions.import(name, path__namespace$1.normalize(path__namespace$1.join(this.dir, from)))));
10647
10764
  }
@@ -10678,7 +10795,8 @@ class TopLevelTypeConvertor extends BaseTypeConvertor {
10678
10795
  f64: heirConversions.number,
10679
10796
  void: heirConversions.void,
10680
10797
  boolean: heirConversions.boolean,
10681
- pointer: heirConversions.pointer
10798
+ pointer: heirConversions.pointer,
10799
+ undefined: heirConversions.undefined
10682
10800
  }));
10683
10801
  }
10684
10802
  }
@@ -10708,7 +10826,8 @@ class LibraryTypeConvertor extends TopLevelTypeConvertor {
10708
10826
  number: (type) => `number`,
10709
10827
  void: (type) => `void`,
10710
10828
  boolean: (type) => `boolean`,
10711
- pointer: (type) => `KNativePointer`
10829
+ pointer: (type) => `KNativePointer`,
10830
+ undefined: (type) => `undefined`
10712
10831
  });
10713
10832
  }
10714
10833
  }
@@ -10750,7 +10869,8 @@ class ImporterTypeConvertor extends TopLevelTypeConvertor {
10750
10869
  number: (type) => type,
10751
10870
  boolean: (type) => type,
10752
10871
  void: (type) => type,
10753
- pointer: (type) => type
10872
+ pointer: (type) => type,
10873
+ undefined: (type) => type
10754
10874
  });
10755
10875
  this.importer = importer;
10756
10876
  }
@@ -10790,6 +10910,7 @@ class BindingParameterTypeConvertor extends TopLevelTypeConvertor {
10790
10910
  void: (type) => (parameter) => parameter,
10791
10911
  pointer: (type) => (parameter) => parameter,
10792
10912
  boolean: (type) => (parameter) => parameter,
10913
+ undefined: (type) => (parameter) => parameter
10793
10914
  });
10794
10915
  }
10795
10916
  }
@@ -10832,6 +10953,7 @@ class BindingReturnValueTypeConvertor extends TopLevelTypeConvertor {
10832
10953
  void: plain,
10833
10954
  pointer: plain,
10834
10955
  boolean: plain,
10956
+ undefined: plain
10835
10957
  });
10836
10958
  }
10837
10959
  }
@@ -10866,6 +10988,7 @@ class PeerPrinter extends SingleFilePrinter {
10866
10988
  return node != this.node;
10867
10989
  }
10868
10990
  constructor(config, idl, node) {
10991
+ var _a;
10869
10992
  super(idl);
10870
10993
  this.config = config;
10871
10994
  this.node = node;
@@ -10873,7 +10996,7 @@ class PeerPrinter extends SingleFilePrinter {
10873
10996
  this.importer = new Importer(this.typechecker, `.`, this.node.name);
10874
10997
  this.bindingParameterTypeConvertor = new BindingParameterTypeConvertor(this.typechecker);
10875
10998
  this.bindingReturnValueTypeConvertor = new BindingReturnValueTypeConvertor(this.typechecker);
10876
- this.parent = parent(this.node); // ?? throwException(`expected peer to have parent: ${this.node.name}`)
10999
+ this.parent = (_a = parent(this.node)) !== null && _a !== void 0 ? _a : Config.defaultAncestor;
10877
11000
  this.writer = new TSLanguageWriter(new IndentedPrinter(), createEmptyReferenceResolver(), { convert: (node) => composedConvertType(new LibraryTypeConvertor(this.typechecker), new ImporterTypeConvertor(this.importer, this.typechecker), node)
10878
11001
  });
10879
11002
  }
@@ -10883,6 +11006,8 @@ class PeerPrinter extends SingleFilePrinter {
10883
11006
  printBody() {
10884
11007
  this.printConstructor();
10885
11008
  this.printMethods();
11009
+ this.printFragment();
11010
+ this.printBrand();
10886
11011
  }
10887
11012
  printConstructor() {
10888
11013
  this.writer.writeConstructorImplementation(this.node.name, new MethodSignature(IDLVoidType, [
@@ -10923,6 +11048,15 @@ class PeerPrinter extends SingleFilePrinter {
10923
11048
  }
10924
11049
  });
10925
11050
  }
11051
+ printFragment() {
11052
+ const methods = this.config.fragments.getCodeFragment(this.node.name);
11053
+ if (methods !== undefined) {
11054
+ methods.forEach(it => {
11055
+ this.importer.withReexportImport(it.definition);
11056
+ this.writer.writeLines(`${it.name} = ${it.definition}`);
11057
+ });
11058
+ }
11059
+ }
10926
11060
  printGetter(node) {
10927
11061
  this.writer.writeMethodImplementation(new Method(peerMethod(node.name), new MethodSignature(flattenType(node.returnType), []), [MethodModifier.GETTER]), () => {
10928
11062
  this.writer.writeStatement(this.writer.makeReturn(this.makeReturnBindingCall(node)));
@@ -10944,9 +11078,13 @@ class PeerPrinter extends SingleFilePrinter {
10944
11078
  }
10945
11079
  printCreateOrUpdate(node) {
10946
11080
  this.writer.writeMethodImplementation(makeMethod(PeersConstructions.createOrUpdate(this.node.name, node.name), node.parameters.map(it => createParameter(it.name, flattenType(it.type))), flattenType(node.returnType), [MethodModifier.STATIC]), () => {
10947
- this.writer.writeStatement(this.writer.makeReturn(this.writer.makeNewObject(this.node.name, [
11081
+ const newExpr = this.writer.makeNewObject(this.node.name, [
10948
11082
  this.writer.makeFunctionCall(this.writer.makeString(PeersConstructions.callBinding(this.node.name, node.name, nodeNamespace(this.node))), this.makeBindingArguments(node.parameters))
10949
- ])));
11083
+ ]);
11084
+ const isAstNode = this.node.inheritance.some(parent => this.typechecker.isHeir(parent.name, Config.astNodeCommonAncestor));
11085
+ const updateMethodName = 'updateChildren';
11086
+ this.writer.writeStatement(this.writer.makeReturn(isAstNode ?
11087
+ this.writer.makeMethodCall(newExpr.asString(), updateMethodName, []) : newExpr));
10950
11088
  });
10951
11089
  }
10952
11090
  makeBindingArguments(parameters) {
@@ -10966,6 +11104,9 @@ class PeerPrinter extends SingleFilePrinter {
10966
11104
  const qualified = `${this.importer.withEnumImport(Config.nodeTypeAttribute)}.${enumValue}`;
10967
11105
  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(`}`));
10968
11106
  }
11107
+ printBrand() {
11108
+ this.writer.writeProperty(PeersConstructions.brand(this.node.name), IDLUndefinedType, [FieldModifier.PROTECTED, FieldModifier.READONLY]);
11109
+ }
10969
11110
  }
10970
11111
 
10971
11112
  /*
@@ -11465,6 +11606,11 @@ class AstNodeFilterTransformer extends BaseInterfaceFilterTransformer {
11465
11606
  return false;
11466
11607
  if (this.typechecker.isHeir(name, Config.defaultAncestor))
11467
11608
  return false;
11609
+ // TODO: fix
11610
+ if (name === "Program")
11611
+ return false;
11612
+ if (name === "ArkTsConfig")
11613
+ return false;
11468
11614
  console.log(`FILTERED (AST) ${name}`);
11469
11615
  return true;
11470
11616
  }
@@ -13484,6 +13630,35 @@ class NonNullableOptions {
13484
13630
  }
13485
13631
  }
13486
13632
 
13633
+ /*
13634
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
13635
+ * Licensed under the Apache License, Version 2.0 (the "License");
13636
+ * you may not use this file except in compliance with the License.
13637
+ * You may obtain a copy of the License at
13638
+ *
13639
+ * http://www.apache.org/licenses/LICENSE-2.0
13640
+ *
13641
+ * Unless required by applicable law or agreed to in writing, software
13642
+ * distributed under the License is distributed on an "AS IS" BASIS,
13643
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13644
+ * See the License for the specific language governing permissions and
13645
+ * limitations under the License.
13646
+ */
13647
+ class CodeFragmentOptions {
13648
+ constructor(filePath) {
13649
+ var _a;
13650
+ this.fragments = [];
13651
+ if (filePath === undefined) {
13652
+ return;
13653
+ }
13654
+ this.fragments = (_a = lib.parse(fs__namespace$1.readFileSync(filePath).toString()).fragments) !== null && _a !== void 0 ? _a : [];
13655
+ }
13656
+ getCodeFragment(name) {
13657
+ var _a;
13658
+ return (_a = this.fragments.find(it => it.interface === name)) === null || _a === void 0 ? void 0 : _a.methods;
13659
+ }
13660
+ }
13661
+
13487
13662
  /*
13488
13663
  * Copyright (c) 2024 Huawei Device Co., Ltd.
13489
13664
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -13504,7 +13679,7 @@ function main() {
13504
13679
  if (options.initialize) {
13505
13680
  new StaticEmitter(options.outputDir, options.pandaSdkPath).emit();
13506
13681
  }
13507
- new DynamicEmitter(options.outputDir, toIDLFile(path__namespace$1.join(options.pandaSdkPath, pandaSdkIdlFilePath), { inheritanceMode: 'single' })[0], new Config(new IgnoreOptions(options.optionsFile), new NonNullableOptions(options.optionsFile), new IrHackOptions(options.optionsFile)), options.debug).emit();
13682
+ new DynamicEmitter(options.outputDir, toIDLFile(path__namespace$1.join(options.pandaSdkPath, pandaSdkIdlFilePath), { inheritanceMode: 'single' })[0], new Config(new IgnoreOptions(options.optionsFile), new NonNullableOptions(options.optionsFile), new IrHackOptions(options.optionsFile), new CodeFragmentOptions(options.optionsFile)), options.debug).emit();
13508
13683
  }
13509
13684
  main();
13510
13685
  //# sourceMappingURL=index.js.map